; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal (GetStringFontInfo)

; 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._HII_STRING_PACKAGE_INSTANCE = type { i64, ptr, ptr, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i8, i16 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct._HII_FONT_INFO = type { i64, %struct._LIST_ENTRY, ptr, i8 }
%struct._HII_GLOBAL_FONT_INFO = type { i64, %struct._LIST_ENTRY, ptr, i64, ptr }

@.str = external hidden unnamed_addr constant [148 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [64 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

declare zeroext i8 @DebugAssertEnabled() #1

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) #1

declare ptr @AllocateZeroPool(i64 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @GetStringFontInfo(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2) #2 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  br label %12

12:                                               ; preds = %3
  %13 = call zeroext i8 @DebugAssertEnabled()
  %14 = icmp ne i8 %13, 0
  br i1 %14, label %15, label %23

15:                                               ; preds = %12
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %21

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

21:                                               ; preds = %18, %15
  call void @DebugAssert(ptr noundef @.str, i64 noundef 216, ptr noundef @.str.5)
  br label %22

22:                                               ; preds = %21, %18
  br label %23

23:                                               ; preds = %22, %12
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._HII_STRING_PACKAGE_INSTANCE, ptr %26, i32 0, i32 4
  %28 = getelementptr inbounds %struct._LIST_ENTRY, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !10
  store ptr %29, ptr %8, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %110, %25
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._HII_STRING_PACKAGE_INSTANCE, ptr %32, i32 0, i32 4
  %34 = icmp ne ptr %31, %33
  br i1 %34, label %35, label %114

35:                                               ; preds = %30
  %36 = call zeroext i8 @DebugAssertEnabled()
  %37 = zext i8 %36 to i32
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %49

39:                                               ; preds = %35
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = ptrtoint ptr %40 to i64
  %42 = sub i64 %41, ptrtoint (ptr getelementptr inbounds (%struct._HII_FONT_INFO, ptr null, i32 0, i32 1) to i64)
  %43 = inttoptr i64 %42 to ptr
  %44 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %43, i32 0, i32 0
  %45 = load i64, ptr %44, align 8, !tbaa !15
  %46 = icmp ne i64 %45, 1768320104
  br i1 %46, label %47, label %49

47:                                               ; preds = %39
  call void @DebugAssert(ptr noundef @.str, i64 noundef 219, ptr noundef @.str.2)
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  br label %54

49:                                               ; preds = %39, %35
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = ptrtoint ptr %50 to i64
  %52 = sub i64 %51, ptrtoint (ptr getelementptr inbounds (%struct._HII_FONT_INFO, ptr null, i32 0, i32 1) to i64)
  %53 = inttoptr i64 %52 to ptr
  br label %54

54:                                               ; preds = %49, %47
  %55 = phi ptr [ %48, %47 ], [ %53, %49 ]
  store ptr %55, ptr %9, align 8, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %56, i32 0, i32 3
  %58 = load i8, ptr %57, align 8, !tbaa !17
  %59 = zext i8 %58 to i32
  %60 = load i8, ptr %6, align 1, !tbaa !9
  %61 = zext i8 %60 to i32
  %62 = icmp eq i32 %59, %61
  br i1 %62, label %63, label %109

63:                                               ; preds = %54
  %64 = call zeroext i8 @DebugAssertEnabled()
  %65 = zext i8 %64 to i32
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %81

67:                                               ; preds = %63
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %68, i32 0, i32 2
  %70 = load ptr, ptr %69, align 8, !tbaa !18
  %71 = ptrtoint ptr %70 to i64
  %72 = sub i64 %71, ptrtoint (ptr getelementptr inbounds (%struct._HII_GLOBAL_FONT_INFO, ptr null, i32 0, i32 1) to i64)
  %73 = inttoptr i64 %72 to ptr
  %74 = getelementptr inbounds %struct._HII_GLOBAL_FONT_INFO, ptr %73, i32 0, i32 0
  %75 = load i64, ptr %74, align 8, !tbaa !19
  %76 = icmp ne i64 %75, 1768318824
  br i1 %76, label %77, label %81

77:                                               ; preds = %67
  call void @DebugAssert(ptr noundef @.str, i64 noundef 221, ptr noundef @.str.2)
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %78, i32 0, i32 2
  %80 = load ptr, ptr %79, align 8, !tbaa !18
  br label %88

81:                                               ; preds = %67, %63
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !18
  %85 = ptrtoint ptr %84 to i64
  %86 = sub i64 %85, ptrtoint (ptr getelementptr inbounds (%struct._HII_GLOBAL_FONT_INFO, ptr null, i32 0, i32 1) to i64)
  %87 = inttoptr i64 %86 to ptr
  br label %88

88:                                               ; preds = %81, %77
  %89 = phi ptr [ %80, %77 ], [ %87, %81 ]
  store ptr %89, ptr %10, align 8, !tbaa !5
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._HII_GLOBAL_FONT_INFO, ptr %90, i32 0, i32 3
  %92 = load i64, ptr %91, align 8, !tbaa !21
  %93 = call ptr @AllocateZeroPool(i64 noundef %92)
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %93, ptr %94, align 8, !tbaa !5
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = load ptr, ptr %95, align 8, !tbaa !5
  %97 = icmp eq ptr %96, null
  br i1 %97, label %98, label %99

98:                                               ; preds = %88
  store i64 -9223372036854775799, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %115

99:                                               ; preds = %88
  %100 = load ptr, ptr %7, align 8, !tbaa !5
  %101 = load ptr, ptr %100, align 8, !tbaa !5
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct._HII_GLOBAL_FONT_INFO, ptr %102, i32 0, i32 4
  %104 = load ptr, ptr %103, align 8, !tbaa !22
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct._HII_GLOBAL_FONT_INFO, ptr %105, i32 0, i32 3
  %107 = load i64, ptr %106, align 8, !tbaa !21
  %108 = call ptr @CopyMem(ptr noundef %101, ptr noundef %104, i64 noundef %107)
  store i64 0, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %115

109:                                              ; preds = %54
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %8, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct._LIST_ENTRY, ptr %111, i32 0, i32 0
  %113 = load ptr, ptr %112, align 8, !tbaa !23
  store ptr %113, ptr %8, align 8, !tbaa !5
  br label %30, !llvm.loop !24

114:                                              ; preds = %30
  store i64 -9223372036854775794, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %115

115:                                              ; preds = %114, %99, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %116 = load i64, ptr %4, align 8
  ret i64 %116
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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, !6, i64 40}
!11 = !{!"_HII_STRING_PACKAGE_INSTANCE", !12, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !13, i64 40, !7, i64 56, !14, i64 58}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !12, i64 0}
!16 = !{!"_HII_FONT_INFO", !12, i64 0, !13, i64 8, !6, i64 24, !7, i64 32}
!17 = !{!16, !7, i64 32}
!18 = !{!16, !6, i64 24}
!19 = !{!20, !12, i64 0}
!20 = !{!"_HII_GLOBAL_FONT_INFO", !12, i64 0, !13, i64 8, !6, i64 24, !12, i64 32, !6, i64 40}
!21 = !{!20, !12, i64 32}
!22 = !{!20, !6, i64 40}
!23 = !{!13, !6, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; 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 [148 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [64 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #0

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775799, 1) i64 @GetStringFontInfo(ptr noundef readonly %0, i8 noundef zeroext %1, ptr noundef writeonly %2) local_unnamed_addr #1 {
  %4 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %9, label %5

5:                                                ; preds = %3
  %6 = icmp ne ptr %2, null
  %7 = icmp ne ptr %0, null
  %or.cond = and i1 %7, %6
  br i1 %or.cond, label %9, label %8

8:                                                ; preds = %5
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 216, ptr noundef nonnull @.str.5) #2
  br label %9

9:                                                ; preds = %8, %5, %3
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  br label %11

11:                                               ; preds = %._crit_edge33, %9
  %.021.in = phi ptr [ %10, %9 ], [ %.021, %._crit_edge33 ]
  %.021 = load ptr, ptr %.021.in, align 8, !tbaa !5
  %.not23 = icmp eq ptr %.021, %10
  br i1 %.not23, label %.loopexit, label %12

12:                                               ; preds = %11
  %13 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not24 = icmp eq i8 %13, 0
  %.pre34 = ptrtoint ptr %.021 to i64
  %.pre36 = add i64 %.pre34, -8
  %.pre38 = inttoptr i64 %.pre36 to ptr
  br i1 %.not24, label %._crit_edge33, label %14

14:                                               ; preds = %12
  %15 = load i64, ptr %.pre38, align 8, !tbaa !10
  %.not25 = icmp eq i64 %15, 1768320104
  br i1 %.not25, label %._crit_edge33, label %16

16:                                               ; preds = %14
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 219, ptr noundef nonnull @.str.2) #2
  br label %._crit_edge33

._crit_edge33:                                    ; preds = %12, %14, %16
  %17 = phi ptr [ %.021, %16 ], [ %.pre38, %14 ], [ %.pre38, %12 ]
  %18 = getelementptr inbounds i8, ptr %17, i64 32
  %19 = load i8, ptr %18, align 8, !tbaa !13
  %20 = icmp eq i8 %19, %1
  br i1 %20, label %21, label %11, !llvm.loop !14

21:                                               ; preds = %._crit_edge33
  %22 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not26 = icmp eq i8 %22, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %17, i64 24
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !16
  %.pre28 = ptrtoint ptr %.pre to i64
  %.pre29 = add i64 %.pre28, -8
  %.pre31 = inttoptr i64 %.pre29 to ptr
  br i1 %.not26, label %._crit_edge, label %23

23:                                               ; preds = %21
  %24 = load i64, ptr %.pre31, align 8, !tbaa !17
  %.not27 = icmp eq i64 %24, 1768318824
  br i1 %.not27, label %._crit_edge, label %25

25:                                               ; preds = %23
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 221, ptr noundef nonnull @.str.2) #2
  %26 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !16
  br label %._crit_edge

._crit_edge:                                      ; preds = %21, %23, %25
  %27 = phi ptr [ %26, %25 ], [ %.pre31, %23 ], [ %.pre31, %21 ]
  %28 = getelementptr inbounds i8, ptr %27, i64 32
  %29 = load i64, ptr %28, align 8, !tbaa !19
  %30 = tail call ptr @AllocateZeroPool(i64 noundef %29) #2
  store ptr %30, ptr %2, align 8, !tbaa !20
  %31 = icmp eq ptr %30, null
  br i1 %31, label %.loopexit, label %32

32:                                               ; preds = %._crit_edge
  %33 = getelementptr inbounds i8, ptr %27, i64 40
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  %35 = load i64, ptr %28, align 8, !tbaa !19
  %36 = tail call ptr @CopyMem(ptr noundef nonnull %30, ptr noundef %34, i64 noundef %35) #2
  br label %.loopexit

.loopexit:                                        ; preds = %11, %._crit_edge, %32
  %.0 = phi i64 [ 0, %32 ], [ -9223372036854775799, %._crit_edge ], [ -9223372036854775794, %11 ]
  ret i64 %.0
}

attributes #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 #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, !7, i64 0}
!6 = !{!"_LIST_ENTRY", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 0}
!11 = !{!"_HII_FONT_INFO", !12, i64 0, !6, i64 8, !7, i64 24, !8, i64 32}
!12 = !{!"long long", !8, i64 0}
!13 = !{!11, !8, i64 32}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!11, !7, i64 24}
!17 = !{!18, !12, i64 0}
!18 = !{!"_HII_GLOBAL_FONT_INFO", !12, i64 0, !6, i64 8, !7, i64 24, !12, i64 32, !7, i64 40}
!19 = !{!18, !12, i64 32}
!20 = !{!7, !7, i64 0}
!21 = !{!18, !7, i64 40}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass