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

; 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 = external hidden unnamed_addr constant [3 x i8], align 1
@font_data = external dso_local global [255 x i32], align 16
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = 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
define dso_local void @print_char(i8 noundef signext %0) #2 {
  %2 = alloca i8, align 1
  %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
  %9 = alloca i32, align 4
  store i8 %0, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %10 = load i8, ptr %2, align 1, !tbaa !5
  %11 = sext i8 %10 to i32
  %12 = sub nsw i32 %11, 32
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [255 x i32], ptr @font_data, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !8
  store i32 %15, ptr %3, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %16 = load i32, ptr %3, align 4, !tbaa !8
  %17 = and i32 %16, 1073741824
  store i32 %17, ptr %4, align 4, !tbaa !8
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !8
  br label %19

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

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

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

24:                                               ; preds = %49, %23
  %25 = load i32, ptr %7, align 4, !tbaa !8
  %26 = icmp slt i32 %25, 5
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %29 = load i32, ptr %3, align 4, !tbaa !8
  %30 = load i32, ptr %7, align 4, !tbaa !8
  %31 = mul nsw i32 6, %30
  %32 = lshr i32 %29, %31
  %33 = and i32 %32, 63
  store i32 %33, ptr %8, align 4, !tbaa !8
  %34 = load i32, ptr %4, align 4, !tbaa !8
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %39

36:                                               ; preds = %28
  %37 = load i32, ptr %8, align 4, !tbaa !8
  %38 = shl i32 %37, 2
  store i32 %38, ptr %8, align 4, !tbaa !8
  br label %39

39:                                               ; preds = %36, %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %40 = load i32, ptr %8, align 4, !tbaa !8
  %41 = load i32, ptr %5, align 4, !tbaa !8
  %42 = shl i32 1, %41
  %43 = and i32 %40, %42
  store i32 %43, ptr %9, align 4, !tbaa !8
  %44 = load i32, ptr %9, align 4, !tbaa !8
  %45 = icmp ne i32 %44, 0
  %46 = zext i1 %45 to i64
  %47 = select i1 %45, i32 42, i32 32
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %47)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %49

49:                                               ; preds = %39
  %50 = load i32, ptr %7, align 4, !tbaa !8
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %7, align 4, !tbaa !8
  br label %24, !llvm.loop !10

52:                                               ; preds = %27
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %54

54:                                               ; preds = %52
  %55 = load i32, ptr %5, align 4, !tbaa !8
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %5, align 4, !tbaa !8
  br label %19, !llvm.loop !12

57:                                               ; preds = %22
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; 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 = external hidden unnamed_addr constant [3 x i8], align 1
@font_data = external dso_local local_unnamed_addr global [255 x i32], align 16
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = 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: nofree nounwind uwtable
define dso_local void @print_char(i8 noundef signext %0) local_unnamed_addr #1 {
.preheader:
  %1 = sext i8 %0 to i64
  %2 = add nsw i64 %1, -32
  %3 = getelementptr inbounds [255 x i32], ptr @font_data, i64 0, i64 %2
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %6 = lshr i32 %4, 24
  %7 = and i32 %6, 63
  %8 = lshr i32 %4, 29
  %9 = and i32 %8, 2
  %spec.select.4 = shl nuw nsw i32 %7, %9
  %10 = lshr i32 %4, 18
  %11 = and i32 %10, 63
  %spec.select.3 = shl nuw nsw i32 %11, %9
  %12 = lshr i32 %4, 12
  %13 = and i32 %12, 63
  %spec.select.2 = shl nuw nsw i32 %13, %9
  %14 = lshr i32 %4, 6
  %15 = and i32 %14, 63
  %spec.select.1 = shl nuw nsw i32 %15, %9
  %16 = and i32 %4, 63
  %spec.select = shl nuw nsw i32 %16, %9
  %17 = and i32 %spec.select, 1
  %.not15 = icmp eq i32 %17, 0
  %18 = select i1 %.not15, i32 32, i32 42
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %18)
  %20 = and i32 %spec.select.1, 1
  %.not15.1 = icmp eq i32 %20, 0
  %21 = select i1 %.not15.1, i32 32, i32 42
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %21)
  %23 = and i32 %spec.select.2, 1
  %.not15.2 = icmp eq i32 %23, 0
  %24 = select i1 %.not15.2, i32 32, i32 42
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %24)
  %26 = and i32 %spec.select.3, 1
  %.not15.3 = icmp eq i32 %26, 0
  %27 = select i1 %.not15.3, i32 32, i32 42
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %27)
  %29 = and i32 %spec.select.4, 1
  %.not15.4 = icmp eq i32 %29, 0
  %30 = select i1 %.not15.4, i32 32, i32 42
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %30)
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %33 = and i32 %spec.select, 2
  %.not15.118 = icmp eq i32 %33, 0
  %34 = select i1 %.not15.118, i32 32, i32 42
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %34)
  %36 = and i32 %spec.select.1, 2
  %.not15.1.1 = icmp eq i32 %36, 0
  %37 = select i1 %.not15.1.1, i32 32, i32 42
  %38 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %37)
  %39 = and i32 %spec.select.2, 2
  %.not15.2.1 = icmp eq i32 %39, 0
  %40 = select i1 %.not15.2.1, i32 32, i32 42
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %40)
  %42 = and i32 %spec.select.3, 2
  %.not15.3.1 = icmp eq i32 %42, 0
  %43 = select i1 %.not15.3.1, i32 32, i32 42
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %43)
  %45 = and i32 %spec.select.4, 2
  %.not15.4.1 = icmp eq i32 %45, 0
  %46 = select i1 %.not15.4.1, i32 32, i32 42
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %46)
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %49 = and i32 %spec.select, 4
  %.not15.219 = icmp eq i32 %49, 0
  %50 = select i1 %.not15.219, i32 32, i32 42
  %51 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %50)
  %52 = and i32 %spec.select.1, 4
  %.not15.1.2 = icmp eq i32 %52, 0
  %53 = select i1 %.not15.1.2, i32 32, i32 42
  %54 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %53)
  %55 = and i32 %spec.select.2, 4
  %.not15.2.2 = icmp eq i32 %55, 0
  %56 = select i1 %.not15.2.2, i32 32, i32 42
  %57 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %56)
  %58 = and i32 %spec.select.3, 4
  %.not15.3.2 = icmp eq i32 %58, 0
  %59 = select i1 %.not15.3.2, i32 32, i32 42
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %59)
  %61 = and i32 %spec.select.4, 4
  %.not15.4.2 = icmp eq i32 %61, 0
  %62 = select i1 %.not15.4.2, i32 32, i32 42
  %63 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %62)
  %64 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %65 = and i32 %spec.select, 8
  %.not15.320 = icmp eq i32 %65, 0
  %66 = select i1 %.not15.320, i32 32, i32 42
  %67 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %66)
  %68 = and i32 %spec.select.1, 8
  %.not15.1.3 = icmp eq i32 %68, 0
  %69 = select i1 %.not15.1.3, i32 32, i32 42
  %70 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %69)
  %71 = and i32 %spec.select.2, 8
  %.not15.2.3 = icmp eq i32 %71, 0
  %72 = select i1 %.not15.2.3, i32 32, i32 42
  %73 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %72)
  %74 = and i32 %spec.select.3, 8
  %.not15.3.3 = icmp eq i32 %74, 0
  %75 = select i1 %.not15.3.3, i32 32, i32 42
  %76 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %75)
  %77 = and i32 %spec.select.4, 8
  %.not15.4.3 = icmp eq i32 %77, 0
  %78 = select i1 %.not15.4.3, i32 32, i32 42
  %79 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %78)
  %80 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %81 = and i32 %spec.select, 16
  %.not15.421 = icmp eq i32 %81, 0
  %82 = select i1 %.not15.421, i32 32, i32 42
  %83 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %82)
  %84 = and i32 %spec.select.1, 16
  %.not15.1.4 = icmp eq i32 %84, 0
  %85 = select i1 %.not15.1.4, i32 32, i32 42
  %86 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %85)
  %87 = and i32 %spec.select.2, 16
  %.not15.2.4 = icmp eq i32 %87, 0
  %88 = select i1 %.not15.2.4, i32 32, i32 42
  %89 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %88)
  %90 = and i32 %spec.select.3, 16
  %.not15.3.4 = icmp eq i32 %90, 0
  %91 = select i1 %.not15.3.4, i32 32, i32 42
  %92 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %91)
  %93 = and i32 %spec.select.4, 16
  %.not15.4.4 = icmp eq i32 %93, 0
  %94 = select i1 %.not15.4.4, i32 32, i32 42
  %95 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %94)
  %96 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %97 = and i32 %spec.select, 32
  %.not15.5 = icmp eq i32 %97, 0
  %98 = select i1 %.not15.5, i32 32, i32 42
  %99 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %98)
  %100 = and i32 %spec.select.1, 32
  %.not15.1.5 = icmp eq i32 %100, 0
  %101 = select i1 %.not15.1.5, i32 32, i32 42
  %102 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %101)
  %103 = and i32 %spec.select.2, 32
  %.not15.2.5 = icmp eq i32 %103, 0
  %104 = select i1 %.not15.2.5, i32 32, i32 42
  %105 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %104)
  %106 = and i32 %spec.select.3, 32
  %.not15.3.5 = icmp eq i32 %106, 0
  %107 = select i1 %.not15.3.5, i32 32, i32 42
  %108 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %107)
  %109 = and i32 %spec.select.4, 32
  %.not15.4.5 = icmp eq i32 %109, 0
  %110 = select i1 %.not15.4.5, i32 32, i32 42
  %111 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %110)
  %112 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %113 = and i32 %spec.select, 64
  %.not15.6 = icmp eq i32 %113, 0
  %114 = select i1 %.not15.6, i32 32, i32 42
  %115 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %114)
  %116 = and i32 %spec.select.1, 64
  %.not15.1.6 = icmp eq i32 %116, 0
  %117 = select i1 %.not15.1.6, i32 32, i32 42
  %118 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %117)
  %119 = and i32 %spec.select.2, 64
  %.not15.2.6 = icmp eq i32 %119, 0
  %120 = select i1 %.not15.2.6, i32 32, i32 42
  %121 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %120)
  %122 = and i32 %spec.select.3, 64
  %.not15.3.6 = icmp eq i32 %122, 0
  %123 = select i1 %.not15.3.6, i32 32, i32 42
  %124 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %123)
  %125 = and i32 %spec.select.4, 64
  %.not15.4.6 = icmp eq i32 %125, 0
  %126 = select i1 %.not15.4.6, i32 32, i32 42
  %127 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %126)
  %128 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %.not15.7 = icmp ult i32 %spec.select, 128
  %129 = select i1 %.not15.7, i32 32, i32 42
  %130 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %129)
  %.not15.1.7 = icmp ult i32 %spec.select.1, 128
  %131 = select i1 %.not15.1.7, i32 32, i32 42
  %132 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %131)
  %.not15.2.7 = icmp ult i32 %spec.select.2, 128
  %133 = select i1 %.not15.2.7, i32 32, i32 42
  %134 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %133)
  %.not15.3.7 = icmp ult i32 %spec.select.3, 128
  %135 = select i1 %.not15.3.7, i32 32, i32 42
  %136 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %135)
  %.not15.4.7 = icmp ult i32 %spec.select.4, 128
  %137 = select i1 %.not15.4.7, i32 32, i32 42
  %138 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %137)
  %139 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %140 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  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 = { nofree 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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass