; 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_get_char_advance = external hidden unnamed_addr constant [44 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: nounwind uwtable
define dso_local signext i16 @arm_lcd_get_char_advance(ptr noundef nonnull %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i16, align 2
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp ne ptr null, %4
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  br label %8

7:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 516, ptr noundef @__PRETTY_FUNCTION__.arm_lcd_get_char_advance) #3
  unreachable

8:                                                ; preds = %6
  call void @llvm.lifetime.start.p0(i64 2, ptr %3) #4
  %9 = load ptr, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 14), align 8, !tbaa !9
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = call signext i16 @__arm_lcd_get_char_advance(ptr noundef %9, ptr noundef null, ptr noundef %10)
  %12 = sext i16 %11 to i32
  %13 = load i16, ptr getelementptr inbounds (%struct.anon.16, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 10), i32 0, i32 1), align 4, !tbaa !22
  %14 = sext i16 %13 to i32
  %15 = add nsw i32 %12, %14
  %16 = trunc i32 %15 to i16
  store i16 %16, ptr %3, align 2, !tbaa !23
  %17 = load i16, ptr %3, align 2, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 2, ptr %3) #4
  ret i16 %17
}

; Function Attrs: nounwind uwtable
declare hidden signext i16 @__arm_lcd_get_char_advance(ptr noundef, ptr noundef, ptr noundef) #2

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 = { 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 = { noreturn nounwind }
attributes #4 = { 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 = !{!10, !6, i64 160}
!10 = !{!"", !11, i64 0, !11, i64 8, !12, i64 16, !14, i64 20, !6, 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, !6, i64 160}
!11 = !{!"arm_2d_region_t", !7, i64 0, !7, i64 4}
!12 = !{!"arm_2d_location_t", !13, i64 0, !13, i64 2}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 2}
!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", !13, i64 0, !13, i64 2}
!19 = !{!"", !7, i64 0, !13, i64 2, !13, i64 4, !7, i64 6}
!20 = !{!"arm_2d_scratch_mem_t", !7, i64 0, !21, i64 8}
!21 = !{!"long", !7, i64 0}
!22 = !{!10, !13, i64 48}
!23 = !{!13, !13, i64 0}


; 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: nounwind uwtable
define dso_local signext i16 @arm_lcd_get_char_advance(ptr noundef nonnull %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 160), align 8, !tbaa !5
  %3 = tail call signext i16 @__arm_lcd_get_char_advance(ptr noundef %2, ptr noundef null, ptr noundef nonnull %0)
  %4 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 48), align 8, !tbaa !21
  %5 = add i16 %4, %3
  ret i16 %5
}

; Function Attrs: nounwind uwtable
declare hidden signext i16 @__arm_lcd_get_char_advance(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

!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, !13, i64 160}
!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 = !{!6, !11, i64 48}


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