; ModuleID = 'byte-copy.before.ll'
source_filename = "byte-copy.before.ll"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define void @byte_copy(ptr noalias %dst, ptr noalias readonly %src, i64 %n) {
entry:
  %empty = icmp eq i64 %n, 0
  br i1 %empty, label %exit, label %loop.preheader

loop.preheader:                                   ; preds = %entry
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %dst, ptr align 1 %src, i64 %n, i1 false)
  br label %loop

loop:                                             ; preds = %loop.preheader, %loop
  %i = phi i64 [ %next, %loop ], [ 0, %loop.preheader ]
  %from = getelementptr i8, ptr %src, i64 %i
  %to = getelementptr i8, ptr %dst, i64 %i
  %value = load i8, ptr %from, align 1
  %next = add nuw i64 %i, 1
  %more = icmp ult i64 %next, %n
  br i1 %more, label %loop, label %exit.loopexit

exit.loopexit:                                    ; preds = %loop
  br label %exit

exit:                                             ; preds = %exit.loopexit, %entry
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #0

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
