; 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: 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) #1

; Function Attrs: nounwind uwtable
define dso_local void @arm_lcd_text_location(i8 noundef zeroext %0, i8 noundef zeroext %1) #2 {
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  %5 = alloca %struct.arm_2d_size_t, align 2
  store i8 %0, ptr %3, align 1, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %5, ptr align 4 getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 10), i64 4, i1 false), !tbaa.struct !8
  %6 = 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 !11
  %7 = sext i16 %6 to i32
  %8 = getelementptr inbounds %struct.arm_2d_size_t, ptr %5, i32 0, i32 0
  %9 = load i16, ptr %8, align 2, !tbaa !24
  %10 = sext i16 %9 to i32
  %11 = add nsw i32 %10, %7
  %12 = trunc i32 %11 to i16
  store i16 %12, ptr %8, align 2, !tbaa !24
  %13 = load i16, ptr getelementptr inbounds (%struct.arm_2d_size_t, ptr getelementptr inbounds (%struct.anon.16, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 10), i32 0, i32 1), i32 0, i32 1), align 2, !tbaa !25
  %14 = sext i16 %13 to i32
  %15 = getelementptr inbounds %struct.arm_2d_size_t, ptr %5, i32 0, i32 1
  %16 = load i16, ptr %15, align 2, !tbaa !26
  %17 = sext i16 %16 to i32
  %18 = add nsw i32 %17, %14
  %19 = trunc i32 %18 to i16
  store i16 %19, ptr %15, align 2, !tbaa !26
  %20 = getelementptr inbounds %struct.arm_2d_size_t, ptr %5, i32 0, i32 0
  %21 = load i16, ptr %20, align 2, !tbaa !24
  %22 = sext i16 %21 to i32
  %23 = load i8, ptr %4, align 1, !tbaa !5
  %24 = zext i8 %23 to i32
  %25 = mul nsw i32 %22, %24
  %26 = load i16, ptr getelementptr inbounds (%struct.arm_2d_region_t, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 1), i32 0, i32 1), align 4, !tbaa !5
  %27 = sext i16 %26 to i32
  %28 = srem i32 %25, %27
  %29 = trunc i32 %28 to i16
  store i16 %29, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 2), align 8, !tbaa !27
  %30 = getelementptr inbounds %struct.arm_2d_size_t, ptr %5, i32 0, i32 1
  %31 = load i16, ptr %30, align 2, !tbaa !26
  %32 = sext i16 %31 to i32
  %33 = load i8, ptr %3, align 1, !tbaa !5
  %34 = zext i8 %33 to i32
  %35 = getelementptr inbounds %struct.arm_2d_size_t, ptr %5, i32 0, i32 0
  %36 = load i16, ptr %35, align 2, !tbaa !24
  %37 = sext i16 %36 to i32
  %38 = load i8, ptr %4, align 1, !tbaa !5
  %39 = zext i8 %38 to i32
  %40 = mul nsw i32 %37, %39
  %41 = load i16, ptr getelementptr inbounds (%struct.arm_2d_region_t, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 1), i32 0, i32 1), align 4, !tbaa !5
  %42 = sext i16 %41 to i32
  %43 = sdiv i32 %40, %42
  %44 = add nsw i32 %34, %43
  %45 = mul nsw i32 %32, %44
  %46 = trunc i32 %45 to i16
  store i16 %46, ptr getelementptr inbounds (%struct.arm_2d_location_t, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 2), i32 0, i32 1), align 2, !tbaa !28
  %47 = load i16, ptr getelementptr inbounds (%struct.arm_2d_size_t, ptr getelementptr inbounds (%struct.arm_2d_region_t, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 1), i32 0, i32 1), i32 0, i32 1), align 2, !tbaa !5
  %48 = sext i16 %47 to i32
  %49 = load i16, ptr getelementptr inbounds (%struct.arm_2d_location_t, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 2), i32 0, i32 1), align 2, !tbaa !28
  %50 = sext i16 %49 to i32
  %51 = srem i32 %50, %48
  %52 = trunc i32 %51 to i16
  store i16 %52, ptr getelementptr inbounds (%struct.arm_2d_location_t, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 2), i32 0, i32 1), align 2, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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


; 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 nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @arm_lcd_text_location(i8 noundef zeroext %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %.sroa.0.0.copyload = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 44), align 4, !tbaa !5
  %.sroa.7.0.copyload = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 46), align 2, !tbaa !5
  %3 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 48), align 8, !tbaa !9
  %4 = add i16 %3, %.sroa.0.0.copyload
  %5 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 50), align 2, !tbaa !22
  %6 = add i16 %5, %.sroa.7.0.copyload
  %7 = sext i16 %4 to i32
  %8 = zext i8 %1 to i32
  %9 = mul nsw i32 %7, %8
  %10 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 12), align 4, !tbaa !23
  %11 = sext i16 %10 to i32
  %12 = srem i32 %9, %11
  %13 = trunc nsw i32 %12 to i16
  store i16 %13, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 16), align 8, !tbaa !24
  %14 = zext i8 %0 to i32
  %15 = sdiv i32 %9, %11
  %16 = add nsw i32 %15, %14
  %17 = trunc i32 %16 to i16
  %18 = mul i16 %6, %17
  %19 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 14), align 2, !tbaa !23
  %20 = sext i16 %19 to i32
  %21 = sext i16 %18 to i32
  %22 = srem i32 %21, %20
  %23 = trunc nsw i32 %22 to i16
  store i16 %23, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 18), align 2, !tbaa !25
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, 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, !6, i64 0}
!6 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 48}
!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 = !{!10, !6, i64 50}
!23 = !{!7, !7, i64 0}
!24 = !{!10, !6, i64 16}
!25 = !{!10, !6, i64 18}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass