; LLVM IR from simon-zerisenay/42_Push_Swap :: libft (ft_memcpy)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
define dso_local ptr @ft_memcpy(ptr noalias noundef %0, ptr noalias noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %17

13:                                               ; preds = %3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %45

17:                                               ; preds = %13, %3
  store i32 0, ptr %9, align 4, !tbaa !11
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %24, label %20

20:                                               ; preds = %17
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call i64 @ft_strlen(ptr noundef %21)
  %23 = trunc i64 %22 to i32
  store i32 %23, ptr %9, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %20, %17
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %25

25:                                               ; preds = %29, %24
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = add i64 %26, -1
  store i64 %27, ptr %7, align 8, !tbaa !9
  %28 = icmp ne i64 %26, 0
  br i1 %28, label %29, label %43

29:                                               ; preds = %25
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !11
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %30, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !13
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load i32, ptr %9, align 4, !tbaa !11
  %37 = load i32, ptr %8, align 4, !tbaa !11
  %38 = add i32 %36, %37
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %35, i64 %39
  store i8 %34, ptr %40, align 1, !tbaa !13
  %41 = load i32, ptr %8, align 4, !tbaa !11
  %42 = add i32 %41, 1
  store i32 %42, ptr %8, align 4, !tbaa !11
  br label %25, !llvm.loop !14

43:                                               ; preds = %25
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %44, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %45

45:                                               ; preds = %43, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %46 = load ptr, ptr %4, align 8
  ret ptr %46
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i64 @ft_strlen(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @ft_memcpy(ptr noalias noundef returned writeonly %0, ptr noalias noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %1, null
  %or.cond = and i1 %4, %5
  br i1 %or.cond, label %.loopexit, label %6

6:                                                ; preds = %3
  br i1 %4, label %7, label %10

7:                                                ; preds = %6
  %8 = tail call i64 @ft_strlen(ptr noundef null) #2
  %9 = trunc i64 %8 to i32
  br label %10

10:                                               ; preds = %7, %6
  %.0 = phi i32 [ 0, %6 ], [ %9, %7 ]
  %.not1718 = icmp eq i64 %2, 0
  br i1 %.not1718, label %.loopexit, label %iter.check

iter.check:                                       ; preds = %10
  %min.iters.check = icmp ult i64 %2, 8
  br i1 %min.iters.check, label %.lr.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %iter.check
  %11 = add i64 %2, -1
  %12 = trunc i64 %11 to i32
  %13 = xor i32 %.0, -1
  %14 = icmp ult i32 %13, %12
  %15 = icmp ugt i64 %11, 4294967295
  %16 = or i1 %14, %15
  br i1 %16, label %.lr.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %vector.scevcheck
  %min.iters.check21 = icmp ult i64 %2, 32
  br i1 %min.iters.check21, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %2, 8589934560
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = trunc i64 %index to i32
  %17 = and i64 %index, 4294967264
  %18 = getelementptr inbounds i8, ptr %1, i64 %17
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %wide.load = load <16 x i8>, ptr %18, align 1, !tbaa !5
  %wide.load22 = load <16 x i8>, ptr %19, align 1, !tbaa !5
  %20 = add i32 %.0, %offset.idx
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %0, i64 %21
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  store <16 x i8> %wide.load, ptr %22, align 1, !tbaa !5
  store <16 x i8> %wide.load22, ptr %23, align 1, !tbaa !5
  %index.next = add nuw i64 %index, 32
  %24 = icmp eq i64 %index.next, %n.vec
  br i1 %24, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %2
  br i1 %cmp.n, label %.loopexit, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %ind.end27 = and i64 %2, 31
  %ind.end25 = trunc i64 %n.vec to i32
  %n.vec.remaining = and i64 %2, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %.lr.ph.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec24 = and i64 %2, 8589934584
  %ind.end = trunc i64 %n.vec24 to i32
  %ind.end26 = and i64 %2, 7
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index29 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next32, %vec.epilog.vector.body ]
  %offset.idx30 = trunc i64 %index29 to i32
  %25 = and i64 %index29, 4294967288
  %26 = getelementptr inbounds i8, ptr %1, i64 %25
  %wide.load31 = load <8 x i8>, ptr %26, align 1, !tbaa !5
  %27 = add i32 %.0, %offset.idx30
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %0, i64 %28
  store <8 x i8> %wide.load31, ptr %29, align 1, !tbaa !5
  %index.next32 = add nuw i64 %index29, 8
  %30 = icmp eq i64 %index.next32, %n.vec24
  br i1 %30, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !12

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n33 = icmp eq i64 %n.vec24, %2
  br i1 %cmp.n33, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %vec.epilog.middle.block, %vector.scevcheck, %iter.check, %vec.epilog.iter.check
  %.01320.ph = phi i32 [ 0, %iter.check ], [ 0, %vector.scevcheck ], [ %ind.end25, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  %.01419.ph = phi i64 [ %2, %iter.check ], [ %2, %vector.scevcheck ], [ %ind.end27, %vec.epilog.iter.check ], [ %ind.end26, %vec.epilog.middle.block ]
  %31 = add i64 %.01419.ph, -1
  %xtraiter = and i64 %.01419.ph, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %.01320.prol = phi i32 [ %39, %.lr.ph.prol ], [ %.01320.ph, %.lr.ph.preheader ]
  %.01419.prol = phi i64 [ %32, %.lr.ph.prol ], [ %.01419.ph, %.lr.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %32 = add i64 %.01419.prol, -1
  %33 = zext i32 %.01320.prol to i64
  %34 = getelementptr inbounds i8, ptr %1, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = add i32 %.01320.prol, %.0
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds i8, ptr %0, i64 %37
  store i8 %35, ptr %38, align 1, !tbaa !5
  %39 = add i32 %.01320.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !13

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.01320.unr = phi i32 [ %.01320.ph, %.lr.ph.preheader ], [ %39, %.lr.ph.prol ]
  %.01419.unr = phi i64 [ %.01419.ph, %.lr.ph.preheader ], [ %32, %.lr.ph.prol ]
  %40 = icmp ult i64 %31, 3
  br i1 %40, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.01320 = phi i32 [ %69, %.lr.ph ], [ %.01320.unr, %.lr.ph.prol.loopexit ]
  %.01419 = phi i64 [ %62, %.lr.ph ], [ %.01419.unr, %.lr.ph.prol.loopexit ]
  %41 = zext i32 %.01320 to i64
  %42 = getelementptr inbounds i8, ptr %1, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = add i32 %.01320, %.0
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %0, i64 %45
  store i8 %43, ptr %46, align 1, !tbaa !5
  %47 = add i32 %.01320, 1
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %1, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !5
  %51 = add i32 %47, %.0
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds i8, ptr %0, i64 %52
  store i8 %50, ptr %53, align 1, !tbaa !5
  %54 = add i32 %.01320, 2
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %1, i64 %55
  %57 = load i8, ptr %56, align 1, !tbaa !5
  %58 = add i32 %54, %.0
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds i8, ptr %0, i64 %59
  store i8 %57, ptr %60, align 1, !tbaa !5
  %61 = add i32 %.01320, 3
  %62 = add i64 %.01419, -4
  %63 = zext i32 %61 to i64
  %64 = getelementptr inbounds i8, ptr %1, i64 %63
  %65 = load i8, ptr %64, align 1, !tbaa !5
  %66 = add i32 %61, %.0
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds i8, ptr %0, i64 %67
  store i8 %65, ptr %68, align 1, !tbaa !5
  %69 = add i32 %.01320, 4
  %.not17.3 = icmp eq i64 %62, 0
  br i1 %.not17.3, label %.loopexit, label %.lr.ph, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %vec.epilog.middle.block, %10, %3
  ret ptr %0
}

declare i64 @ft_strlen(ptr noundef) local_unnamed_addr #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !9, !10, !11}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !9, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass