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

; 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.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = 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

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

; 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
declare dso_local ptr @int_to_hex(i32 noundef) #2

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

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

11:                                               ; preds = %49, %2
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = add nsw i32 %13, 4
  %15 = icmp slt i32 %12, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %52

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %45, %17
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 8
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %48

22:                                               ; preds = %18
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = and i32 %23, 3
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %28, label %26

26:                                               ; preds = %22
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %28

28:                                               ; preds = %26, %22
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = call i32 @get_font_column(i32 noundef %29, i32 noundef %30)
  %32 = call ptr @int_to_hex(i32 noundef %31)
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %32)
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = and i32 %34, 3
  %36 = icmp eq i32 %35, 3
  br i1 %36, label %37, label %44

37:                                               ; preds = %28
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = icmp ne i32 %38, 7
  br i1 %39, label %40, label %44

40:                                               ; preds = %37
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %5, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %40, %37, %28
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %8, align 4, !tbaa !5
  br label %18, !llvm.loop !9

48:                                               ; preds = %21
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %6, align 4, !tbaa !5
  br label %11, !llvm.loop !11

52:                                               ; preds = %16
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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}


; 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.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.5 = 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 ptr @int_to_hex(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @gen_chars(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %5 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 0)
  %6 = tail call ptr @int_to_hex(i32 noundef %5)
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %6)
  %8 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 1)
  %9 = tail call ptr @int_to_hex(i32 noundef %8)
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %9)
  %11 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 2)
  %12 = tail call ptr @int_to_hex(i32 noundef %11)
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %12)
  %14 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 3)
  %15 = tail call ptr @int_to_hex(i32 noundef %14)
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %15)
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %19 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 4)
  %20 = tail call ptr @int_to_hex(i32 noundef %19)
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %20)
  %22 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 5)
  %23 = tail call ptr @int_to_hex(i32 noundef %22)
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %23)
  %25 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 6)
  %26 = tail call ptr @int_to_hex(i32 noundef %25)
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %26)
  %28 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 7)
  %29 = tail call ptr @int_to_hex(i32 noundef %28)
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %29)
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %32 = add nsw i32 %1, 1
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %34 = tail call i32 @get_font_column(i32 noundef %32, i32 noundef 0)
  %35 = tail call ptr @int_to_hex(i32 noundef %34)
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %35)
  %37 = tail call i32 @get_font_column(i32 noundef %32, i32 noundef 1)
  %38 = tail call ptr @int_to_hex(i32 noundef %37)
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %38)
  %40 = tail call i32 @get_font_column(i32 noundef %32, i32 noundef 2)
  %41 = tail call ptr @int_to_hex(i32 noundef %40)
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %41)
  %43 = tail call i32 @get_font_column(i32 noundef %32, i32 noundef 3)
  %44 = tail call ptr @int_to_hex(i32 noundef %43)
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %44)
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %48 = tail call i32 @get_font_column(i32 noundef %32, i32 noundef 4)
  %49 = tail call ptr @int_to_hex(i32 noundef %48)
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %49)
  %51 = tail call i32 @get_font_column(i32 noundef %32, i32 noundef 5)
  %52 = tail call ptr @int_to_hex(i32 noundef %51)
  %53 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %52)
  %54 = tail call i32 @get_font_column(i32 noundef %32, i32 noundef 6)
  %55 = tail call ptr @int_to_hex(i32 noundef %54)
  %56 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %55)
  %57 = tail call i32 @get_font_column(i32 noundef %32, i32 noundef 7)
  %58 = tail call ptr @int_to_hex(i32 noundef %57)
  %59 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %58)
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %61 = add nsw i32 %1, 2
  %62 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %63 = tail call i32 @get_font_column(i32 noundef %61, i32 noundef 0)
  %64 = tail call ptr @int_to_hex(i32 noundef %63)
  %65 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %64)
  %66 = tail call i32 @get_font_column(i32 noundef %61, i32 noundef 1)
  %67 = tail call ptr @int_to_hex(i32 noundef %66)
  %68 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %67)
  %69 = tail call i32 @get_font_column(i32 noundef %61, i32 noundef 2)
  %70 = tail call ptr @int_to_hex(i32 noundef %69)
  %71 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %70)
  %72 = tail call i32 @get_font_column(i32 noundef %61, i32 noundef 3)
  %73 = tail call ptr @int_to_hex(i32 noundef %72)
  %74 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %73)
  %75 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %76 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %77 = tail call i32 @get_font_column(i32 noundef %61, i32 noundef 4)
  %78 = tail call ptr @int_to_hex(i32 noundef %77)
  %79 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %78)
  %80 = tail call i32 @get_font_column(i32 noundef %61, i32 noundef 5)
  %81 = tail call ptr @int_to_hex(i32 noundef %80)
  %82 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %81)
  %83 = tail call i32 @get_font_column(i32 noundef %61, i32 noundef 6)
  %84 = tail call ptr @int_to_hex(i32 noundef %83)
  %85 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %84)
  %86 = tail call i32 @get_font_column(i32 noundef %61, i32 noundef 7)
  %87 = tail call ptr @int_to_hex(i32 noundef %86)
  %88 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %87)
  %89 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %90 = add nsw i32 %1, 3
  %91 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %92 = tail call i32 @get_font_column(i32 noundef %90, i32 noundef 0)
  %93 = tail call ptr @int_to_hex(i32 noundef %92)
  %94 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %93)
  %95 = tail call i32 @get_font_column(i32 noundef %90, i32 noundef 1)
  %96 = tail call ptr @int_to_hex(i32 noundef %95)
  %97 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %96)
  %98 = tail call i32 @get_font_column(i32 noundef %90, i32 noundef 2)
  %99 = tail call ptr @int_to_hex(i32 noundef %98)
  %100 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %99)
  %101 = tail call i32 @get_font_column(i32 noundef %90, i32 noundef 3)
  %102 = tail call ptr @int_to_hex(i32 noundef %101)
  %103 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %102)
  %104 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %105 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %106 = tail call i32 @get_font_column(i32 noundef %90, i32 noundef 4)
  %107 = tail call ptr @int_to_hex(i32 noundef %106)
  %108 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %107)
  %109 = tail call i32 @get_font_column(i32 noundef %90, i32 noundef 5)
  %110 = tail call ptr @int_to_hex(i32 noundef %109)
  %111 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %110)
  %112 = tail call i32 @get_font_column(i32 noundef %90, i32 noundef 6)
  %113 = tail call ptr @int_to_hex(i32 noundef %112)
  %114 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %113)
  %115 = tail call i32 @get_font_column(i32 noundef %90, i32 noundef 7)
  %116 = tail call ptr @int_to_hex(i32 noundef %115)
  %117 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %116)
  %118 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  ret void
}

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: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass