; LLVM IR from BrunoLevy/learn-fpga :: FemtoRV/FIRMWARE/TOOLS/FONT (make_font8x8)

; 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.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [11 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
  %7 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %8

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

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %20

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

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

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

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

25:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %34

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

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

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

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

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

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

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

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

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

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

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

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

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

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.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [11 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 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  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)
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  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)
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  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)
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  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