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

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

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

17:                                               ; preds = %6
  %18 = call zeroext i8 @DebugAssertEnabled()
  %19 = icmp ne i8 %18, 0
  br i1 %19, label %20, label %34

20:                                               ; preds = %17
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %32

23:                                               ; preds = %20
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %32

26:                                               ; preds = %23
  %27 = load ptr, ptr %12, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %32

29:                                               ; preds = %26
  %30 = load ptr, ptr %13, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %33, label %32

32:                                               ; preds = %29, %26, %23, %20
  call void @DebugAssert(ptr noundef @.str, i64 noundef 63, ptr noundef @.str.1)
  br label %33

33:                                               ; preds = %32, %29
  br label %34

34:                                               ; preds = %33, %17
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = load i8, ptr %11, align 1, !tbaa !9
  %38 = icmp ne i8 %37, 0
  br i1 %38, label %85, label %39

39:                                               ; preds = %36
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._HII_STRING_PACKAGE_INSTANCE, ptr %40, i32 0, i32 4
  %42 = getelementptr inbounds %struct._LIST_ENTRY, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !10
  store ptr %43, ptr %15, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %80, %39
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._HII_STRING_PACKAGE_INSTANCE, ptr %46, i32 0, i32 4
  %48 = icmp ne ptr %45, %47
  br i1 %48, label %49, label %84

49:                                               ; preds = %44
  %50 = call zeroext i8 @DebugAssertEnabled()
  %51 = zext i8 %50 to i32
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %63

53:                                               ; preds = %49
  %54 = load ptr, ptr %15, align 8, !tbaa !5
  %55 = ptrtoint ptr %54 to i64
  %56 = sub i64 %55, ptrtoint (ptr getelementptr inbounds (%struct._HII_FONT_INFO, ptr null, i32 0, i32 1) to i64)
  %57 = inttoptr i64 %56 to ptr
  %58 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %57, i32 0, i32 0
  %59 = load i64, ptr %58, align 8, !tbaa !15
  %60 = icmp ne i64 %59, 1768320104
  br i1 %60, label %61, label %63

61:                                               ; preds = %53
  call void @DebugAssert(ptr noundef @.str, i64 noundef 70, ptr noundef @.str.2)
  %62 = load ptr, ptr %15, align 8, !tbaa !5
  br label %68

63:                                               ; preds = %53, %49
  %64 = load ptr, ptr %15, align 8, !tbaa !5
  %65 = ptrtoint ptr %64 to i64
  %66 = sub i64 %65, ptrtoint (ptr getelementptr inbounds (%struct._HII_FONT_INFO, ptr null, i32 0, i32 1) to i64)
  %67 = inttoptr i64 %66 to ptr
  br label %68

68:                                               ; preds = %63, %61
  %69 = phi ptr [ %62, %61 ], [ %67, %63 ]
  store ptr %69, ptr %14, align 8, !tbaa !5
  %70 = load ptr, ptr %14, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !17
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._HII_GLOBAL_FONT_INFO, ptr %73, i32 0, i32 1
  %75 = icmp eq ptr %72, %74
  br i1 %75, label %76, label %79

76:                                               ; preds = %68
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %77, ptr %78, align 8, !tbaa !5
  store i8 1, ptr %7, align 1
  store i32 1, ptr %16, align 4
  br label %114

79:                                               ; preds = %68
  br label %80

80:                                               ; preds = %79
  %81 = load ptr, ptr %15, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._LIST_ENTRY, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !18
  store ptr %83, ptr %15, align 8, !tbaa !5
  br label %44, !llvm.loop !19

84:                                               ; preds = %44
  br label %85

85:                                               ; preds = %84, %36
  %86 = call ptr @AllocateZeroPool(i64 noundef 40)
  store ptr %86, ptr %14, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %85
  %88 = call zeroext i8 @DebugAssertEnabled()
  %89 = icmp ne i8 %88, 0
  br i1 %89, label %90, label %95

90:                                               ; preds = %87
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = icmp ne ptr %91, null
  br i1 %92, label %94, label %93

93:                                               ; preds = %90
  call void @DebugAssert(ptr noundef @.str, i64 noundef 85, ptr noundef @.str.3)
  br label %94

94:                                               ; preds = %93, %90
  br label %95

95:                                               ; preds = %94, %87
  br label %96

96:                                               ; preds = %95
  br label %97

97:                                               ; preds = %96
  %98 = load ptr, ptr %14, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %98, i32 0, i32 0
  store i64 1768320104, ptr %99, align 8, !tbaa !15
  %100 = load i8, ptr %10, align 1, !tbaa !9
  %101 = load ptr, ptr %14, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %101, i32 0, i32 3
  store i8 %100, ptr %102, align 8, !tbaa !21
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct._HII_GLOBAL_FONT_INFO, ptr %103, i32 0, i32 1
  %105 = load ptr, ptr %14, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %105, i32 0, i32 2
  store ptr %104, ptr %106, align 8, !tbaa !17
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._HII_STRING_PACKAGE_INSTANCE, ptr %107, i32 0, i32 4
  %109 = load ptr, ptr %14, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._HII_FONT_INFO, ptr %109, i32 0, i32 1
  %111 = call ptr @InsertTailList(ptr noundef %108, ptr noundef %110)
  %112 = load ptr, ptr %14, align 8, !tbaa !5
  %113 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %112, ptr %113, align 8, !tbaa !5
  store i8 0, ptr %7, align 1
  store i32 1, ptr %16, align 4
  br label %114

114:                                              ; preds = %97, %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %115 = load i8, ptr %7, align 1
  ret i8 %115
}

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

declare zeroext i8 @DebugAssertEnabled() #2

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

declare ptr @AllocateZeroPool(i64 noundef) #2

declare ptr @InsertTailList(ptr noundef, ptr noundef) #2

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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, !6, i64 24}
!18 = !{!13, !6, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!16, !7, i64 32}


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

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @ReferFontInfoLocally(ptr noundef readnone %0, ptr noundef %1, i8 noundef zeroext %2, i8 noundef zeroext %3, ptr noundef %4, ptr noundef writeonly %5) local_unnamed_addr #0 {
  %7 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %7, 0
  br i1 %.not, label %17, label %8

8:                                                ; preds = %6
  %9 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %10 = insertelement <4 x ptr> %9, ptr %1, i64 1
  %11 = insertelement <4 x ptr> %10, ptr %4, i64 2
  %12 = insertelement <4 x ptr> %11, ptr %5, i64 3
  %13 = icmp eq <4 x ptr> %12, zeroinitializer
  %14 = bitcast <4 x i1> %13 to i4
  %15 = icmp eq i4 %14, 0
  br i1 %15, label %17, label %16

16:                                               ; preds = %8
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 63, ptr noundef nonnull @.str.1) #2
  br label %17

17:                                               ; preds = %16, %8, %6
  %.not34 = icmp eq i8 %3, 0
  br i1 %.not34, label %18, label %.loopexit

18:                                               ; preds = %17
  %19 = getelementptr inbounds i8, ptr %1, i64 40
  %20 = getelementptr inbounds i8, ptr %4, i64 8
  br label %21

21:                                               ; preds = %._crit_edge, %18
  %.0.in = phi ptr [ %19, %18 ], [ %.0, %._crit_edge ]
  %.0 = load ptr, ptr %.0.in, align 8, !tbaa !5
  %.not35 = icmp eq ptr %.0, %19
  br i1 %.not35, label %.loopexit, label %22

22:                                               ; preds = %21
  %23 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not36 = icmp eq i8 %23, 0
  %.pre = ptrtoint ptr %.0 to i64
  %.pre39 = add i64 %.pre, -8
  %.pre41 = inttoptr i64 %.pre39 to ptr
  br i1 %.not36, label %._crit_edge, label %24

24:                                               ; preds = %22
  %25 = load i64, ptr %.pre41, align 8, !tbaa !10
  %.not37 = icmp eq i64 %25, 1768320104
  br i1 %.not37, label %._crit_edge, label %26

26:                                               ; preds = %24
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 70, ptr noundef nonnull @.str.2) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %22, %24, %26
  %27 = phi ptr [ %.0, %26 ], [ %.pre41, %24 ], [ %.pre41, %22 ]
  %28 = getelementptr inbounds i8, ptr %27, i64 24
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = icmp eq ptr %29, %20
  br i1 %30, label %.loopexit38, label %21, !llvm.loop !14

.loopexit:                                        ; preds = %21, %17
  %31 = tail call ptr @AllocateZeroPool(i64 noundef 40) #2
  %32 = tail call zeroext i8 @DebugAssertEnabled() #2
  %33 = icmp eq i8 %32, 0
  %34 = icmp ne ptr %31, null
  %or.cond7 = select i1 %33, i1 true, i1 %34
  br i1 %or.cond7, label %36, label %35

35:                                               ; preds = %.loopexit
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 85, ptr noundef nonnull @.str.3) #2
  br label %36

36:                                               ; preds = %35, %.loopexit
  store i64 1768320104, ptr %31, align 8, !tbaa !10
  %37 = getelementptr inbounds i8, ptr %31, i64 32
  store i8 %2, ptr %37, align 8, !tbaa !16
  %38 = getelementptr inbounds i8, ptr %4, i64 8
  %39 = getelementptr inbounds i8, ptr %31, i64 24
  store ptr %38, ptr %39, align 8, !tbaa !13
  %40 = getelementptr inbounds i8, ptr %1, i64 40
  %41 = getelementptr inbounds i8, ptr %31, i64 8
  %42 = tail call ptr @InsertTailList(ptr noundef nonnull %40, ptr noundef nonnull %41) #2
  br label %.loopexit38

.loopexit38:                                      ; preds = %._crit_edge, %36
  %storemerge = phi ptr [ %31, %36 ], [ %27, %._crit_edge ]
  %.033 = phi i8 [ 0, %36 ], [ 1, %._crit_edge ]
  store ptr %storemerge, ptr %5, align 8, !tbaa !17
  ret i8 %.033
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #1

declare ptr @InsertTailList(ptr noundef, ptr noundef) local_unnamed_addr #1

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

!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, !7, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!11, !8, i64 32}
!17 = !{!7, !7, i64 0}


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