; LLVM IR from ARM-software/Arm-2D :: Helper/Source (arm_2d_helper_font)

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

%struct.anon.13 = type { %struct.arm_2d_region_t, %struct.arm_2d_region_t, %struct.arm_2d_location_t, %struct.anon.14, ptr, i32, i32, i8, i8, %struct.anon.15, %struct.anon.16, %struct.anon.17, %struct.arm_2d_scratch_mem_t, %struct.arm_2d_region_t, ptr }
%struct.arm_2d_location_t = type { i16, i16 }
%struct.anon.14 = type { i16, i16 }
%struct.anon.15 = type { i8, i8 }
%struct.anon.16 = type { %struct.arm_2d_size_t, %struct.arm_2d_size_t, %struct.arm_2d_region_t }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.anon.17 = type { %union.anon.18, i16, i16, [65 x i8] }
%union.anon.18 = type { i16 }
%struct.arm_2d_scratch_mem_t = type { %union.anon.19, i64 }
%union.anon.19 = type { %union.anon.20 }
%union.anon.20 = type { %struct.anon.21 }
%struct.anon.21 = type { i32 }
%struct.arm_2d_region_t = type { %union.anon.10, %union.anon.11 }
%union.anon.10 = type { %struct.arm_2d_location_t }
%union.anon.11 = type { %struct.arm_2d_size_t }

@s_tLCDTextControl = external hidden global %struct.anon.13, align 8

; 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

; Function Attrs: nounwind uwtable
declare dso_local void @arm_lcd_puts(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @arm_lcd_printf_buffer(i16 noundef signext %0) #1 {
  %2 = alloca i16, align 2
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  store i16 %0, ptr %2, align 2, !tbaa !5
  %12 = load i16, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  %13 = zext i16 %12 to i32
  %14 = icmp eq i32 0, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %1
  br label %180

16:                                               ; preds = %1
  br label %17

17:                                               ; preds = %16
  %18 = load i16, ptr %2, align 2, !tbaa !5
  %19 = sext i16 %18 to i32
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %21, label %66

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 3), ptr %5, align 8, !tbaa !23
  br label %22

22:                                               ; preds = %54, %21
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  %23 = load ptr, ptr %5, align 8, !tbaa !23
  %24 = call signext i8 @arm_2d_helper_get_utf8_byte_length(ptr noundef %23)
  store i8 %24, ptr %6, align 1, !tbaa !24
  %25 = load i8, ptr %6, align 1, !tbaa !24
  %26 = sext i8 %25 to i32
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %22
  store i32 4, ptr %7, align 4
  br label %51

29:                                               ; preds = %22
  %30 = load i8, ptr %6, align 1, !tbaa !24
  %31 = sext i8 %30 to i32
  %32 = load ptr, ptr %5, align 8, !tbaa !23
  %33 = sext i32 %31 to i64
  %34 = getelementptr inbounds i8, ptr %32, i64 %33
  store ptr %34, ptr %5, align 8, !tbaa !23
  %35 = load i8, ptr %6, align 1, !tbaa !24
  %36 = sext i8 %35 to i32
  %37 = load i32, ptr %3, align 4, !tbaa !22
  %38 = add nsw i32 %37, %36
  store i32 %38, ptr %3, align 4, !tbaa !22
  %39 = load i32, ptr %4, align 4, !tbaa !22
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %4, align 4, !tbaa !22
  %41 = load i32, ptr %3, align 4, !tbaa !22
  %42 = load i16, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  %43 = zext i16 %42 to i32
  %44 = icmp sge i32 %41, %43
  br i1 %44, label %49, label %45

45:                                               ; preds = %29
  %46 = load i32, ptr %3, align 4, !tbaa !22
  %47 = sext i32 %46 to i64
  %48 = icmp uge i64 %47, 65
  br i1 %48, label %49, label %50

49:                                               ; preds = %45, %29
  store i32 4, ptr %7, align 4
  br label %51

50:                                               ; preds = %45
  store i32 0, ptr %7, align 4
  br label %51

51:                                               ; preds = %50, %49, %28
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  %52 = load i32, ptr %7, align 4
  switch i32 %52, label %181 [
    i32 0, label %53
    i32 4, label %55
  ]

53:                                               ; preds = %51
  br label %54

54:                                               ; preds = %53
  br i1 true, label %22, label %55

55:                                               ; preds = %54, %51
  %56 = load i32, ptr %4, align 4, !tbaa !22
  %57 = load i16, ptr %2, align 2, !tbaa !5
  %58 = sext i16 %57 to i32
  %59 = add nsw i32 %56, %58
  %60 = trunc i32 %59 to i16
  store i16 %60, ptr %2, align 2, !tbaa !5
  %61 = load i16, ptr %2, align 2, !tbaa !5
  %62 = sext i16 %61 to i32
  %63 = icmp slt i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %55
  store i16 0, ptr %2, align 2, !tbaa !5
  br label %65

65:                                               ; preds = %64, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %66

66:                                               ; preds = %65, %17
  %67 = load i16, ptr %2, align 2, !tbaa !5
  %68 = sext i16 %67 to i32
  %69 = icmp sgt i32 %68, 0
  br i1 %69, label %70, label %108

70:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 3), ptr %9, align 8, !tbaa !23
  br label %71

71:                                               ; preds = %101, %70
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  %72 = load ptr, ptr %9, align 8, !tbaa !23
  %73 = call signext i8 @arm_2d_helper_get_utf8_byte_length(ptr noundef %72)
  store i8 %73, ptr %10, align 1, !tbaa !24
  %74 = load i8, ptr %10, align 1, !tbaa !24
  %75 = sext i8 %74 to i32
  %76 = icmp slt i32 %75, 0
  br i1 %76, label %77, label %78

77:                                               ; preds = %71
  store i32 6, ptr %7, align 4
  br label %98

78:                                               ; preds = %71
  %79 = load i8, ptr %10, align 1, !tbaa !24
  %80 = sext i8 %79 to i32
  %81 = load ptr, ptr %9, align 8, !tbaa !23
  %82 = sext i32 %80 to i64
  %83 = getelementptr inbounds i8, ptr %81, i64 %82
  store ptr %83, ptr %9, align 8, !tbaa !23
  %84 = load i8, ptr %10, align 1, !tbaa !24
  %85 = sext i8 %84 to i32
  %86 = load i32, ptr %8, align 4, !tbaa !22
  %87 = add nsw i32 %86, %85
  store i32 %87, ptr %8, align 4, !tbaa !22
  %88 = load i32, ptr %8, align 4, !tbaa !22
  %89 = load i16, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  %90 = zext i16 %89 to i32
  %91 = icmp sge i32 %88, %90
  br i1 %91, label %96, label %92

92:                                               ; preds = %78
  %93 = load i32, ptr %8, align 4, !tbaa !22
  %94 = sext i32 %93 to i64
  %95 = icmp uge i64 %94, 65
  br i1 %95, label %96, label %97

96:                                               ; preds = %92, %78
  store i32 0, ptr %8, align 4, !tbaa !22
  store i32 6, ptr %7, align 4
  br label %98

97:                                               ; preds = %92
  store i32 0, ptr %7, align 4
  br label %98

98:                                               ; preds = %97, %96, %77
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  %99 = load i32, ptr %7, align 4
  switch i32 %99, label %181 [
    i32 0, label %100
    i32 6, label %105
  ]

100:                                              ; preds = %98
  br label %101

101:                                              ; preds = %100
  %102 = load i16, ptr %2, align 2, !tbaa !5
  %103 = add i16 %102, -1
  store i16 %103, ptr %2, align 2, !tbaa !5
  %104 = icmp ne i16 %103, 0
  br i1 %104, label %71, label %105, !llvm.loop !25

105:                                              ; preds = %101, %98
  %106 = load i32, ptr %8, align 4, !tbaa !22
  %107 = trunc i32 %106 to i16
  store i16 %107, ptr %2, align 2, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %108

108:                                              ; preds = %105, %66
  br label %109

109:                                              ; preds = %108
  %110 = load i16, ptr %2, align 2, !tbaa !5
  %111 = sext i16 %110 to i32
  %112 = icmp eq i32 0, %111
  br i1 %112, label %119, label %113

113:                                              ; preds = %109
  %114 = load i16, ptr %2, align 2, !tbaa !5
  %115 = sext i16 %114 to i32
  %116 = load i16, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  %117 = zext i16 %116 to i32
  %118 = icmp sge i32 %115, %117
  br i1 %118, label %119, label %121

119:                                              ; preds = %113, %109
  %120 = load i16, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  store i16 %120, ptr %2, align 2, !tbaa !5
  br label %121

121:                                              ; preds = %119, %113
  %122 = load i16, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  %123 = zext i16 %122 to i32
  %124 = load i16, ptr %2, align 2, !tbaa !5
  %125 = sext i16 %124 to i32
  %126 = icmp slt i32 %123, %125
  br i1 %126, label %127, label %130

127:                                              ; preds = %121
  %128 = load i16, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  %129 = zext i16 %128 to i32
  br label %133

130:                                              ; preds = %121
  %131 = load i16, ptr %2, align 2, !tbaa !5
  %132 = sext i16 %131 to i32
  br label %133

133:                                              ; preds = %130, %127
  %134 = phi i32 [ %129, %127 ], [ %132, %130 ]
  %135 = trunc i32 %134 to i16
  store i16 %135, ptr %2, align 2, !tbaa !5
  br label %136

136:                                              ; preds = %133
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  %137 = load i16, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), align 4, !tbaa !24
  %138 = zext i16 %137 to i32
  %139 = load i16, ptr %2, align 2, !tbaa !5
  %140 = sext i16 %139 to i32
  %141 = add nsw i32 %138, %140
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [65 x i8], ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 3), i64 0, i64 %142
  %144 = load i8, ptr %143, align 1, !tbaa !24
  store i8 %144, ptr %11, align 1, !tbaa !24
  %145 = load i16, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), align 4, !tbaa !24
  %146 = zext i16 %145 to i32
  %147 = load i16, ptr %2, align 2, !tbaa !5
  %148 = sext i16 %147 to i32
  %149 = add nsw i32 %146, %148
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [65 x i8], ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 3), i64 0, i64 %150
  store i8 0, ptr %151, align 1, !tbaa !24
  %152 = load i16, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), align 4, !tbaa !24
  %153 = zext i16 %152 to i64
  %154 = getelementptr inbounds [65 x i8], ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 3), i64 0, i64 %153
  call void @arm_lcd_puts(ptr noundef %154)
  %155 = load i8, ptr %11, align 1, !tbaa !24
  %156 = load i16, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), align 4, !tbaa !24
  %157 = zext i16 %156 to i32
  %158 = load i16, ptr %2, align 2, !tbaa !5
  %159 = sext i16 %158 to i32
  %160 = add nsw i32 %157, %159
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [65 x i8], ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 3), i64 0, i64 %161
  store i8 %155, ptr %162, align 1, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  br label %163

163:                                              ; preds = %136
  %164 = load i16, ptr %2, align 2, !tbaa !5
  %165 = sext i16 %164 to i32
  %166 = load i16, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), align 4, !tbaa !24
  %167 = zext i16 %166 to i32
  %168 = add nsw i32 %167, %165
  %169 = trunc i32 %168 to i16
  store i16 %169, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), align 4, !tbaa !24
  %170 = load i16, ptr %2, align 2, !tbaa !5
  %171 = sext i16 %170 to i32
  %172 = load i16, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  %173 = zext i16 %172 to i32
  %174 = sub nsw i32 %173, %171
  %175 = trunc i32 %174 to i16
  store i16 %175, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  %176 = load i16, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 2), align 4, !tbaa !9
  %177 = zext i16 %176 to i32
  %178 = icmp eq i32 0, %177
  br i1 %178, label %179, label %180

179:                                              ; preds = %163
  store i16 0, ptr getelementptr inbounds (%struct.anon.17, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), i32 0, i32 1), align 2, !tbaa !27
  store i16 0, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 11), align 4, !tbaa !24
  br label %180

180:                                              ; preds = %179, %163, %15
  ret void

181:                                              ; preds = %98, %51
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden signext i8 @arm_2d_helper_get_utf8_byte_length(ptr noundef nonnull) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { inlinehint 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 64}
!10 = !{!"", !11, i64 0, !11, i64 8, !12, i64 16, !13, i64 20, !14, i64 24, !15, i64 32, !15, i64 36, !7, i64 40, !7, i64 41, !16, i64 42, !17, i64 44, !19, i64 60, !20, i64 136, !11, i64 152, !14, i64 160}
!11 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!12 = !{!"arm_2d_location_t", !6, i64 0, !6, i64 2}
!13 = !{!"", !6, i64 0, !6, i64 2}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"", !7, i64 0, !7, i64 1}
!17 = !{!"", !18, i64 0, !18, i64 4, !11, i64 8}
!18 = !{!"arm_2d_size_t", !6, i64 0, !6, i64 2}
!19 = !{!"", !7, i64 0, !6, i64 2, !6, i64 4, !7, i64 6}
!20 = !{!"arm_2d_scratch_mem_t", !7, i64 0, !21, i64 8}
!21 = !{!"long", !7, i64 0}
!22 = !{!15, !15, i64 0}
!23 = !{!14, !14, i64 0}
!24 = !{!7, !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!10, !6, i64 62}


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

%struct.anon.13 = type { %struct.arm_2d_region_t, %struct.arm_2d_region_t, %struct.arm_2d_location_t, %struct.anon.14, ptr, i32, i32, i8, i8, %struct.anon.15, %struct.anon.16, %struct.anon.17, %struct.arm_2d_scratch_mem_t, %struct.arm_2d_region_t, ptr }
%struct.arm_2d_location_t = type { i16, i16 }
%struct.anon.14 = type { i16, i16 }
%struct.anon.15 = type { i8, i8 }
%struct.anon.16 = type { %struct.arm_2d_size_t, %struct.arm_2d_size_t, %struct.arm_2d_region_t }
%struct.arm_2d_size_t = type { i16, i16 }
%struct.anon.17 = type { %union.anon.18, i16, i16, [65 x i8] }
%union.anon.18 = type { i16 }
%struct.arm_2d_scratch_mem_t = type { %union.anon.19, i64 }
%union.anon.19 = type { %union.anon.20 }
%union.anon.20 = type { %struct.anon.21 }
%struct.anon.21 = type { i32 }
%struct.arm_2d_region_t = type { %union.anon.10, %union.anon.11 }
%union.anon.10 = type { %struct.arm_2d_location_t }
%union.anon.11 = type { %struct.arm_2d_size_t }

@s_tLCDTextControl = external hidden global %struct.anon.13, align 8

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

; Function Attrs: nounwind uwtable
define dso_local void @arm_lcd_printf_buffer(i16 noundef signext %0) local_unnamed_addr #0 {
  %2 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 64), align 8, !tbaa !5
  %3 = icmp eq i16 %2, 0
  br i1 %3, label %61, label %4

4:                                                ; preds = %1
  %5 = icmp slt i16 %0, 0
  br i1 %5, label %.preheader83, label %19

.preheader83:                                     ; preds = %4, %8
  %.050 = phi ptr [ %11, %8 ], [ getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 66), %4 ]
  %.048 = phi i16 [ %13, %8 ], [ 0, %4 ]
  %.040 = phi i32 [ %12, %8 ], [ 0, %4 ]
  %6 = tail call signext i8 @arm_2d_helper_get_utf8_byte_length(ptr noundef %.050)
  %7 = icmp slt i8 %6, 0
  br i1 %7, label %select.unfold, label %8

8:                                                ; preds = %.preheader83
  %9 = zext nneg i8 %6 to i32
  %10 = zext nneg i8 %6 to i64
  %11 = getelementptr inbounds i8, ptr %.050, i64 %10
  %12 = add nuw nsw i32 %.040, %9
  %13 = add i16 %.048, 1
  %14 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 64), align 8, !tbaa !5
  %15 = zext i16 %14 to i32
  %16 = icmp uge i32 %12, %15
  %17 = icmp ugt i32 %12, 64
  %or.cond = or i1 %17, %16
  br i1 %or.cond, label %select.unfold, label %.preheader83

select.unfold:                                    ; preds = %8, %.preheader83
  %.149.ph = phi i16 [ %.048, %.preheader83 ], [ %13, %8 ]
  %18 = add i16 %.149.ph, %0
  %spec.store.select = tail call i16 @llvm.smax.i16(i16 %18, i16 0)
  br label %19

19:                                               ; preds = %select.unfold, %4
  %.0 = phi i16 [ %spec.store.select, %select.unfold ], [ %0, %4 ]
  %.not = icmp eq i16 %.0, 0
  br i1 %.not, label %..thread80_crit_edge, label %.preheader

..thread80_crit_edge:                             ; preds = %19
  %.pre = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 64), align 8
  br label %.thread80

.preheader:                                       ; preds = %19, %22
  %.044 = phi i32 [ %.62, %22 ], [ 0, %19 ]
  %.042 = phi ptr [ %25, %22 ], [ getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 66), %19 ]
  %.1 = phi i16 [ %30, %22 ], [ %.0, %19 ]
  %20 = tail call signext i8 @arm_2d_helper_get_utf8_byte_length(ptr noundef %.042)
  %21 = icmp slt i8 %20, 0
  %.pre84.pre = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 64), align 8
  br i1 %21, label %.thread72, label %22

22:                                               ; preds = %.preheader
  %23 = zext nneg i8 %20 to i32
  %24 = zext nneg i8 %20 to i64
  %25 = getelementptr inbounds i8, ptr %.042, i64 %24
  %26 = add nsw i32 %.044, %23
  %27 = zext i16 %.pre84.pre to i32
  %28 = icmp sge i32 %26, %27
  %29 = icmp ugt i32 %26, 64
  %or.cond5 = or i1 %29, %28
  %.62 = select i1 %or.cond5, i32 0, i32 %26
  %30 = add nsw i16 %.1, -1
  %.not59 = icmp eq i16 %30, 0
  %or.cond65 = select i1 %or.cond5, i1 true, i1 %.not59
  br i1 %or.cond65, label %.thread72, label %.preheader, !llvm.loop !21

.thread72:                                        ; preds = %.preheader, %22
  %.14579 = phi i32 [ %.62, %22 ], [ %.044, %.preheader ]
  %31 = trunc i32 %.14579 to i16
  %32 = icmp eq i16 %31, 0
  br i1 %32, label %.thread80, label %33

33:                                               ; preds = %.thread72
  %sext82 = shl i32 %.14579, 16
  %34 = ashr exact i32 %sext82, 16
  %35 = zext i16 %.pre84.pre to i32
  %.not60 = icmp slt i32 %34, %35
  br i1 %.not60, label %37, label %.thread80

.thread80:                                        ; preds = %..thread80_crit_edge, %33, %.thread72
  %36 = phi i16 [ %.pre, %..thread80_crit_edge ], [ %.pre84.pre, %33 ], [ %.pre84.pre, %.thread72 ]
  %.pre85 = zext i16 %36 to i32
  br label %37

37:                                               ; preds = %.thread80, %33
  %.pre-phi = phi i32 [ %.pre85, %.thread80 ], [ %35, %33 ]
  %.3 = phi i16 [ %36, %.thread80 ], [ %31, %33 ]
  %38 = sext i16 %.3 to i32
  %39 = tail call i32 @llvm.smin.i32(i32 %.pre-phi, i32 %38)
  %40 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 60), align 4, !tbaa !23
  %41 = zext i16 %40 to i32
  %42 = add nsw i32 %39, %41
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [65 x i8], ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 66), i64 0, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !23
  store i8 0, ptr %44, align 1, !tbaa !23
  %46 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 60), align 4, !tbaa !23
  %47 = zext i16 %46 to i64
  %48 = getelementptr inbounds [65 x i8], ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 66), i64 0, i64 %47
  tail call void @arm_lcd_puts(ptr noundef nonnull %48)
  %49 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 60), align 4, !tbaa !23
  %50 = zext i16 %49 to i32
  %51 = add nsw i32 %39, %50
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [65 x i8], ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 66), i64 0, i64 %52
  store i8 %45, ptr %53, align 1, !tbaa !23
  %54 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 60), align 4, !tbaa !23
  %55 = trunc nsw i32 %39 to i16
  %56 = add i16 %54, %55
  store i16 %56, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 60), align 4, !tbaa !23
  %57 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 64), align 8, !tbaa !5
  %58 = sub i16 %57, %55
  store i16 %58, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 64), align 8, !tbaa !5
  %59 = icmp eq i16 %57, %55
  br i1 %59, label %60, label %61

60:                                               ; preds = %37
  store i16 0, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 62), align 2, !tbaa !24
  store i16 0, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 60), align 4, !tbaa !23
  br label %61

61:                                               ; preds = %1, %60, %37
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden signext i8 @arm_2d_helper_get_utf8_byte_length(ptr noundef nonnull) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i16 @llvm.smax.i16(i16, i16) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #2

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 = { inlinehint 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !11, i64 64}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !12, i64 20, !13, i64 24, !14, i64 32, !14, i64 36, !8, i64 40, !8, i64 41, !15, i64 42, !16, i64 44, !18, i64 60, !19, i64 136, !7, i64 152, !13, i64 160}
!7 = !{!"arm_2d_region_t", !8, i64 0, !8, i64 4}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"arm_2d_location_t", !11, i64 0, !11, i64 2}
!11 = !{!"short", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 2}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!"", !8, i64 0, !8, i64 1}
!16 = !{!"", !17, i64 0, !17, i64 4, !7, i64 8}
!17 = !{!"arm_2d_size_t", !11, i64 0, !11, i64 2}
!18 = !{!"", !8, i64 0, !11, i64 2, !11, i64 4, !8, i64 6}
!19 = !{!"arm_2d_scratch_mem_t", !8, i64 0, !20, i64 8}
!20 = !{!"long", !8, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!8, !8, i64 0}
!24 = !{!6, !11, i64 62}


; Effective O3 passes: AggressiveInstCombinePass,BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass