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

@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@s_tLCDTextControl = external hidden global %struct.anon.13, align 8
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.arm_lcd_putchar_to_buffer = external hidden unnamed_addr constant [57 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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @arm_lcd_putchar_to_buffer(ptr noundef nonnull %0, i8 noundef zeroext %1) #3 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr null, %8
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  br label %12

11:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 1179, ptr noundef @__PRETTY_FUNCTION__.arm_lcd_putchar_to_buffer) #4
  unreachable

12:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #5
  %13 = load i16, 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 !10
  %14 = zext i16 %13 to i64
  %15 = sub i64 64, %14
  %16 = trunc i64 %15 to i16
  store i16 %16, ptr %6, align 2, !tbaa !23
  %17 = load i16, ptr %6, align 2, !tbaa !23
  %18 = sext i16 %17 to i32
  %19 = load i8, ptr %5, align 1, !tbaa !9
  %20 = zext i8 %19 to i32
  %21 = icmp slt i32 %18, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %12
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %43

23:                                               ; preds = %12
  %24 = load i16, 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 !10
  %25 = zext i16 %24 to i32
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds 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 %26
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i8, ptr %5, align 1, !tbaa !9
  %30 = zext i8 %29 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %27, ptr align 1 %28, i64 %30, i1 false)
  %31 = load i8, ptr %5, align 1, !tbaa !9
  %32 = zext i8 %31 to i32
  %33 = load i16, 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 !10
  %34 = zext i16 %33 to i32
  %35 = add nsw i32 %34, %32
  %36 = trunc i32 %35 to i16
  store i16 %36, 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 !10
  %37 = load i8, ptr %5, align 1, !tbaa !9
  %38 = zext i8 %37 to i32
  %39 = 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 !24
  %40 = zext i16 %39 to i32
  %41 = add nsw i32 %40, %38
  %42 = trunc i32 %41 to i16
  store i16 %42, 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 !24
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %43

43:                                               ; preds = %23, %22
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #5
  %44 = load i1, ptr %3, align 1
  ret i1 %44
}

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


; 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 local_unnamed_addr global %struct.anon.13, align 8

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @arm_lcd_putchar_to_buffer(ptr nocapture noundef nonnull readonly %0, i8 noundef zeroext %1) local_unnamed_addr #1 {
  %3 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 62), align 2, !tbaa !5
  %4 = sub i16 64, %3
  %5 = sext i16 %4 to i32
  %6 = zext i8 %1 to i32
  %7 = icmp sge i32 %5, %6
  br i1 %7, label %8, label %17

8:                                                ; preds = %2
  %9 = zext i16 %3 to i64
  %10 = getelementptr inbounds i8, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 66), i64 %9
  %11 = zext i8 %1 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %10, ptr nonnull align 1 %0, i64 %11, i1 false)
  %12 = zext i8 %1 to i16
  %13 = load <2 x i16>, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 62), align 2, !tbaa !21
  %14 = insertelement <2 x i16> poison, i16 %12, i64 0
  %15 = shufflevector <2 x i16> %14, <2 x i16> poison, <2 x i32> zeroinitializer
  %16 = add <2 x i16> %13, %15
  store <2 x i16> %16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 62), align 2, !tbaa !21
  br label %17

17:                                               ; preds = %2, %8
  ret i1 %7
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) 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, !11, i64 62}
!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 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass