; 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.arm_2d_char_descriptor_t = type { %struct.arm_2d_tile_t, i16, i16, i16, i8, i8 }
%struct.arm_2d_tile_t = type { %union.anon, %union.anon.9, %union.anon.12 }
%union.anon = type { %struct.anon }
%struct.anon = type { i8, %union.arm_2d_color_info_t, %union.anon.2 }
%union.arm_2d_color_info_t = type { %struct.anon.0 }
%struct.anon.0 = type { i8 }
%union.anon.2 = type { i16 }
%union.anon.9 = type { %struct.arm_2d_region_t }
%struct.arm_2d_region_t = type { %union.anon.10, %union.anon.11 }
%union.anon.10 = type { %struct.arm_2d_location_t }
%struct.arm_2d_location_t = type { i16, i16 }
%union.anon.11 = type { %struct.arm_2d_size_t }
%struct.arm_2d_size_t = type { i16, i16 }
%union.anon.12 = type { ptr }
%struct.arm_2d_font_t = type { %struct.arm_2d_tile_t, %struct.arm_2d_size_t, i32, ptr, ptr }
%struct.arm_2d_a1_font_t = type { %union.anon.24, i32 }
%union.anon.24 = type { %struct.arm_2d_font_t }

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.ARM_2D_A1_FONT_GET_CHAR_DESCRIPTOR_HANDLER = external hidden unnamed_addr constant [131 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

10:                                               ; preds = %3
  br label %12

11:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 453, ptr noundef @__PRETTY_FUNCTION__.ARM_2D_A1_FONT_GET_CHAR_DESCRIPTOR_HANDLER) #5
  unreachable

12:                                               ; preds = %10
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp ne ptr null, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  br label %17

16:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 454, ptr noundef @__PRETTY_FUNCTION__.ARM_2D_A1_FONT_GET_CHAR_DESCRIPTOR_HANDLER) #5
  unreachable

17:                                               ; preds = %15
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp ne ptr null, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  br label %22

21:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 455, ptr noundef @__PRETTY_FUNCTION__.ARM_2D_A1_FONT_GET_CHAR_DESCRIPTOR_HANDLER) #5
  unreachable

22:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %23, ptr %7, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %24, i8 0, i64 32, i1 false)
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.arm_2d_char_descriptor_t, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %struct.arm_2d_region_t, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.arm_2d_font_t, ptr %29, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 8 %30, i64 4, i1 false), !tbaa.struct !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.arm_2d_font_t, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.arm_2d_char_descriptor_t, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %34, i32 0, i32 2
  store ptr %32, ptr %35, align 8, !tbaa !12
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.arm_2d_char_descriptor_t, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %37, i32 0, i32 0
  %39 = load i8, ptr %38, align 8
  %40 = and i8 %39, -5
  %41 = or i8 %40, 4
  store i8 %41, ptr %38, align 8
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.arm_2d_font_t, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %struct.arm_2d_size_t, ptr %43, i32 0, i32 0
  %45 = load i16, ptr %44, align 8, !tbaa !13
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.arm_2d_char_descriptor_t, ptr %46, i32 0, i32 1
  store i16 %45, ptr %47, align 8, !tbaa !18
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.arm_2d_char_descriptor_t, ptr %48, i32 0, i32 2
  store i16 0, ptr %49, align 2, !tbaa !20
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.arm_2d_font_t, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %struct.arm_2d_size_t, ptr %51, i32 0, i32 1
  %53 = load i16, ptr %52, align 2, !tbaa !21
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.arm_2d_char_descriptor_t, ptr %54, i32 0, i32 3
  store i16 %53, ptr %55, align 4, !tbaa !22
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = load i8, ptr %56, align 1, !tbaa !12
  %58 = zext i8 %57 to i32
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.arm_2d_a1_font_t, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 8, !tbaa !23
  %62 = trunc i32 %61 to i16
  %63 = sext i16 %62 to i32
  %64 = sub nsw i32 %58, %63
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.arm_2d_font_t, ptr %65, i32 0, i32 1
  %67 = getelementptr inbounds %struct.arm_2d_size_t, ptr %66, i32 0, i32 1
  %68 = load i16, ptr %67, align 2, !tbaa !21
  %69 = sext i16 %68 to i32
  %70 = mul nsw i32 %64, %69
  %71 = trunc i32 %70 to i16
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.arm_2d_char_descriptor_t, ptr %72, i32 0, i32 0
  %74 = getelementptr inbounds %struct.arm_2d_tile_t, ptr %73, i32 0, i32 1
  %75 = getelementptr inbounds %struct.arm_2d_region_t, ptr %74, i32 0, i32 0
  %76 = getelementptr inbounds %struct.arm_2d_location_t, ptr %75, i32 0, i32 1
  store i16 %71, ptr %76, align 2, !tbaa !12
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.arm_2d_char_descriptor_t, ptr %77, i32 0, i32 4
  store i8 1, ptr %78, align 2, !tbaa !25
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret ptr %79
}

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { noreturn nounwind }
attributes #6 = { 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 = !{i64 0, i64 2, !10, i64 2, i64 2, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !11, i64 24}
!14 = !{!"arm_2d_font_t", !15, i64 0, !16, i64 24, !17, i64 28, !6, i64 32, !6, i64 40}
!15 = !{!"arm_2d_tile_t", !7, i64 0, !7, i64 4, !7, i64 16}
!16 = !{!"arm_2d_size_t", !11, i64 0, !11, i64 2}
!17 = !{!"int", !7, i64 0}
!18 = !{!19, !11, i64 24}
!19 = !{!"", !15, i64 0, !11, i64 24, !11, i64 26, !11, i64 28, !7, i64 30}
!20 = !{!19, !11, i64 26}
!21 = !{!14, !11, i64 26}
!22 = !{!19, !11, i64 28}
!23 = !{!24, !17, i64 48}
!24 = !{!"arm_2d_a1_font_t", !7, i64 0, !17, i64 48}
!25 = !{!19, !7, i64 30}


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

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.ARM_2D_A1_FONT_GET_CHAR_DESCRIPTOR_HANDLER = external hidden unnamed_addr constant [131 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @ARM_2D_A1_FONT_GET_CHAR_DESCRIPTOR_HANDLER(ptr noundef %0, ptr noundef returned writeonly %1, ptr noundef readonly %2) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 453, ptr noundef nonnull @__PRETTY_FUNCTION__.ARM_2D_A1_FONT_GET_CHAR_DESCRIPTOR_HANDLER) #3
  unreachable

5:                                                ; preds = %3
  %.not23 = icmp eq ptr %1, null
  br i1 %.not23, label %6, label %7

6:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 454, ptr noundef nonnull @__PRETTY_FUNCTION__.ARM_2D_A1_FONT_GET_CHAR_DESCRIPTOR_HANDLER) #3
  unreachable

7:                                                ; preds = %5
  %.not24 = icmp eq ptr %2, null
  br i1 %.not24, label %8, label %9

8:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 455, ptr noundef nonnull @__PRETTY_FUNCTION__.ARM_2D_A1_FONT_GET_CHAR_DESCRIPTOR_HANDLER) #3
  unreachable

9:                                                ; preds = %7
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %1, i8 0, i64 32, i1 false)
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load i32, ptr %11, align 8
  store i32 %12, ptr %10, align 4
  %13 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %0, ptr %13, align 8, !tbaa !5
  store i8 4, ptr %1, align 8
  %14 = load i16, ptr %11, align 8, !tbaa !8
  %15 = getelementptr inbounds i8, ptr %1, i64 24
  store i16 %14, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %1, i64 26
  store i16 0, ptr %16, align 2, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 26
  %18 = load i16, ptr %17, align 2, !tbaa !18
  %19 = getelementptr inbounds i8, ptr %1, i64 28
  store i16 %18, ptr %19, align 4, !tbaa !19
  %20 = load i8, ptr %2, align 1, !tbaa !5
  %21 = zext i8 %20 to i32
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  %23 = load i32, ptr %22, align 8, !tbaa !20
  %24 = sub i32 %21, %23
  %25 = trunc i32 %24 to i16
  %26 = mul i16 %18, %25
  %27 = getelementptr inbounds i8, ptr %1, i64 6
  store i16 %26, ptr %27, align 2, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %1, i64 30
  store i8 1, ptr %28, align 2, !tbaa !22
  ret ptr %1
}

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 }

!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 = !{!9, !12, i64 24}
!9 = !{!"arm_2d_font_t", !10, i64 0, !11, i64 24, !13, i64 28, !14, i64 32, !14, i64 40}
!10 = !{!"arm_2d_tile_t", !6, i64 0, !6, i64 4, !6, i64 16}
!11 = !{!"arm_2d_size_t", !12, i64 0, !12, i64 2}
!12 = !{!"short", !6, i64 0}
!13 = !{!"int", !6, i64 0}
!14 = !{!"any pointer", !6, i64 0}
!15 = !{!16, !12, i64 24}
!16 = !{!"", !10, i64 0, !12, i64 24, !12, i64 26, !12, i64 28, !6, i64 30}
!17 = !{!16, !12, i64 26}
!18 = !{!9, !12, i64 26}
!19 = !{!16, !12, i64 28}
!20 = !{!21, !13, i64 48}
!21 = !{!"arm_2d_a1_font_t", !6, i64 0, !13, i64 48}
!22 = !{!16, !6, i64 30}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass