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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @digit_to_HEX(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @int_to_hex(i32 noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @gen_chars(i32 noundef %0, i32 noundef %1) #0 {
  %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
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = call signext i8 @digit_to_HEX(i32 noundef %8)
  %10 = sext i8 %9 to i32
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %12 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %12, ptr %5, align 4, !tbaa !5
  br label %13

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

18:                                               ; preds = %13
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %38

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

20:                                               ; preds = %31, %19
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 8
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %34

24:                                               ; preds = %20
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = sub nsw i32 7, %26
  %28 = call i32 @get_font_column(i32 noundef %25, i32 noundef %27)
  %29 = call ptr @int_to_hex(i32 noundef %28)
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %29)
  br label %31

31:                                               ; preds = %24
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %7, align 4, !tbaa !5
  br label %20, !llvm.loop !9

34:                                               ; preds = %23
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %5, align 4, !tbaa !5
  br label %13, !llvm.loop !11

38:                                               ; preds = %18
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 [15 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @digit_to_HEX(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @int_to_hex(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @gen_chars(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = tail call signext i8 @digit_to_HEX(i32 noundef %0)
  %4 = sext i8 %3 to i32
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %4)
  %6 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 7)
  %7 = tail call ptr @int_to_hex(i32 noundef %6)
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %7)
  %9 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 6)
  %10 = tail call ptr @int_to_hex(i32 noundef %9)
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %10)
  %12 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 5)
  %13 = tail call ptr @int_to_hex(i32 noundef %12)
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %13)
  %15 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 4)
  %16 = tail call ptr @int_to_hex(i32 noundef %15)
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %16)
  %18 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 3)
  %19 = tail call ptr @int_to_hex(i32 noundef %18)
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %19)
  %21 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 2)
  %22 = tail call ptr @int_to_hex(i32 noundef %21)
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %22)
  %24 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 1)
  %25 = tail call ptr @int_to_hex(i32 noundef %24)
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %25)
  %27 = tail call i32 @get_font_column(i32 noundef %1, i32 noundef 0)
  %28 = tail call ptr @int_to_hex(i32 noundef %27)
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %28)
  %30 = add nsw i32 %1, 1
  %31 = tail call i32 @get_font_column(i32 noundef %30, i32 noundef 7)
  %32 = tail call ptr @int_to_hex(i32 noundef %31)
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %32)
  %34 = tail call i32 @get_font_column(i32 noundef %30, i32 noundef 6)
  %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 %30, i32 noundef 5)
  %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 %30, i32 noundef 4)
  %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 %30, 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 @get_font_column(i32 noundef %30, i32 noundef 2)
  %47 = tail call ptr @int_to_hex(i32 noundef %46)
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %47)
  %49 = tail call i32 @get_font_column(i32 noundef %30, i32 noundef 1)
  %50 = tail call ptr @int_to_hex(i32 noundef %49)
  %51 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %50)
  %52 = tail call i32 @get_font_column(i32 noundef %30, i32 noundef 0)
  %53 = tail call ptr @int_to_hex(i32 noundef %52)
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %53)
  %55 = add nsw i32 %1, 2
  %56 = tail call i32 @get_font_column(i32 noundef %55, i32 noundef 7)
  %57 = tail call ptr @int_to_hex(i32 noundef %56)
  %58 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %57)
  %59 = tail call i32 @get_font_column(i32 noundef %55, i32 noundef 6)
  %60 = tail call ptr @int_to_hex(i32 noundef %59)
  %61 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %60)
  %62 = tail call i32 @get_font_column(i32 noundef %55, i32 noundef 5)
  %63 = tail call ptr @int_to_hex(i32 noundef %62)
  %64 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %63)
  %65 = tail call i32 @get_font_column(i32 noundef %55, i32 noundef 4)
  %66 = tail call ptr @int_to_hex(i32 noundef %65)
  %67 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %66)
  %68 = tail call i32 @get_font_column(i32 noundef %55, i32 noundef 3)
  %69 = tail call ptr @int_to_hex(i32 noundef %68)
  %70 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %69)
  %71 = tail call i32 @get_font_column(i32 noundef %55, i32 noundef 2)
  %72 = tail call ptr @int_to_hex(i32 noundef %71)
  %73 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %72)
  %74 = tail call i32 @get_font_column(i32 noundef %55, i32 noundef 1)
  %75 = tail call ptr @int_to_hex(i32 noundef %74)
  %76 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %75)
  %77 = tail call i32 @get_font_column(i32 noundef %55, i32 noundef 0)
  %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 = add nsw i32 %1, 3
  %81 = tail call i32 @get_font_column(i32 noundef %80, i32 noundef 7)
  %82 = tail call ptr @int_to_hex(i32 noundef %81)
  %83 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %82)
  %84 = tail call i32 @get_font_column(i32 noundef %80, i32 noundef 6)
  %85 = tail call ptr @int_to_hex(i32 noundef %84)
  %86 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %85)
  %87 = tail call i32 @get_font_column(i32 noundef %80, i32 noundef 5)
  %88 = tail call ptr @int_to_hex(i32 noundef %87)
  %89 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %88)
  %90 = tail call i32 @get_font_column(i32 noundef %80, i32 noundef 4)
  %91 = tail call ptr @int_to_hex(i32 noundef %90)
  %92 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %91)
  %93 = tail call i32 @get_font_column(i32 noundef %80, i32 noundef 3)
  %94 = tail call ptr @int_to_hex(i32 noundef %93)
  %95 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %94)
  %96 = tail call i32 @get_font_column(i32 noundef %80, i32 noundef 2)
  %97 = tail call ptr @int_to_hex(i32 noundef %96)
  %98 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %97)
  %99 = tail call i32 @get_font_column(i32 noundef %80, i32 noundef 1)
  %100 = tail call ptr @int_to_hex(i32 noundef %99)
  %101 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %100)
  %102 = tail call i32 @get_font_column(i32 noundef %80, i32 noundef 0)
  %103 = tail call ptr @int_to_hex(i32 noundef %102)
  %104 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %103)
  %105 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  ret void
}

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

!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,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass