; LLVM IR from BrunoLevy/learn-fpga :: Basic/Tools/Font (makefont)

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

@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; 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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @gen_chars(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %16, %0
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 16
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %19

11:                                               ; preds = %7
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = load i32, ptr %2, align 4, !tbaa !5
  call void @gen_chars(i32 noundef %12, i32 noundef %13)
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = add nsw i32 %14, 4
  store i32 %15, ptr %2, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %11
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !9

19:                                               ; preds = %10
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %30, %19
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp slt i32 %22, 16
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %33

25:                                               ; preds = %21
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = load i32, ptr %2, align 4, !tbaa !5
  call void @gen_chars(i32 noundef %26, i32 noundef %27)
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = add nsw i32 %28, 4
  store i32 %29, ptr %2, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %4, align 4, !tbaa !5
  br label %21, !llvm.loop !11

33:                                               ; preds = %24
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %44, %33
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = icmp slt i32 %36, 16
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %47

39:                                               ; preds = %35
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = load i32, ptr %2, align 4, !tbaa !5
  call void @gen_chars(i32 noundef %40, i32 noundef %41)
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = add nsw i32 %42, 4
  store i32 %43, ptr %2, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %39
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %5, align 4, !tbaa !5
  br label %35, !llvm.loop !12

47:                                               ; preds = %38
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %58, %47
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = icmp slt i32 %50, 16
  br i1 %51, label %53, label %52

52:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %61

53:                                               ; preds = %49
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = load i32, ptr %2, align 4, !tbaa !5
  call void @gen_chars(i32 noundef %54, i32 noundef %55)
  %56 = load i32, ptr %2, align 4, !tbaa !5
  %57 = add nsw i32 %56, 4
  store i32 %57, ptr %2, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %53
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %6, align 4, !tbaa !5
  br label %49, !llvm.loop !13

61:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %62 = load i32, ptr %1, align 4
  ret i32 %62
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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

@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @gen_chars(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  tail call void @gen_chars(i32 noundef 0, i32 noundef 0)
  tail call void @gen_chars(i32 noundef 1, i32 noundef 4)
  tail call void @gen_chars(i32 noundef 2, i32 noundef 8)
  tail call void @gen_chars(i32 noundef 3, i32 noundef 12)
  tail call void @gen_chars(i32 noundef 4, i32 noundef 16)
  tail call void @gen_chars(i32 noundef 5, i32 noundef 20)
  tail call void @gen_chars(i32 noundef 6, i32 noundef 24)
  tail call void @gen_chars(i32 noundef 7, i32 noundef 28)
  tail call void @gen_chars(i32 noundef 8, i32 noundef 32)
  tail call void @gen_chars(i32 noundef 9, i32 noundef 36)
  tail call void @gen_chars(i32 noundef 10, i32 noundef 40)
  tail call void @gen_chars(i32 noundef 11, i32 noundef 44)
  tail call void @gen_chars(i32 noundef 12, i32 noundef 48)
  tail call void @gen_chars(i32 noundef 13, i32 noundef 52)
  tail call void @gen_chars(i32 noundef 14, i32 noundef 56)
  tail call void @gen_chars(i32 noundef 15, i32 noundef 60)
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  tail call void @gen_chars(i32 noundef 0, i32 noundef 64)
  tail call void @gen_chars(i32 noundef 1, i32 noundef 68)
  tail call void @gen_chars(i32 noundef 2, i32 noundef 72)
  tail call void @gen_chars(i32 noundef 3, i32 noundef 76)
  tail call void @gen_chars(i32 noundef 4, i32 noundef 80)
  tail call void @gen_chars(i32 noundef 5, i32 noundef 84)
  tail call void @gen_chars(i32 noundef 6, i32 noundef 88)
  tail call void @gen_chars(i32 noundef 7, i32 noundef 92)
  tail call void @gen_chars(i32 noundef 8, i32 noundef 96)
  tail call void @gen_chars(i32 noundef 9, i32 noundef 100)
  tail call void @gen_chars(i32 noundef 10, i32 noundef 104)
  tail call void @gen_chars(i32 noundef 11, i32 noundef 108)
  tail call void @gen_chars(i32 noundef 12, i32 noundef 112)
  tail call void @gen_chars(i32 noundef 13, i32 noundef 116)
  tail call void @gen_chars(i32 noundef 14, i32 noundef 120)
  tail call void @gen_chars(i32 noundef 15, i32 noundef 124)
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  tail call void @gen_chars(i32 noundef 0, i32 noundef 128)
  tail call void @gen_chars(i32 noundef 1, i32 noundef 132)
  tail call void @gen_chars(i32 noundef 2, i32 noundef 136)
  tail call void @gen_chars(i32 noundef 3, i32 noundef 140)
  tail call void @gen_chars(i32 noundef 4, i32 noundef 144)
  tail call void @gen_chars(i32 noundef 5, i32 noundef 148)
  tail call void @gen_chars(i32 noundef 6, i32 noundef 152)
  tail call void @gen_chars(i32 noundef 7, i32 noundef 156)
  tail call void @gen_chars(i32 noundef 8, i32 noundef 160)
  tail call void @gen_chars(i32 noundef 9, i32 noundef 164)
  tail call void @gen_chars(i32 noundef 10, i32 noundef 168)
  tail call void @gen_chars(i32 noundef 11, i32 noundef 172)
  tail call void @gen_chars(i32 noundef 12, i32 noundef 176)
  tail call void @gen_chars(i32 noundef 13, i32 noundef 180)
  tail call void @gen_chars(i32 noundef 14, i32 noundef 184)
  tail call void @gen_chars(i32 noundef 15, i32 noundef 188)
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  tail call void @gen_chars(i32 noundef 0, i32 noundef 192)
  tail call void @gen_chars(i32 noundef 1, i32 noundef 196)
  tail call void @gen_chars(i32 noundef 2, i32 noundef 200)
  tail call void @gen_chars(i32 noundef 3, i32 noundef 204)
  tail call void @gen_chars(i32 noundef 4, i32 noundef 208)
  tail call void @gen_chars(i32 noundef 5, i32 noundef 212)
  tail call void @gen_chars(i32 noundef 6, i32 noundef 216)
  tail call void @gen_chars(i32 noundef 7, i32 noundef 220)
  tail call void @gen_chars(i32 noundef 8, i32 noundef 224)
  tail call void @gen_chars(i32 noundef 9, i32 noundef 228)
  tail call void @gen_chars(i32 noundef 10, i32 noundef 232)
  tail call void @gen_chars(i32 noundef 11, i32 noundef 236)
  tail call void @gen_chars(i32 noundef 12, i32 noundef 240)
  tail call void @gen_chars(i32 noundef 13, i32 noundef 244)
  tail call void @gen_chars(i32 noundef 14, i32 noundef 248)
  tail call void @gen_chars(i32 noundef 15, i32 noundef 252)
  ret i32 0
}

attributes #0 = { nofree nounwind "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)"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass