; 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_insert_line_space(i16 noundef signext %0) #2 {
  %2 = alloca i16, align 2
  %3 = alloca %struct.arm_2d_size_t, align 2
  store i16 %0, ptr %2, align 2, !tbaa !5
  %4 = load i16, ptr %2, align 2, !tbaa !5
  %5 = sext i16 %4 to i32
  %6 = load i16, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 2), align 8, !tbaa !9
  %7 = sext i16 %6 to i32
  %8 = add nsw i32 %7, %5
  %9 = trunc i32 %8 to i16
  store i16 %9, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 2), align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %3, ptr align 4 getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 10), i64 4, i1 false), !tbaa.struct !22
  %10 = 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 !23
  %11 = sext i16 %10 to i32
  %12 = getelementptr inbounds %struct.arm_2d_size_t, ptr %3, i32 0, i32 0
  %13 = load i16, ptr %12, align 2, !tbaa !24
  %14 = sext i16 %13 to i32
  %15 = add nsw i32 %14, %11
  %16 = trunc i32 %15 to i16
  store i16 %16, ptr %12, align 2, !tbaa !24
  %17 = 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
  %18 = sext i16 %17 to i32
  %19 = getelementptr inbounds %struct.arm_2d_size_t, ptr %3, i32 0, i32 1
  %20 = load i16, ptr %19, align 2, !tbaa !26
  %21 = sext i16 %20 to i32
  %22 = add nsw i32 %21, %18
  %23 = trunc i32 %22 to i16
  store i16 %23, ptr %19, align 2, !tbaa !26
  call void @__arm_lcd_draw_region_line_wrapping(ptr noundef %3, ptr noundef getelementptr inbounds (%struct.arm_2d_region_t, ptr getelementptr inbounds (%struct.anon.13, ptr @s_tLCDTextControl, i32 0, i32 1), i32 0, i32 1))
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @__arm_lcd_draw_region_line_wrapping(ptr noundef, ptr noundef) #2

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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 16}
!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 = !{i64 0, i64 2, !5, i64 2, i64 2, !5}
!23 = !{!10, !6, i64 48}
!24 = !{!18, !6, i64 0}
!25 = !{!10, !6, i64 50}
!26 = !{!18, !6, i64 2}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 @arm_lcd_text_insert_line_space(i16 noundef signext %0) local_unnamed_addr #1 {
  %2 = alloca %struct.arm_2d_size_t, align 2
  %3 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 16), align 8, !tbaa !5
  %4 = add i16 %3, %0
  store i16 %4, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 16), align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #2
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 44), align 4
  %6 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 48), align 8, !tbaa !21
  %7 = trunc i32 %5 to i16
  %8 = add i16 %6, %7
  store i16 %8, ptr %2, align 2, !tbaa !22
  %9 = load i16, ptr getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 50), align 2, !tbaa !23
  %10 = getelementptr inbounds i8, ptr %2, i64 2
  %11 = lshr i32 %5, 16
  %12 = trunc nuw i32 %11 to i16
  %13 = add i16 %9, %12
  store i16 %13, ptr %10, align 2, !tbaa !24
  call void @__arm_lcd_draw_region_line_wrapping(ptr noundef nonnull %2, ptr noundef nonnull getelementptr inbounds (i8, ptr @s_tLCDTextControl, i64 12))
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @__arm_lcd_draw_region_line_wrapping(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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, !11, i64 16}
!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}
!22 = !{!17, !11, i64 0}
!23 = !{!6, !11, i64 50}
!24 = !{!17, !11, i64 2}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SCCPPass,SROAPass