; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @makename(ptr noundef %0, ptr noundef %1) #1 {
  %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
  br label %10

10:                                               ; preds = %15, %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load i8, ptr %11, align 1, !tbaa !9
  %13 = sext i8 %12 to i32
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %18

15:                                               ; preds = %10
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i32 1
  store ptr %17, ptr %5, align 8, !tbaa !5
  br label %10, !llvm.loop !10

18:                                               ; preds = %10
  br label %19

19:                                               ; preds = %32, %18
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 0
  %23 = icmp ne ptr %20, %22
  br i1 %23, label %24, label %30

24:                                               ; preds = %19
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 -1
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  %29 = icmp ne i32 %28, 47
  br label %30

30:                                               ; preds = %24, %19
  %31 = phi i1 [ false, %19 ], [ %29, %24 ]
  br i1 %31, label %32, label %35

32:                                               ; preds = %30
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i32 -1
  store ptr %34, ptr %5, align 8, !tbaa !5
  br label %19, !llvm.loop !12

35:                                               ; preds = %30
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 0
  store ptr %37, ptr %6, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %55, %35
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 127
  %42 = icmp ne ptr %39, %41
  br i1 %42, label %43, label %53

43:                                               ; preds = %38
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i8, ptr %44, align 1, !tbaa !9
  %46 = sext i8 %45 to i32
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %53

48:                                               ; preds = %43
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load i8, ptr %49, align 1, !tbaa !9
  %51 = sext i8 %50 to i32
  %52 = icmp ne i32 %51, 59
  br label %53

53:                                               ; preds = %48, %43, %38
  %54 = phi i1 [ false, %43 ], [ false, %38 ], [ %52, %48 ]
  br i1 %54, label %55, label %62

55:                                               ; preds = %53
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i32 1
  store ptr %57, ptr %5, align 8, !tbaa !5
  %58 = load i8, ptr %56, align 1, !tbaa !9
  store i8 %58, ptr %7, align 1, !tbaa !9
  %59 = load i8, ptr %7, align 1, !tbaa !9
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i32 1
  store ptr %61, ptr %6, align 8, !tbaa !5
  store i8 %59, ptr %60, align 1, !tbaa !9
  br label %38, !llvm.loop !13

62:                                               ; preds = %53
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 0, ptr %63, 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
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}


; 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 @makename(ptr nocapture noundef writeonly %0, ptr noundef readonly %1) local_unnamed_addr #0 {
  br label %3

3:                                                ; preds = %3, %2
  %.0 = phi ptr [ %1, %2 ], [ %5, %3 ]
  %4 = load i8, ptr %.0, align 1, !tbaa !5
  %.not = icmp eq i8 %4, 0
  %5 = getelementptr inbounds i8, ptr %.0, i64 1
  br i1 %.not, label %.preheader, label %3, !llvm.loop !8

.preheader:                                       ; preds = %3, %6
  %.1 = phi ptr [ %7, %6 ], [ %.0, %3 ]
  %.not19 = icmp eq ptr %.1, %1
  br i1 %.not19, label %.critedge, label %6

6:                                                ; preds = %.preheader
  %7 = getelementptr inbounds i8, ptr %.1, i64 -1
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %.not20 = icmp eq i8 %8, 47
  br i1 %.not20, label %.critedge, label %.preheader, !llvm.loop !10

.critedge:                                        ; preds = %.preheader, %6
  %.1.lcssa = phi ptr [ %1, %.preheader ], [ %.1, %6 ]
  %scevgep = getelementptr i8, ptr %0, i64 127
  br label %9

9:                                                ; preds = %21, %.critedge
  %.225 = phi ptr [ %.1.lcssa, %.critedge ], [ %22, %21 ]
  %.017.idx24 = phi i64 [ 0, %.critedge ], [ %.017.add.3, %21 ]
  %.017.ptr26 = getelementptr inbounds i8, ptr %0, i64 %.017.idx24
  %10 = load i8, ptr %.225, align 1, !tbaa !5
  switch i8 %10, label %11 [
    i8 0, label %.critedge2
    i8 59, label %.critedge2
  ]

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %.225, i64 1
  %.017.add = or disjoint i64 %.017.idx24, 1
  store i8 %10, ptr %.017.ptr26, align 1, !tbaa !5
  %.017.ptr26.1 = getelementptr inbounds i8, ptr %0, i64 %.017.add
  %13 = load i8, ptr %12, align 1, !tbaa !5
  switch i8 %13, label %14 [
    i8 0, label %.critedge2
    i8 59, label %.critedge2
  ]

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %.225, i64 2
  %.017.add.1 = or disjoint i64 %.017.idx24, 2
  store i8 %13, ptr %.017.ptr26.1, align 1, !tbaa !5
  %.017.ptr26.2 = getelementptr inbounds i8, ptr %0, i64 %.017.add.1
  %16 = load i8, ptr %15, align 1, !tbaa !5
  switch i8 %16, label %17 [
    i8 0, label %.critedge2
    i8 59, label %.critedge2
  ]

17:                                               ; preds = %14
  store i8 %16, ptr %.017.ptr26.2, align 1, !tbaa !5
  %.not21.2 = icmp eq i64 %.017.idx24, 124
  br i1 %.not21.2, label %.critedge2, label %18, !llvm.loop !11

18:                                               ; preds = %17
  %19 = getelementptr inbounds i8, ptr %.225, i64 3
  %.017.add.2 = or disjoint i64 %.017.idx24, 3
  %.017.ptr26.3 = getelementptr inbounds i8, ptr %0, i64 %.017.add.2
  %20 = load i8, ptr %19, align 1, !tbaa !5
  switch i8 %20, label %21 [
    i8 0, label %.critedge2
    i8 59, label %.critedge2
  ]

21:                                               ; preds = %18
  %22 = getelementptr inbounds i8, ptr %.225, i64 4
  %.017.add.3 = add nuw nsw i64 %.017.idx24, 4
  store i8 %20, ptr %.017.ptr26.3, align 1, !tbaa !5
  br label %9

.critedge2:                                       ; preds = %18, %18, %17, %14, %14, %11, %11, %9, %9
  %.017.ptr.lcssa = phi ptr [ %.017.ptr26, %9 ], [ %.017.ptr26, %9 ], [ %.017.ptr26.1, %11 ], [ %.017.ptr26.1, %11 ], [ %.017.ptr26.2, %14 ], [ %.017.ptr26.2, %14 ], [ %scevgep, %17 ], [ %.017.ptr26.3, %18 ], [ %.017.ptr26.3, %18 ]
  store i8 0, ptr %.017.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"}
!10 = distinct !{!10, !9}
!11 = distinct !{!11, !9}


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