; LLVM IR from 48d31kh413k/1337-push_swap-42 :: libft (ft_memmove)

; 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_memmove(ptr noundef %0, ptr 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 i64, align 8
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = 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 8, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  store i64 0, ptr %8, align 8, !tbaa !9
  store i8 1, ptr %9, align 1, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %13, ptr %10, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %14, ptr %11, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %21, label %17

17:                                               ; preds = %3
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  store ptr null, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %57

21:                                               ; preds = %17, %3
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = icmp ugt ptr %22, %23
  br i1 %24, label %25, label %34

25:                                               ; preds = %21
  store i8 -1, ptr %9, align 1, !tbaa !11
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = sub i64 %26, 1
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 %27
  store ptr %29, ptr %10, align 8, !tbaa !5
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = sub i64 %30, 1
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 %31
  store ptr %33, ptr %11, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %25, %21
  br label %35

35:                                               ; preds = %39, %34
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = load i64, ptr %7, align 8, !tbaa !9
  %38 = icmp ult i64 %36, %37
  br i1 %38, label %39, label %55

39:                                               ; preds = %35
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  store i8 %41, ptr %42, align 1, !tbaa !11
  %43 = load i8, ptr %9, align 1, !tbaa !11
  %44 = sext i8 %43 to i32
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = sext i32 %44 to i64
  %47 = getelementptr inbounds i8, ptr %45, i64 %46
  store ptr %47, ptr %10, align 8, !tbaa !5
  %48 = load i8, ptr %9, align 1, !tbaa !11
  %49 = sext i8 %48 to i32
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = sext i32 %49 to i64
  %52 = getelementptr inbounds i8, ptr %50, i64 %51
  store ptr %52, ptr %11, align 8, !tbaa !5
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = add i64 %53, 1
  store i64 %54, ptr %8, align 8, !tbaa !9
  br label %35, !llvm.loop !12

55:                                               ; preds = %35
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %56, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %57

57:                                               ; preds = %55, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %58 = load ptr, ptr %4, align 8
  ret ptr %58
}

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

; 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 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef ptr @ft_memmove(ptr noundef returned writeonly %0, ptr noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = icmp ne ptr %0, null
  %5 = icmp ne ptr %1, null
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %6, label %.loopexit

6:                                                ; preds = %3
  %7 = icmp ugt ptr %0, %1
  %.023 = select i1 %7, i64 -1, i64 1
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %6
  %8 = add i64 %2, -1
  %.021.idx = select i1 %7, i64 %8, i64 0
  %.0 = getelementptr inbounds i8, ptr %1, i64 %.021.idx
  %.021 = getelementptr inbounds i8, ptr %0, i64 %.021.idx
  %xtraiter = and i64 %2, 7
  %9 = icmp ult i64 %2, 8
  br i1 %9, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %2, -8
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.132 = phi ptr [ %.0, %.lr.ph.preheader.new ], [ %33, %.lr.ph ]
  %.12231 = phi ptr [ %.021, %.lr.ph.preheader.new ], [ %32, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.7, %.lr.ph ]
  %10 = load i8, ptr %.132, align 1, !tbaa !5
  store i8 %10, ptr %.12231, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %.12231, i64 %.023
  %12 = getelementptr inbounds i8, ptr %.132, i64 %.023
  %13 = load i8, ptr %12, align 1, !tbaa !5
  store i8 %13, ptr %11, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %11, i64 %.023
  %15 = getelementptr inbounds i8, ptr %12, i64 %.023
  %16 = load i8, ptr %15, align 1, !tbaa !5
  store i8 %16, ptr %14, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %14, i64 %.023
  %18 = getelementptr inbounds i8, ptr %15, i64 %.023
  %19 = load i8, ptr %18, align 1, !tbaa !5
  store i8 %19, ptr %17, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %17, i64 %.023
  %21 = getelementptr inbounds i8, ptr %18, i64 %.023
  %22 = load i8, ptr %21, align 1, !tbaa !5
  store i8 %22, ptr %20, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %20, i64 %.023
  %24 = getelementptr inbounds i8, ptr %21, i64 %.023
  %25 = load i8, ptr %24, align 1, !tbaa !5
  store i8 %25, ptr %23, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %23, i64 %.023
  %27 = getelementptr inbounds i8, ptr %24, i64 %.023
  %28 = load i8, ptr %27, align 1, !tbaa !5
  store i8 %28, ptr %26, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %26, i64 %.023
  %30 = getelementptr inbounds i8, ptr %27, i64 %.023
  %31 = load i8, ptr %30, align 1, !tbaa !5
  store i8 %31, ptr %29, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %29, i64 %.023
  %33 = getelementptr inbounds i8, ptr %30, i64 %.023
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !8

.loopexit.loopexit.unr-lcssa:                     ; preds = %.lr.ph, %.lr.ph.preheader
  %.132.unr = phi ptr [ %.0, %.lr.ph.preheader ], [ %33, %.lr.ph ]
  %.12231.unr = phi ptr [ %.021, %.lr.ph.preheader ], [ %32, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.loopexit.loopexit.unr-lcssa, %.lr.ph.epil
  %.132.epil = phi ptr [ %36, %.lr.ph.epil ], [ %.132.unr, %.loopexit.loopexit.unr-lcssa ]
  %.12231.epil = phi ptr [ %35, %.lr.ph.epil ], [ %.12231.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %34 = load i8, ptr %.132.epil, align 1, !tbaa !5
  store i8 %34, ptr %.12231.epil, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %.12231.epil, i64 %.023
  %36 = getelementptr inbounds i8, ptr %.132.epil, i64 %.023
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.lr.ph.epil, !llvm.loop !10

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %.lr.ph.epil, %6, %3
  ret ptr %0
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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" }

!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}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.unroll.disable"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass