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

; 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_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_PCI_IO_PROTOCOL = type { ptr, ptr, %struct.EFI_PCI_IO_PROTOCOL_ACCESS, %struct.EFI_PCI_IO_PROTOCOL_ACCESS, %struct.EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr }
%struct.EFI_PCI_IO_PROTOCOL_ACCESS = type { ptr, ptr }
%struct.EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS = type { ptr, ptr }
%struct.QEMU_VIDEO_MODE_DATA = type { i32, i32, i32, i32, i32 }

@QemuVideoBochsModes = external dso_local global [37 x %struct.QEMU_VIDEO_BOCHS_MODES], align 16
@.str.1 = external hidden unnamed_addr constant [53 x i8], align 1
@__FUNCTION__.QemuVideoBochsModeSetup = external hidden unnamed_addr constant [24 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [135 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 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 ptr @AllocatePool(i64 noundef) #1

declare zeroext i8 @DebugPrintEnabled() #1

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #1

declare void @DebugPrint(i64 noundef, ptr 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 @QemuVideoBochsModeSetup(ptr noundef %0, i8 noundef zeroext %1) #2 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %14 = load i8, ptr %5, align 1, !tbaa !9
  %15 = icmp ne i8 %14, 0
  br i1 %15, label %16, label %77

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %10, align 4, !tbaa !10
  store i32 -1, ptr %11, align 4, !tbaa !10
  store i32 0, ptr %6, align 4, !tbaa !10
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = getelementptr inbounds %struct._EFI_PCI_IO_PROTOCOL, ptr %19, i32 0, i32 2
  %21 = getelementptr inbounds %struct.EFI_PCI_IO_PROTOCOL_ACCESS, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = call i64 %22(ptr noundef %25, i32 noundef 2, i8 noundef zeroext 2, i64 noundef 0, i64 noundef 1, ptr noundef %10)
  %27 = icmp slt i64 %26, 0
  br i1 %27, label %58, label %28

28:                                               ; preds = %16
  %29 = load i32, ptr %10, align 4, !tbaa !10
  %30 = icmp ne i32 %29, 1330796625
  br i1 %30, label %58, label %31

31:                                               ; preds = %28
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %35 = getelementptr inbounds %struct._EFI_PCI_IO_PROTOCOL, ptr %34, i32 0, i32 2
  %36 = getelementptr inbounds %struct.EFI_PCI_IO_PROTOCOL_ACCESS, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !12
  %41 = call i64 %37(ptr noundef %40, i32 noundef 2, i8 noundef zeroext 2, i64 noundef 36, i64 noundef 1, ptr noundef %11)
  %42 = icmp slt i64 %41, 0
  br i1 %42, label %58, label %43

43:                                               ; preds = %31
  %44 = load i32, ptr %11, align 4, !tbaa !10
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %58, label %46

46:                                               ; preds = %43
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !12
  %50 = getelementptr inbounds %struct._EFI_PCI_IO_PROTOCOL, ptr %49, i32 0, i32 2
  %51 = getelementptr inbounds %struct.EFI_PCI_IO_PROTOCOL_ACCESS, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !12
  %56 = call i64 %52(ptr noundef %55, i32 noundef 2, i8 noundef zeroext 2, i64 noundef 40, i64 noundef 1, ptr noundef %6)
  %57 = icmp slt i64 %56, 0
  br i1 %57, label %58, label %73

58:                                               ; preds = %46, %43, %31, %28, %16
  br label %59

59:                                               ; preds = %58
  %60 = call zeroext i8 @DebugPrintEnabled()
  %61 = icmp ne i8 %60, 0
  br i1 %61, label %62, label %70

62:                                               ; preds = %59
  br label %63

63:                                               ; preds = %62
  %64 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %65 = icmp ne i8 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %63
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.1, ptr noundef @__FUNCTION__.QemuVideoBochsModeSetup)
  br label %67

67:                                               ; preds = %66, %63
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  br label %70

70:                                               ; preds = %69, %59
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  store i64 -9223372036854775794, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %74

73:                                               ; preds = %46
  store i32 0, ptr %12, align 4
  br label %74

74:                                               ; preds = %73, %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %75 = load i32, ptr %12, align 4
  switch i32 %75, label %227 [
    i32 0, label %76
  ]

76:                                               ; preds = %74
  br label %83

77:                                               ; preds = %2
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = call zeroext i16 @BochsRead(ptr noundef %78, i16 noundef zeroext 10)
  %80 = zext i16 %79 to i32
  store i32 %80, ptr %6, align 4, !tbaa !10
  %81 = load i32, ptr %6, align 4, !tbaa !10
  %82 = mul i32 %81, 65536
  store i32 %82, ptr %6, align 4, !tbaa !10
  br label %83

83:                                               ; preds = %77, %76
  br label %84

84:                                               ; preds = %83
  %85 = call zeroext i8 @DebugPrintEnabled()
  %86 = icmp ne i8 %85, 0
  br i1 %86, label %87, label %96

87:                                               ; preds = %84
  br label %88

88:                                               ; preds = %87
  %89 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 4194304)
  %90 = icmp ne i8 %89, 0
  br i1 %90, label %91, label %93

91:                                               ; preds = %88
  %92 = load i32, ptr %6, align 4, !tbaa !10
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 4194304, ptr noundef @.str.2, ptr noundef @__FUNCTION__.QemuVideoBochsModeSetup, i32 noundef %92)
  br label %93

93:                                               ; preds = %91, %88
  br label %94

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94
  br label %96

96:                                               ; preds = %95, %84
  br label %97

97:                                               ; preds = %96
  br label %98

98:                                               ; preds = %97
  %99 = call ptr @AllocatePool(i64 noundef 740)
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %100, i32 0, i32 8
  store ptr %99, ptr %101, align 8, !tbaa !19
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %102, i32 0, i32 8
  %104 = load ptr, ptr %103, align 8, !tbaa !19
  %105 = icmp eq ptr %104, null
  br i1 %105, label %106, label %107

106:                                              ; preds = %98
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %227

107:                                              ; preds = %98
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %108, i32 0, i32 8
  %110 = load ptr, ptr %109, align 8, !tbaa !19
  store ptr %110, ptr %8, align 8, !tbaa !5
  store ptr @QemuVideoBochsModes, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %7, align 4, !tbaa !10
  br label %111

111:                                              ; preds = %213, %107
  %112 = load i32, ptr %7, align 4, !tbaa !10
  %113 = zext i32 %112 to i64
  %114 = icmp ult i64 %113, 37
  br i1 %114, label %115, label %216

115:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  br label %116

116:                                              ; preds = %115
  %117 = call zeroext i8 @DebugAssertEnabled()
  %118 = icmp ne i8 %117, 0
  br i1 %118, label %119, label %127

119:                                              ; preds = %116
  %120 = load ptr, ptr %9, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.QEMU_VIDEO_BOCHS_MODES, ptr %120, i32 0, i32 2
  %122 = load i32, ptr %121, align 4, !tbaa !20
  %123 = urem i32 %122, 8
  %124 = icmp eq i32 %123, 0
  br i1 %124, label %126, label %125

125:                                              ; preds = %119
  call void @DebugAssert(ptr noundef @.str.3, i64 noundef 325, ptr noundef @.str.4)
  br label %126

126:                                              ; preds = %125, %119
  br label %127

127:                                              ; preds = %126, %116
  br label %128

128:                                              ; preds = %127
  br label %129

129:                                              ; preds = %128
  %130 = load ptr, ptr %9, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.QEMU_VIDEO_BOCHS_MODES, ptr %130, i32 0, i32 0
  %132 = load i32, ptr %131, align 4, !tbaa !22
  %133 = zext i32 %132 to i64
  %134 = load ptr, ptr %9, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.QEMU_VIDEO_BOCHS_MODES, ptr %134, i32 0, i32 1
  %136 = load i32, ptr %135, align 4, !tbaa !23
  %137 = zext i32 %136 to i64
  %138 = mul i64 %133, %137
  %139 = load ptr, ptr %9, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.QEMU_VIDEO_BOCHS_MODES, ptr %139, i32 0, i32 2
  %141 = load i32, ptr %140, align 4, !tbaa !20
  %142 = udiv i32 %141, 8
  %143 = zext i32 %142 to i64
  %144 = mul i64 %138, %143
  store i64 %144, ptr %13, align 8, !tbaa !24
  %145 = load i64, ptr %13, align 8, !tbaa !24
  %146 = load i32, ptr %6, align 4, !tbaa !10
  %147 = zext i32 %146 to i64
  %148 = icmp ule i64 %145, %147
  br i1 %148, label %149, label %210

149:                                              ; preds = %129
  %150 = load i32, ptr %7, align 4, !tbaa !10
  %151 = load ptr, ptr %8, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %151, i32 0, i32 0
  store i32 %150, ptr %152, align 4, !tbaa !25
  %153 = load ptr, ptr %9, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.QEMU_VIDEO_BOCHS_MODES, ptr %153, i32 0, i32 0
  %155 = load i32, ptr %154, align 4, !tbaa !22
  %156 = load ptr, ptr %8, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %156, i32 0, i32 1
  store i32 %155, ptr %157, align 4, !tbaa !27
  %158 = load ptr, ptr %9, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.QEMU_VIDEO_BOCHS_MODES, ptr %158, i32 0, i32 1
  %160 = load i32, ptr %159, align 4, !tbaa !23
  %161 = load ptr, ptr %8, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %161, i32 0, i32 2
  store i32 %160, ptr %162, align 4, !tbaa !28
  %163 = load ptr, ptr %9, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.QEMU_VIDEO_BOCHS_MODES, ptr %163, i32 0, i32 2
  %165 = load i32, ptr %164, align 4, !tbaa !20
  %166 = load ptr, ptr %8, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %166, i32 0, i32 3
  store i32 %165, ptr %167, align 4, !tbaa !29
  %168 = load ptr, ptr %8, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %168, i32 0, i32 4
  store i32 60, ptr %169, align 4, !tbaa !30
  br label %170

170:                                              ; preds = %149
  %171 = call zeroext i8 @DebugPrintEnabled()
  %172 = icmp ne i8 %171, 0
  br i1 %172, label %173, label %205

173:                                              ; preds = %170
  br label %174

174:                                              ; preds = %173
  %175 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64)
  %176 = icmp ne i8 %175, 0
  br i1 %176, label %177, label %202

177:                                              ; preds = %174
  %178 = load ptr, ptr %8, align 8, !tbaa !5
  %179 = load ptr, ptr %4, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %179, i32 0, i32 8
  %181 = load ptr, ptr %180, align 8, !tbaa !19
  %182 = ptrtoint ptr %178 to i64
  %183 = ptrtoint ptr %181 to i64
  %184 = sub i64 %182, %183
  %185 = sdiv exact i64 %184, 20
  %186 = trunc i64 %185 to i32
  %187 = load ptr, ptr %8, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %187, i32 0, i32 0
  %189 = load i32, ptr %188, align 4, !tbaa !25
  %190 = load ptr, ptr %8, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %190, i32 0, i32 1
  %192 = load i32, ptr %191, align 4, !tbaa !27
  %193 = load ptr, ptr %8, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %193, i32 0, i32 2
  %195 = load i32, ptr %194, align 4, !tbaa !28
  %196 = load ptr, ptr %8, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %196, i32 0, i32 3
  %198 = load i32, ptr %197, align 4, !tbaa !29
  %199 = load ptr, ptr %8, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %199, i32 0, i32 4
  %201 = load i32, ptr %200, align 4, !tbaa !30
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 64, ptr noundef @.str.5, i32 noundef %186, i32 noundef %189, i32 noundef %192, i32 noundef %195, i32 noundef %198, i32 noundef %201)
  br label %202

202:                                              ; preds = %177, %174
  br label %203

203:                                              ; preds = %202
  br label %204

204:                                              ; preds = %203
  br label %205

205:                                              ; preds = %204, %170
  br label %206

206:                                              ; preds = %205
  br label %207

207:                                              ; preds = %206
  %208 = load ptr, ptr %8, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.QEMU_VIDEO_MODE_DATA, ptr %208, i32 1
  store ptr %209, ptr %8, align 8, !tbaa !5
  br label %210

210:                                              ; preds = %207, %129
  %211 = load ptr, ptr %9, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.QEMU_VIDEO_BOCHS_MODES, ptr %211, i32 1
  store ptr %212, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %213

213:                                              ; preds = %210
  %214 = load i32, ptr %7, align 4, !tbaa !10
  %215 = add i32 %214, 1
  store i32 %215, ptr %7, align 4, !tbaa !10
  br label %111, !llvm.loop !31

216:                                              ; preds = %111
  %217 = load ptr, ptr %8, align 8, !tbaa !5
  %218 = load ptr, ptr %4, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %218, i32 0, i32 8
  %220 = load ptr, ptr %219, align 8, !tbaa !19
  %221 = ptrtoint ptr %217 to i64
  %222 = ptrtoint ptr %220 to i64
  %223 = sub i64 %221, %222
  %224 = sdiv exact i64 %223, 20
  %225 = load ptr, ptr %4, align 8, !tbaa !5
  %226 = getelementptr inbounds %struct.QEMU_VIDEO_PRIVATE_DATA, ptr %225, i32 0, i32 7
  store i64 %224, ptr %226, align 8, !tbaa !33
  store i64 0, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %227

227:                                              ; preds = %216, %106, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %228 = load i64, ptr %3, align 8
  ret i64 %228
}

declare zeroext i16 @BochsRead(ptr noundef, i16 noundef zeroext) #1

declare zeroext i8 @DebugAssertEnabled() #1

declare void @DebugAssert(ptr noundef, i64 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 16}
!13 = !{!"", !14, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !15, i64 32, !6, i64 64, !14, i64 72, !14, i64 80, !6, i64 88, !6, i64 96, !11, i64 104}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"_EFI_GRAPHICS_OUTPUT_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!17, !6, i64 16}
!17 = !{!"_EFI_PCI_IO_PROTOCOL", !6, i64 0, !6, i64 8, !18, i64 16, !18, i64 32, !18, i64 48, !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, !14, i64 144, !6, i64 152}
!18 = !{!"", !6, i64 0, !6, i64 8}
!19 = !{!13, !6, i64 88}
!20 = !{!21, !11, i64 8}
!21 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!22 = !{!21, !11, i64 0}
!23 = !{!21, !11, i64 4}
!24 = !{!14, !14, i64 0}
!25 = !{!26, !11, i64 0}
!26 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!27 = !{!26, !11, i64 4}
!28 = !{!26, !11, i64 8}
!29 = !{!26, !11, i64 12}
!30 = !{!26, !11, i64 16}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}
!33 = !{!13, !14, i64 80}


; 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_BOCHS_MODES = type { i32, i32, i32 }

@QemuVideoBochsModes = external dso_local local_unnamed_addr global [37 x %struct.QEMU_VIDEO_BOCHS_MODES], align 16
@.str.1 = external hidden unnamed_addr constant [53 x i8], align 1
@__FUNCTION__.QemuVideoBochsModeSetup = external hidden unnamed_addr constant [24 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [135 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [64 x i8], align 1

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

declare ptr @AllocatePool(i64 noundef) local_unnamed_addr #1

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #1

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) local_unnamed_addr #1

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

; 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 range(i64 -9223372036854775799, 1) i64 @QemuVideoBochsModeSetup(ptr noundef %0, i8 noundef zeroext %1) local_unnamed_addr #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %.not = icmp eq i8 %1, 0
  br i1 %.not, label %35, label %6

6:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  store i32 -1, ptr %5, align 4, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = call i64 %10(ptr noundef %8, i32 noundef 2, i8 noundef zeroext 2, i64 noundef 0, i64 noundef 1, ptr noundef nonnull %4) #3
  %12 = icmp slt i64 %11, 0
  %13 = load i32, ptr %4, align 4
  %14 = icmp ne i32 %13, 1330796625
  %or.cond = select i1 %12, i1 true, i1 %14
  br i1 %or.cond, label %29, label %15

15:                                               ; preds = %6
  %16 = load ptr, ptr %7, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = call i64 %18(ptr noundef %16, i32 noundef 2, i8 noundef zeroext 2, i64 noundef 36, i64 noundef 1, ptr noundef nonnull %5) #3
  %20 = icmp slt i64 %19, 0
  %21 = load i32, ptr %5, align 4
  %22 = icmp ne i32 %21, 0
  %or.cond3 = select i1 %20, i1 true, i1 %22
  br i1 %or.cond3, label %29, label %23

23:                                               ; preds = %15
  %24 = load ptr, ptr %7, align 8, !tbaa !9
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = call i64 %26(ptr noundef %24, i32 noundef 2, i8 noundef zeroext 2, i64 noundef 40, i64 noundef 1, ptr noundef nonnull %3) #3
  %28 = icmp slt i64 %27, 0
  br i1 %28, label %29, label %34

29:                                               ; preds = %6, %15, %23
  %30 = call zeroext i8 @DebugPrintEnabled() #3
  %.not48 = icmp eq i8 %30, 0
  br i1 %.not48, label %.critedge, label %31

31:                                               ; preds = %29
  %32 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not49 = icmp eq i8 %32, 0
  br i1 %.not49, label %.critedge, label %33

33:                                               ; preds = %31
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.1, ptr noundef nonnull @__FUNCTION__.QemuVideoBochsModeSetup) #3
  br label %.critedge

34:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  br label %39

35:                                               ; preds = %2
  %36 = tail call zeroext i16 @BochsRead(ptr noundef %0, i16 noundef zeroext 10) #3
  %37 = zext i16 %36 to i32
  %38 = shl nuw i32 %37, 16
  store i32 %38, ptr %3, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %34, %35
  %40 = call zeroext i8 @DebugPrintEnabled() #3
  %.not50 = icmp eq i8 %40, 0
  br i1 %.not50, label %45, label %41

41:                                               ; preds = %39
  %42 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 4194304) #3
  %.not51 = icmp eq i8 %42, 0
  br i1 %.not51, label %45, label %43

43:                                               ; preds = %41
  %44 = load i32, ptr %3, align 4, !tbaa !5
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 4194304, ptr noundef nonnull @.str.2, ptr noundef nonnull @__FUNCTION__.QemuVideoBochsModeSetup, i32 noundef %44) #3
  br label %45

45:                                               ; preds = %41, %43, %39
  %46 = call ptr @AllocatePool(i64 noundef 740) #3
  %47 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %46, ptr %47, align 8, !tbaa !17
  %48 = icmp eq ptr %46, null
  br i1 %48, label %102, label %.preheader

.preheader:                                       ; preds = %45, %92
  %.04458 = phi ptr [ %93, %92 ], [ @QemuVideoBochsModes, %45 ]
  %.04557 = phi ptr [ %.146, %92 ], [ %46, %45 ]
  %.04756 = phi i32 [ %94, %92 ], [ 0, %45 ]
  %49 = call zeroext i8 @DebugAssertEnabled() #3
  %.not52 = icmp eq i8 %49, 0
  br i1 %.not52, label %56, label %50

50:                                               ; preds = %.preheader
  %51 = getelementptr inbounds i8, ptr %.04458, i64 8
  %52 = load i32, ptr %51, align 4, !tbaa !18
  %53 = and i32 %52, 7
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %56, label %55

55:                                               ; preds = %50
  call void @DebugAssert(ptr noundef nonnull @.str.3, i64 noundef 325, ptr noundef nonnull @.str.4) #3
  br label %56

56:                                               ; preds = %50, %55, %.preheader
  %57 = load i32, ptr %.04458, align 4, !tbaa !20
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %.04458, i64 4
  %60 = load i32, ptr %59, align 4, !tbaa !21
  %61 = zext i32 %60 to i64
  %62 = mul nuw i64 %61, %58
  %63 = getelementptr inbounds i8, ptr %.04458, i64 8
  %64 = load i32, ptr %63, align 4, !tbaa !18
  %65 = lshr i32 %64, 3
  %66 = zext nneg i32 %65 to i64
  %67 = mul i64 %62, %66
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = zext i32 %68 to i64
  %.not53 = icmp ugt i64 %67, %69
  br i1 %.not53, label %92, label %70

70:                                               ; preds = %56
  store i32 %.04756, ptr %.04557, align 4, !tbaa !22
  %71 = getelementptr inbounds i8, ptr %.04557, i64 4
  store i32 %57, ptr %71, align 4, !tbaa !24
  %72 = getelementptr inbounds i8, ptr %.04557, i64 8
  store i32 %60, ptr %72, align 4, !tbaa !25
  %73 = getelementptr inbounds i8, ptr %.04557, i64 12
  store i32 %64, ptr %73, align 4, !tbaa !26
  %74 = getelementptr inbounds i8, ptr %.04557, i64 16
  store i32 60, ptr %74, align 4, !tbaa !27
  %75 = call zeroext i8 @DebugPrintEnabled() #3
  %.not54 = icmp eq i8 %75, 0
  br i1 %.not54, label %90, label %76

76:                                               ; preds = %70
  %77 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64) #3
  %.not55 = icmp eq i8 %77, 0
  br i1 %.not55, label %90, label %78

78:                                               ; preds = %76
  %79 = load ptr, ptr %47, align 8, !tbaa !17
  %80 = ptrtoint ptr %.04557 to i64
  %81 = ptrtoint ptr %79 to i64
  %82 = sub i64 %80, %81
  %83 = sdiv exact i64 %82, 20
  %84 = trunc i64 %83 to i32
  %85 = load i32, ptr %.04557, align 4, !tbaa !22
  %86 = load i32, ptr %71, align 4, !tbaa !24
  %87 = load i32, ptr %72, align 4, !tbaa !25
  %88 = load i32, ptr %73, align 4, !tbaa !26
  %89 = load i32, ptr %74, align 4, !tbaa !27
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 64, ptr noundef nonnull @.str.5, i32 noundef %84, i32 noundef %85, i32 noundef %86, i32 noundef %87, i32 noundef %88, i32 noundef %89) #3
  br label %90

90:                                               ; preds = %76, %78, %70
  %91 = getelementptr inbounds i8, ptr %.04557, i64 20
  br label %92

92:                                               ; preds = %90, %56
  %.146 = phi ptr [ %91, %90 ], [ %.04557, %56 ]
  %93 = getelementptr inbounds i8, ptr %.04458, i64 12
  %94 = add nuw nsw i32 %.04756, 1
  %exitcond.not = icmp eq i32 %94, 37
  br i1 %exitcond.not, label %95, label %.preheader, !llvm.loop !28

95:                                               ; preds = %92
  %96 = load ptr, ptr %47, align 8, !tbaa !17
  %97 = ptrtoint ptr %.146 to i64
  %98 = ptrtoint ptr %96 to i64
  %99 = sub i64 %97, %98
  %100 = sdiv exact i64 %99, 20
  %101 = getelementptr inbounds i8, ptr %0, i64 80
  store i64 %100, ptr %101, align 8, !tbaa !30
  br label %102

.critedge:                                        ; preds = %29, %33, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  br label %102

102:                                              ; preds = %45, %.critedge, %95
  %.1 = phi i64 [ 0, %95 ], [ -9223372036854775794, %.critedge ], [ -9223372036854775799, %45 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret i64 %.1
}

declare zeroext i16 @BochsRead(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 16}
!10 = !{!"", !11, i64 0, !12, i64 8, !12, i64 16, !11, i64 24, !13, i64 32, !12, i64 64, !11, i64 72, !11, i64 80, !12, i64 88, !12, i64 96, !6, i64 104}
!11 = !{!"long long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"_EFI_GRAPHICS_OUTPUT_PROTOCOL", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!14 = !{!15, !12, i64 16}
!15 = !{!"_EFI_PCI_IO_PROTOCOL", !12, i64 0, !12, i64 8, !16, i64 16, !16, i64 32, !16, i64 48, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !11, i64 144, !12, i64 152}
!16 = !{!"", !12, i64 0, !12, i64 8}
!17 = !{!10, !12, i64 88}
!18 = !{!19, !6, i64 8}
!19 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}
!20 = !{!19, !6, i64 0}
!21 = !{!19, !6, i64 4}
!22 = !{!23, !6, i64 0}
!23 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16}
!24 = !{!23, !6, i64 4}
!25 = !{!23, !6, i64 8}
!26 = !{!23, !6, i64 12}
!27 = !{!23, !6, i64 16}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!10, !11, i64 80}


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