; LLVM IR from freakout42/macrocalc :: mc/mex (files)

; 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 void @cpyfname(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 0
  store ptr %9, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 0
  store ptr %11, ptr %6, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %24, %2
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 127
  %16 = icmp ne ptr %13, %15
  br i1 %16, label %17, label %22

17:                                               ; preds = %12
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load i8, ptr %18, align 1, !tbaa !9
  %20 = sext i8 %19 to i32
  %21 = icmp ne i32 %20, 0
  br label %22

22:                                               ; preds = %17, %12
  %23 = phi i1 [ false, %12 ], [ %21, %17 ]
  br i1 %23, label %24, label %31

24:                                               ; preds = %22
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i32 1
  store ptr %26, ptr %5, align 8, !tbaa !5
  %27 = load i8, ptr %25, align 1, !tbaa !9
  store i8 %27, ptr %7, align 1, !tbaa !9
  %28 = load i8, ptr %7, align 1, !tbaa !9
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i32 1
  store ptr %30, ptr %6, align 8, !tbaa !5
  store i8 %28, ptr %29, align 1, !tbaa !9
  br label %12, !llvm.loop !10

31:                                               ; preds = %22
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 0, ptr %32, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

; 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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 void @cpyfname(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %scevgep = getelementptr i8, ptr %0, i64 127
  br label %3

3:                                                ; preds = %15, %2
  %.011 = phi ptr [ %1, %2 ], [ %16, %15 ]
  %.08.idx10 = phi i64 [ 0, %2 ], [ %.08.add.3, %15 ]
  %.08.ptr12 = getelementptr inbounds i8, ptr %0, i64 %.08.idx10
  %4 = load i8, ptr %.011, align 1, !tbaa !5
  %.not9 = icmp eq i8 %4, 0
  br i1 %.not9, label %.critedge, label %5

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %.011, i64 1
  %.08.add = or disjoint i64 %.08.idx10, 1
  store i8 %4, ptr %.08.ptr12, align 1, !tbaa !5
  %.08.ptr12.1 = getelementptr inbounds i8, ptr %0, i64 %.08.add
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %.not9.1 = icmp eq i8 %7, 0
  br i1 %.not9.1, label %.critedge, label %8

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %.011, i64 2
  %.08.add.1 = or disjoint i64 %.08.idx10, 2
  store i8 %7, ptr %.08.ptr12.1, align 1, !tbaa !5
  %.08.ptr12.2 = getelementptr inbounds i8, ptr %0, i64 %.08.add.1
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %.not9.2 = icmp eq i8 %10, 0
  br i1 %.not9.2, label %.critedge, label %11

11:                                               ; preds = %8
  store i8 %10, ptr %.08.ptr12.2, align 1, !tbaa !5
  %.not.2 = icmp eq i64 %.08.idx10, 124
  br i1 %.not.2, label %.critedge, label %12, !llvm.loop !8

12:                                               ; preds = %11
  %13 = getelementptr inbounds i8, ptr %.011, i64 3
  %.08.add.2 = or disjoint i64 %.08.idx10, 3
  %.08.ptr12.3 = getelementptr inbounds i8, ptr %0, i64 %.08.add.2
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %.not9.3 = icmp eq i8 %14, 0
  br i1 %.not9.3, label %.critedge, label %15

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %.011, i64 4
  %.08.add.3 = add nuw nsw i64 %.08.idx10, 4
  store i8 %14, ptr %.08.ptr12.3, align 1, !tbaa !5
  br label %3

.critedge:                                        ; preds = %12, %11, %8, %5, %3
  %.08.ptr.lcssa = phi ptr [ %.08.ptr12, %3 ], [ %.08.ptr12.1, %5 ], [ %.08.ptr12.2, %8 ], [ %scevgep, %11 ], [ %.08.ptr12.3, %12 ]
  store i8 0, ptr %.08.ptr.lcssa, align 1, !tbaa !5
  ret void
}

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"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass