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

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

@lmargin = external global i32, align 4
@tabsize = external global i32, align 4
@.str.4 = external hidden unnamed_addr constant [40 x i8], align 1
@fillcol = external global i32, align 4
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1

declare void @mlwrite(ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @setfillcol(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %8, %2
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %19

12:                                               ; preds = %9
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = load i32, ptr @lmargin, align 4, !tbaa !5
  %15 = load i32, ptr @tabsize, align 4, !tbaa !5
  %16 = add nsw i32 %14, %15
  %17 = icmp slt i32 %13, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %12
  call void (ptr, ...) @mlwrite(ptr noundef @.str.4)
  store i32 2, ptr %3, align 4
  br label %27

19:                                               ; preds = %12, %9
  %20 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %20, ptr @fillcol, align 4, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %19
  call void (ptr, ...) @mlwrite(ptr noundef @.str.5)
  br label %26

24:                                               ; preds = %19
  %25 = load i32, ptr %5, align 4, !tbaa !5
  call void (ptr, ...) @mlwrite(ptr noundef @.str.6, i32 noundef %25)
  br label %26

26:                                               ; preds = %24, %23
  store i32 1, ptr %3, align 4
  br label %27

27:                                               ; preds = %26, %18
  %28 = load i32, ptr %3, align 4
  ret i32 %28
}

attributes #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 = { 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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

@lmargin = external local_unnamed_addr global i32, align 4
@tabsize = external local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [40 x i8], align 1
@fillcol = external local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1

declare void @mlwrite(ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 1, 3) i32 @setfillcol(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %.not = icmp ult i32 %1, 2
  br i1 %.not, label %9, label %3

3:                                                ; preds = %2
  %4 = load i32, ptr @lmargin, align 4, !tbaa !5
  %5 = load i32, ptr @tabsize, align 4, !tbaa !5
  %6 = add nsw i32 %5, %4
  %7 = icmp sgt i32 %6, %1
  br i1 %7, label %8, label %10

8:                                                ; preds = %3
  tail call void (ptr, ...) @mlwrite(ptr noundef nonnull @.str.4) #2
  br label %11

9:                                                ; preds = %2
  store i32 0, ptr @fillcol, align 4, !tbaa !5
  tail call void (ptr, ...) @mlwrite(ptr noundef nonnull @.str.5) #2
  br label %11

10:                                               ; preds = %3
  store i32 %1, ptr @fillcol, align 4, !tbaa !5
  tail call void (ptr, ...) @mlwrite(ptr noundef nonnull @.str.6, i32 noundef %1) #2
  br label %11

11:                                               ; preds = %9, %10, %8
  %.0 = phi i32 [ 2, %8 ], [ 1, %10 ], [ 1, %9 ]
  ret i32 %.0
}

attributes #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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass