; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/OvmfPkg/QemuVideoDxe (QemuVideoGraphicsOutputSetMode)

; 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.QEMU_VIDEO_CIRRUS_MODES = type { i32, i32, i32, i32, ptr, ptr, i8 }
%struct.QEMU_VIDEO_BOCHS_MODES = type { i32, i32, i32 }
%struct.QEMU_VIDEO_PRIVATE_DATA = type { i64, ptr, ptr, i64, %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, ptr, i64, i64, ptr, ptr, i32 }
%struct._EFI_GRAPHICS_OUTPUT_PROTOCOL = type { ptr, ptr, ptr, ptr }
%struct.EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE = type { i32, i32, ptr, i64, i64, i64 }
%struct.QEMU_VIDEO_MODE_DATA = type { i32, i32, i32, i32, i32 }
%struct.EFI_BOOT_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }
%struct.EFI_GRAPHICS_OUTPUT_MODE_INFORMATION = type { i32, i32, i32, i32, %struct.EFI_PIXEL_BITMASK, i32 }
%struct.EFI_PIXEL_BITMASK = type { i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [128 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@gBS = external global ptr, align 8
@QemuVideoCirrusModes = external global [0 x %struct.QEMU_VIDEO_CIRRUS_MODES], align 8
@QemuVideoBochsModes = external global [0 x %struct.QEMU_VIDEO_BOCHS_MODES], align 4
@.str.2 = external hidden unnamed_addr constant [18 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 @AllocatePool(i64 noundef) #1

; Function Attrs: 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 i64 @QemuVideoGraphicsOutputSetMode(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %9 = call zeroext i8 @DebugAssertEnabled()
  %10 = zext i8 %9 to i32
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %22

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = ptrtoint ptr %13 to i64
  %15 = sub i64 %14, ptrtoint (ptr getelementptr inbounds (%struct.QEMU_VIDEO_PRIVATE_DATA, ptr null, i32 0, i32 4) to i64)
  %16 = inttoptr i64 %15 to ptr
  %17 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %16, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !11
  %19 = icmp ne i64 %18, 1145656913
  br i1 %19, label %20, label %22

20:                                               ; preds = %12
  call void @DebugAssert(ptr noundef @.str, i64 noundef 163, ptr noundef @.str.1)
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  br label %27

22:                                               ; preds = %12, %2
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = ptrtoint ptr %23 to i64
  %25 = sub i64 %24, ptrtoint (ptr getelementptr inbounds (%struct.QEMU_VIDEO_PRIVATE_DATA, ptr null, i32 0, i32 4) to i64)
  %26 = inttoptr i64 %25 to ptr
  br label %27

27:                                               ; preds = %22, %20
  %28 = phi ptr [ %21, %20 ], [ %26, %22 ]
  store ptr %28, ptr %6, align 8, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = getelementptr inbounds %struct.EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !16
  %35 = icmp uge i32 %29, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %27
  store i64 -9223372036854775805, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %150

37:                                               ; preds = %27
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %38, i32 0, i32 8
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %40, i64 %42
  store ptr %43, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %44, i32 0, i32 9
  %46 = load ptr, ptr %45, align 8, !tbaa !19
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %56

48:                                               ; preds = %37
  %49 = load ptr, ptr @gBS, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %49, i32 0, i32 7
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %52, i32 0, i32 9
  %54 = load ptr, ptr %53, align 8, !tbaa !19
  %55 = call i64 %51(ptr noundef %54)
  br label %56

56:                                               ; preds = %48, %37
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 4, !tbaa !23
  %60 = mul i32 4, %59
  %61 = zext i32 %60 to i64
  %62 = call ptr @AllocatePool(i64 noundef %61)
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %63, i32 0, i32 9
  store ptr %62, ptr %64, align 8, !tbaa !19
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %65, i32 0, i32 9
  %67 = load ptr, ptr %66, align 8, !tbaa !19
  %68 = icmp eq ptr %67, null
  br i1 %68, label %69, label %70

69:                                               ; preds = %56
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %150

70:                                               ; preds = %56
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %71, i32 0, i32 10
  %73 = load i32, ptr %72, align 8, !tbaa !25
  switch i32 %73, label %88 [
    i32 1, label %74
    i32 2, label %74
    i32 4, label %81
    i32 3, label %81
  ]

74:                                               ; preds = %70, %70
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %76, i32 0, i32 0
  %78 = load i32, ptr %77, align 4, !tbaa !26
  %79 = zext i32 %78 to i64
  %80 = getelementptr inbounds [0 x %struct.QEMU_VIDEO_CIRRUS_MODES], ptr @QemuVideoCirrusModes, i64 0, i64 %79
  call void @InitializeCirrusGraphicsMode(ptr noundef %75, ptr noundef %80)
  br label %105

81:                                               ; preds = %70, %70
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 4, !tbaa !26
  %86 = zext i32 %85 to i64
  %87 = getelementptr inbounds [0 x %struct.QEMU_VIDEO_BOCHS_MODES], ptr @QemuVideoBochsModes, i64 0, i64 %86
  call void @InitializeBochsGraphicsMode(ptr noundef %82, ptr noundef %87)
  br label %105

88:                                               ; preds = %70
  br label %89

89:                                               ; preds = %88
  %90 = call zeroext i8 @DebugAssertEnabled()
  %91 = icmp ne i8 %90, 0
  br i1 %91, label %92, label %93

92:                                               ; preds = %89
  call void @DebugAssert(ptr noundef @.str, i64 noundef 190, ptr noundef @.str.2)
  br label %93

93:                                               ; preds = %92, %89
  br label %94

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94
  %96 = load ptr, ptr @gBS, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %96, i32 0, i32 7
  %98 = load ptr, ptr %97, align 8, !tbaa !20
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %99, i32 0, i32 9
  %101 = load ptr, ptr %100, align 8, !tbaa !19
  %102 = call i64 %98(ptr noundef %101)
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %103, i32 0, i32 9
  store ptr null, ptr %104, align 8, !tbaa !19
  store i64 -9223372036854775801, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %150

105:                                              ; preds = %81, %74
  %106 = load i32, ptr %5, align 4, !tbaa !9
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, ptr %107, i32 0, i32 3
  %109 = load ptr, ptr %108, align 8, !tbaa !15
  %110 = getelementptr inbounds %struct.EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE, ptr %109, i32 0, i32 1
  store i32 %106, ptr %110, align 4, !tbaa !27
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %111, i32 0, i32 1
  %113 = load i32, ptr %112, align 4, !tbaa !23
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, ptr %114, i32 0, i32 3
  %116 = load ptr, ptr %115, align 8, !tbaa !15
  %117 = getelementptr inbounds %struct.EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE, ptr %116, i32 0, i32 2
  %118 = load ptr, ptr %117, align 8, !tbaa !28
  %119 = getelementptr inbounds %struct.EFI_GRAPHICS_OUTPUT_MODE_INFORMATION, ptr %118, i32 0, i32 1
  store i32 %113, ptr %119, align 4, !tbaa !29
  %120 = load ptr, ptr %7, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %120, i32 0, i32 2
  %122 = load i32, ptr %121, align 4, !tbaa !32
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, ptr %123, i32 0, i32 3
  %125 = load ptr, ptr %124, align 8, !tbaa !15
  %126 = getelementptr inbounds %struct.EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE, ptr %125, i32 0, i32 2
  %127 = load ptr, ptr %126, align 8, !tbaa !28
  %128 = getelementptr inbounds %struct.EFI_GRAPHICS_OUTPUT_MODE_INFORMATION, ptr %127, i32 0, i32 2
  store i32 %122, ptr %128, align 4, !tbaa !33
  %129 = load ptr, ptr %4, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, ptr %129, i32 0, i32 3
  %131 = load ptr, ptr %130, align 8, !tbaa !15
  %132 = getelementptr inbounds %struct.EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE, ptr %131, i32 0, i32 3
  store i64 36, ptr %132, align 8, !tbaa !34
  %133 = load ptr, ptr %6, align 8, !tbaa !5
  %134 = load ptr, ptr %4, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, ptr %134, i32 0, i32 3
  %136 = load ptr, ptr %135, align 8, !tbaa !15
  %137 = call i64 @QemuVideoCompleteModeData(ptr noundef %133, ptr noundef %136)
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, ptr %138, i32 0, i32 3
  %140 = load ptr, ptr %139, align 8, !tbaa !15
  %141 = getelementptr inbounds %struct.EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE, ptr %140, i32 0, i32 4
  %142 = load i64, ptr %141, align 8, !tbaa !35
  %143 = inttoptr i64 %142 to ptr
  %144 = load ptr, ptr %4, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct._EFI_GRAPHICS_OUTPUT_PROTOCOL, ptr %144, i32 0, i32 3
  %146 = load ptr, ptr %145, align 8, !tbaa !15
  %147 = getelementptr inbounds %struct.EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE, ptr %146, i32 0, i32 2
  %148 = load ptr, ptr %147, align 8, !tbaa !28
  %149 = call i64 @BltLibConfigure(ptr noundef %143, ptr noundef %148)
  store i64 0, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %150

150:                                              ; preds = %105, %95, %69, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %151 = load i64, ptr %3, align 8
  ret i64 %151
}

declare void @InitializeCirrusGraphicsMode(ptr noundef, ptr noundef) #1

declare void @InitializeBochsGraphicsMode(ptr noundef, ptr noundef) #1

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

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

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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 32, !6, i64 64, !13, i64 72, !13, i64 80, !6, i64 88, !6, i64 96, !10, i64 104}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"_EFI_GRAPHICS_OUTPUT_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!14, !6, i64 24}
!16 = !{!17, !10, i64 0}
!17 = !{!"", !10, i64 0, !10, i64 4, !6, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!18 = !{!12, !6, i64 88}
!19 = !{!12, !6, i64 96}
!20 = !{!21, !6, i64 72}
!21 = !{!"", !22, i64 0, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!22 = !{!"", !13, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!23 = !{!24, !10, i64 4}
!24 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!25 = !{!12, !10, i64 104}
!26 = !{!24, !10, i64 0}
!27 = !{!17, !10, i64 4}
!28 = !{!17, !6, i64 8}
!29 = !{!30, !10, i64 4}
!30 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !31, i64 16, !10, i64 32}
!31 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!32 = !{!24, !10, i64 8}
!33 = !{!30, !10, i64 8}
!34 = !{!17, !13, i64 16}
!35 = !{!17, !13, i64 24}


; 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.QEMU_VIDEO_CIRRUS_MODES = type { i32, i32, i32, i32, ptr, ptr, i8 }
%struct.QEMU_VIDEO_BOCHS_MODES = type { i32, i32, i32 }
%struct.QEMU_VIDEO_MODE_DATA = type { i32, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [128 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@gBS = external local_unnamed_addr global ptr, align 8
@QemuVideoCirrusModes = external global [0 x %struct.QEMU_VIDEO_CIRRUS_MODES], align 8
@QemuVideoBochsModes = external global [0 x %struct.QEMU_VIDEO_BOCHS_MODES], align 4
@.str.2 = external hidden unnamed_addr constant [18 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 @AllocatePool(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775805, 1) i64 @QemuVideoGraphicsOutputSetMode(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %3, 0
  %.pre = ptrtoint ptr %0 to i64
  %.pre36 = add i64 %.pre, -32
  %.pre38 = inttoptr i64 %.pre36 to ptr
  br i1 %.not, label %._crit_edge, label %4

4:                                                ; preds = %2
  %5 = load i64, ptr %.pre38, align 8, !tbaa !5
  %.not32 = icmp eq i64 %5, 1145656913
  br i1 %.not32, label %._crit_edge, label %6

6:                                                ; preds = %4
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 163, ptr noundef nonnull @.str.1) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %2, %4, %6
  %7 = phi ptr [ %0, %6 ], [ %.pre38, %4 ], [ %.pre38, %2 ]
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = load i32, ptr %9, align 8, !tbaa !14
  %.not33 = icmp ugt i32 %10, %1
  br i1 %.not33, label %11, label %66

11:                                               ; preds = %._crit_edge
  %12 = getelementptr inbounds i8, ptr %7, i64 88
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %14 = zext i32 %1 to i64
  %15 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %13, i64 %14
  %16 = getelementptr inbounds i8, ptr %7, i64 96
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %.not34 = icmp eq ptr %17, null
  br i1 %.not34, label %23, label %18

18:                                               ; preds = %11
  %19 = load ptr, ptr @gBS, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %19, i64 72
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  %22 = tail call i64 %21(ptr noundef nonnull %17) #2
  br label %23

23:                                               ; preds = %18, %11
  %24 = getelementptr inbounds i8, ptr %15, i64 4
  %25 = load i32, ptr %24, align 4, !tbaa !22
  %26 = shl i32 %25, 2
  %27 = zext i32 %26 to i64
  %28 = tail call ptr @AllocatePool(i64 noundef %27) #2
  store ptr %28, ptr %16, align 8, !tbaa !17
  %29 = icmp eq ptr %28, null
  br i1 %29, label %66, label %30

30:                                               ; preds = %23
  %31 = getelementptr inbounds i8, ptr %7, i64 104
  %32 = load i32, ptr %31, align 8, !tbaa !24
  switch i32 %32, label %41 [
    i32 1, label %33
    i32 2, label %33
    i32 4, label %37
    i32 3, label %37
  ]

33:                                               ; preds = %30, %30
  %34 = load i32, ptr %15, align 4, !tbaa !25
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds [0 x %struct.QEMU_VIDEO_CIRRUS_MODES], ptr @QemuVideoCirrusModes, i64 0, i64 %35
  tail call void @InitializeCirrusGraphicsMode(ptr noundef nonnull %7, ptr noundef nonnull %36) #2
  br label %50

37:                                               ; preds = %30, %30
  %38 = load i32, ptr %15, align 4, !tbaa !25
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds [0 x %struct.QEMU_VIDEO_BOCHS_MODES], ptr @QemuVideoBochsModes, i64 0, i64 %39
  tail call void @InitializeBochsGraphicsMode(ptr noundef nonnull %7, ptr noundef nonnull %40) #2
  br label %50

41:                                               ; preds = %30
  %42 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not35 = icmp eq i8 %42, 0
  br i1 %.not35, label %44, label %43

43:                                               ; preds = %41
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 190, ptr noundef nonnull @.str.2) #2
  br label %44

44:                                               ; preds = %43, %41
  %45 = load ptr, ptr @gBS, align 8, !tbaa !18
  %46 = getelementptr inbounds i8, ptr %45, i64 72
  %47 = load ptr, ptr %46, align 8, !tbaa !19
  %48 = load ptr, ptr %16, align 8, !tbaa !17
  %49 = tail call i64 %47(ptr noundef %48) #2
  store ptr null, ptr %16, align 8, !tbaa !17
  br label %66

50:                                               ; preds = %37, %33
  %51 = load ptr, ptr %8, align 8, !tbaa !13
  %52 = getelementptr inbounds i8, ptr %51, i64 4
  store i32 %1, ptr %52, align 4, !tbaa !26
  %53 = getelementptr inbounds i8, ptr %51, i64 8
  %54 = load ptr, ptr %53, align 8, !tbaa !27
  %55 = getelementptr inbounds i8, ptr %54, i64 4
  %56 = load <2 x i32>, ptr %24, align 4, !tbaa !28
  store <2 x i32> %56, ptr %55, align 4, !tbaa !28
  %57 = getelementptr inbounds i8, ptr %51, i64 16
  store i64 36, ptr %57, align 8, !tbaa !29
  %58 = tail call i64 @QemuVideoCompleteModeData(ptr noundef nonnull %7, ptr noundef %51)
  %59 = load ptr, ptr %8, align 8, !tbaa !13
  %60 = getelementptr inbounds i8, ptr %59, i64 24
  %61 = load i64, ptr %60, align 8, !tbaa !30
  %62 = inttoptr i64 %61 to ptr
  %63 = getelementptr inbounds i8, ptr %59, i64 8
  %64 = load ptr, ptr %63, align 8, !tbaa !27
  %65 = tail call i64 @BltLibConfigure(ptr noundef %62, ptr noundef %64) #2
  br label %66

66:                                               ; preds = %23, %._crit_edge, %50, %44
  %.0 = phi i64 [ -9223372036854775801, %44 ], [ 0, %50 ], [ -9223372036854775805, %._crit_edge ], [ -9223372036854775799, %23 ]
  ret i64 %.0
}

declare void @InitializeCirrusGraphicsMode(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @InitializeBochsGraphicsMode(ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare i64 @BltLibConfigure(ptr noundef, ptr noundef) local_unnamed_addr #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 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !11, i64 32, !10, i64 64, !7, i64 72, !7, i64 80, !10, i64 88, !10, i64 96, !12, i64 104}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_EFI_GRAPHICS_OUTPUT_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!12 = !{!"int", !8, i64 0}
!13 = !{!11, !10, i64 24}
!14 = !{!15, !12, i64 0}
!15 = !{!"", !12, i64 0, !12, i64 4, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!16 = !{!6, !10, i64 88}
!17 = !{!6, !10, i64 96}
!18 = !{!10, !10, i64 0}
!19 = !{!20, !10, i64 72}
!20 = !{!"", !21, i64 0, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272, !10, i64 280, !10, i64 288, !10, i64 296, !10, i64 304, !10, i64 312, !10, i64 320, !10, i64 328, !10, i64 336, !10, i64 344, !10, i64 352, !10, i64 360, !10, i64 368}
!21 = !{!"", !7, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!22 = !{!23, !12, i64 4}
!23 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16}
!24 = !{!6, !12, i64 104}
!25 = !{!23, !12, i64 0}
!26 = !{!15, !12, i64 4}
!27 = !{!15, !10, i64 8}
!28 = !{!12, !12, i64 0}
!29 = !{!15, !7, i64 16}
!30 = !{!15, !7, i64 24}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass