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

; 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.GUID = type { i32, i16, i16, [8 x i8] }
%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_DRIVER_BINDING_PROTOCOL = type { ptr, ptr, ptr, i32, ptr, ptr }
%struct.PARTITION_PRIVATE_DATA = type { i64, ptr, ptr, %struct._EFI_BLOCK_IO_PROTOCOL, %struct._EFI_BLOCK_IO2_PROTOCOL, %struct.EFI_BLOCK_IO_MEDIA, %struct.EFI_BLOCK_IO_MEDIA, ptr, ptr, ptr, ptr, i64, i64, i32, ptr }
%struct._EFI_BLOCK_IO_PROTOCOL = type { i64, ptr, ptr, ptr, ptr, ptr }
%struct._EFI_BLOCK_IO2_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr }
%struct.EFI_BLOCK_IO_MEDIA = type { i32, i8, i8, i8, i8, i8, i32, i32, i64, i64, i32, i32 }

@gBS = external global ptr, align 8
@gEfiDiskIoProtocolGuid = external global %struct.GUID, align 4
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@gEfiBlockIoProtocolGuid = external global %struct.GUID, align 4
@gEfiBlockIo2ProtocolGuid = external global %struct.GUID, align 4
@gEfiDiskIo2ProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

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

20:                                               ; preds = %4
  %21 = load ptr, ptr @gBS, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %21, i32 0, i32 34
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %25, i32 0, i32 5
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = call i64 %23(ptr noundef %24, ptr noundef @gEfiDiskIoProtocolGuid, ptr noundef %27, ptr noundef %28)
  %30 = load ptr, ptr @gBS, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %30, i32 0, i32 34
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %34, i32 0, i32 5
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = call i64 %32(ptr noundef %33, ptr noundef @gEfiDiskIo2ProtocolGuid, ptr noundef %36, ptr noundef %37)
  %39 = load ptr, ptr @gBS, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %39, i32 0, i32 34
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %43, i32 0, i32 5
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call i64 %41(ptr noundef %42, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %45, ptr noundef %46)
  store i64 0, ptr %5, align 8
  store i32 1, ptr %17, align 4
  br label %197

48:                                               ; preds = %4
  store i8 1, ptr %14, align 1, !tbaa !17
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %189, %48
  %50 = load i64, ptr %11, align 8, !tbaa !9
  %51 = load i64, ptr %8, align 8, !tbaa !9
  %52 = icmp ult i64 %50, %51
  br i1 %52, label %53, label %192

53:                                               ; preds = %49
  %54 = load ptr, ptr @gBS, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %54, i32 0, i32 33
  %56 = load ptr, ptr %55, align 8, !tbaa !18
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = load i64, ptr %11, align 8, !tbaa !9
  %59 = getelementptr inbounds ptr, ptr %57, i64 %58
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %61, i32 0, i32 5
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = call i64 %56(ptr noundef %60, ptr noundef @gEfiBlockIoProtocolGuid, ptr noundef %12, ptr noundef %63, ptr noundef %64, i32 noundef 2)
  %66 = load ptr, ptr @gBS, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %66, i32 0, i32 33
  %68 = load ptr, ptr %67, align 8, !tbaa !18
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load i64, ptr %11, align 8, !tbaa !9
  %71 = getelementptr inbounds ptr, ptr %69, i64 %70
  %72 = load ptr, ptr %71, align 8, !tbaa !5
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %73, i32 0, i32 5
  %75 = load ptr, ptr %74, align 8, !tbaa !15
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = call i64 %68(ptr noundef %72, ptr noundef @gEfiBlockIo2ProtocolGuid, ptr noundef %13, ptr noundef %75, ptr noundef %76, i32 noundef 2)
  %78 = call zeroext i8 @DebugAssertEnabled()
  %79 = zext i8 %78 to i32
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %91

81:                                               ; preds = %53
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = ptrtoint ptr %82 to i64
  %84 = sub i64 %83, ptrtoint (ptr getelementptr inbounds (%struct.PARTITION_PRIVATE_DATA, ptr null, i32 0, i32 3) to i64)
  %85 = inttoptr i64 %84 to ptr
  %86 = getelementptr inbounds %struct.PARTITION_PRIVATE_DATA, ptr %85, i32 0, i32 0
  %87 = load i64, ptr %86, align 8, !tbaa !19
  %88 = icmp ne i64 %87, 1953653072
  br i1 %88, label %89, label %91

89:                                               ; preds = %81
  call void @DebugAssert(ptr noundef @.str, i64 noundef 522, ptr noundef @.str.1)
  %90 = load ptr, ptr %12, align 8, !tbaa !5
  br label %96

91:                                               ; preds = %81, %53
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = ptrtoint ptr %92 to i64
  %94 = sub i64 %93, ptrtoint (ptr getelementptr inbounds (%struct.PARTITION_PRIVATE_DATA, ptr null, i32 0, i32 3) to i64)
  %95 = inttoptr i64 %94 to ptr
  br label %96

96:                                               ; preds = %91, %89
  %97 = phi ptr [ %90, %89 ], [ %95, %91 ]
  store ptr %97, ptr %15, align 8, !tbaa !5
  %98 = load ptr, ptr @gBS, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %98, i32 0, i32 34
  %100 = load ptr, ptr %99, align 8, !tbaa !11
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %102, i32 0, i32 5
  %104 = load ptr, ptr %103, align 8, !tbaa !15
  %105 = load ptr, ptr %9, align 8, !tbaa !5
  %106 = load i64, ptr %11, align 8, !tbaa !9
  %107 = getelementptr inbounds ptr, ptr %105, i64 %106
  %108 = load ptr, ptr %107, align 8, !tbaa !5
  %109 = call i64 %100(ptr noundef %101, ptr noundef @gEfiDiskIoProtocolGuid, ptr noundef %104, ptr noundef %108)
  store i64 %109, ptr %10, align 8, !tbaa !9
  %110 = load ptr, ptr %13, align 8, !tbaa !5
  %111 = icmp ne ptr %110, null
  br i1 %111, label %112, label %141

112:                                              ; preds = %96
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct._EFI_BLOCK_IO_PROTOCOL, ptr %113, i32 0, i32 5
  %115 = load ptr, ptr %114, align 8, !tbaa !24
  %116 = load ptr, ptr %12, align 8, !tbaa !5
  %117 = call i64 %115(ptr noundef %116)
  %118 = load ptr, ptr %13, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct._EFI_BLOCK_IO2_PROTOCOL, ptr %118, i32 0, i32 4
  %120 = load ptr, ptr %119, align 8, !tbaa !25
  %121 = load ptr, ptr %13, align 8, !tbaa !5
  %122 = call i64 %120(ptr noundef %121, ptr noundef null)
  %123 = load ptr, ptr @gBS, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %123, i32 0, i32 40
  %125 = load ptr, ptr %124, align 8, !tbaa !26
  %126 = load ptr, ptr %9, align 8, !tbaa !5
  %127 = load i64, ptr %11, align 8, !tbaa !9
  %128 = getelementptr inbounds ptr, ptr %126, i64 %127
  %129 = load ptr, ptr %128, align 8, !tbaa !5
  %130 = load ptr, ptr %15, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.PARTITION_PRIVATE_DATA, ptr %130, i32 0, i32 2
  %132 = load ptr, ptr %131, align 8, !tbaa !27
  %133 = load ptr, ptr %15, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.PARTITION_PRIVATE_DATA, ptr %133, i32 0, i32 3
  %135 = load ptr, ptr %15, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.PARTITION_PRIVATE_DATA, ptr %135, i32 0, i32 4
  %137 = load ptr, ptr %15, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.PARTITION_PRIVATE_DATA, ptr %137, i32 0, i32 14
  %139 = load ptr, ptr %138, align 8, !tbaa !28
  %140 = call i64 (ptr, ...) %125(ptr noundef %129, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %132, ptr noundef @gEfiBlockIoProtocolGuid, ptr noundef %134, ptr noundef @gEfiBlockIo2ProtocolGuid, ptr noundef %136, ptr noundef %139, ptr noundef null, ptr noundef null)
  store i64 %140, ptr %10, align 8, !tbaa !9
  br label %163

141:                                              ; preds = %96
  %142 = load ptr, ptr %12, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct._EFI_BLOCK_IO_PROTOCOL, ptr %142, i32 0, i32 5
  %144 = load ptr, ptr %143, align 8, !tbaa !24
  %145 = load ptr, ptr %12, align 8, !tbaa !5
  %146 = call i64 %144(ptr noundef %145)
  %147 = load ptr, ptr @gBS, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %147, i32 0, i32 40
  %149 = load ptr, ptr %148, align 8, !tbaa !26
  %150 = load ptr, ptr %9, align 8, !tbaa !5
  %151 = load i64, ptr %11, align 8, !tbaa !9
  %152 = getelementptr inbounds ptr, ptr %150, i64 %151
  %153 = load ptr, ptr %152, align 8, !tbaa !5
  %154 = load ptr, ptr %15, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.PARTITION_PRIVATE_DATA, ptr %154, i32 0, i32 2
  %156 = load ptr, ptr %155, align 8, !tbaa !27
  %157 = load ptr, ptr %15, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.PARTITION_PRIVATE_DATA, ptr %157, i32 0, i32 3
  %159 = load ptr, ptr %15, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.PARTITION_PRIVATE_DATA, ptr %159, i32 0, i32 14
  %161 = load ptr, ptr %160, align 8, !tbaa !28
  %162 = call i64 (ptr, ...) %149(ptr noundef %153, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %156, ptr noundef @gEfiBlockIoProtocolGuid, ptr noundef %158, ptr noundef %161, ptr noundef null, ptr noundef null)
  store i64 %162, ptr %10, align 8, !tbaa !9
  br label %163

163:                                              ; preds = %141, %112
  %164 = load i64, ptr %10, align 8, !tbaa !9
  %165 = icmp slt i64 %164, 0
  br i1 %165, label %166, label %179

166:                                              ; preds = %163
  %167 = load ptr, ptr @gBS, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %167, i32 0, i32 33
  %169 = load ptr, ptr %168, align 8, !tbaa !18
  %170 = load ptr, ptr %7, align 8, !tbaa !5
  %171 = load ptr, ptr %6, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %171, i32 0, i32 5
  %173 = load ptr, ptr %172, align 8, !tbaa !15
  %174 = load ptr, ptr %9, align 8, !tbaa !5
  %175 = load i64, ptr %11, align 8, !tbaa !9
  %176 = getelementptr inbounds ptr, ptr %174, i64 %175
  %177 = load ptr, ptr %176, align 8, !tbaa !5
  %178 = call i64 %169(ptr noundef %170, ptr noundef @gEfiDiskIoProtocolGuid, ptr noundef %16, ptr noundef %173, ptr noundef %177, i32 noundef 8)
  br label %184

179:                                              ; preds = %163
  %180 = load ptr, ptr %15, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.PARTITION_PRIVATE_DATA, ptr %180, i32 0, i32 2
  %182 = load ptr, ptr %181, align 8, !tbaa !27
  call void @FreePool(ptr noundef %182)
  %183 = load ptr, ptr %15, align 8, !tbaa !5
  call void @FreePool(ptr noundef %183)
  br label %184

184:                                              ; preds = %179, %166
  %185 = load i64, ptr %10, align 8, !tbaa !9
  %186 = icmp slt i64 %185, 0
  br i1 %186, label %187, label %188

187:                                              ; preds = %184
  store i8 0, ptr %14, align 1, !tbaa !17
  br label %188

188:                                              ; preds = %187, %184
  br label %189

189:                                              ; preds = %188
  %190 = load i64, ptr %11, align 8, !tbaa !9
  %191 = add i64 %190, 1
  store i64 %191, ptr %11, align 8, !tbaa !9
  br label %49, !llvm.loop !29

192:                                              ; preds = %49
  %193 = load i8, ptr %14, align 1, !tbaa !17
  %194 = icmp ne i8 %193, 0
  br i1 %194, label %196, label %195

195:                                              ; preds = %192
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %17, align 4
  br label %197

196:                                              ; preds = %192
  store i64 0, ptr %5, align 8
  store i32 1, ptr %17, align 4
  br label %197

197:                                              ; preds = %196, %195, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %198 = load i64, ptr %5, align 8
  ret i64 %198
}

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

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

declare zeroext i8 @DebugAssertEnabled() #2

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

declare void @FreePool(ptr noundef) #2

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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 288}
!12 = !{!"", !13, 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}
!13 = !{!"", !10, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !6, i64 40}
!16 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!7, !7, i64 0}
!18 = !{!12, !6, i64 280}
!19 = !{!20, !10, i64 0}
!20 = !{!"", !10, i64 0, !6, i64 8, !6, i64 16, !21, i64 24, !22, i64 72, !23, i64 112, !23, i64 160, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !10, i64 240, !10, i64 248, !14, i64 256, !6, i64 264}
!21 = !{!"_EFI_BLOCK_IO_PROTOCOL", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!22 = !{!"_EFI_BLOCK_IO2_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!23 = !{!"", !14, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !14, i64 12, !14, i64 16, !10, i64 24, !10, i64 32, !14, i64 40, !14, i64 44}
!24 = !{!21, !6, i64 40}
!25 = !{!22, !6, i64 32}
!26 = !{!12, !6, i64 336}
!27 = !{!20, !6, i64 16}
!28 = !{!20, !6, i64 264}
!29 = distinct !{!29, !30}
!30 = !{!"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"

%struct.GUID = type { i32, i16, i16, [8 x i8] }

@gBS = external local_unnamed_addr global ptr, align 8
@gEfiDiskIoProtocolGuid = external global %struct.GUID, align 4
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@gEfiBlockIoProtocolGuid = external global %struct.GUID, align 4
@gEfiBlockIo2ProtocolGuid = external global %struct.GUID, align 4
@gEfiDiskIo2ProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775801, 1) i64 @PartitionDriverBindingStop(ptr nocapture noundef readonly %0, ptr noundef %1, i64 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i64 %2, 0
  br i1 %8, label %10, label %.preheader

.preheader:                                       ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  br label %27

10:                                               ; preds = %4
  %11 = load ptr, ptr @gBS, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 288
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = tail call i64 %13(ptr noundef %1, ptr noundef nonnull @gEfiDiskIoProtocolGuid, ptr noundef %15, ptr noundef %1) #3
  %17 = load ptr, ptr @gBS, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 288
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %14, align 8, !tbaa !14
  %21 = tail call i64 %19(ptr noundef %1, ptr noundef nonnull @gEfiDiskIo2ProtocolGuid, ptr noundef %20, ptr noundef %1) #3
  %22 = load ptr, ptr @gBS, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 288
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %14, align 8, !tbaa !14
  %26 = tail call i64 %24(ptr noundef %1, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef %25, ptr noundef %1) #3
  br label %100

27:                                               ; preds = %.preheader, %97
  %.053 = phi i8 [ 1, %.preheader ], [ %spec.select, %97 ]
  %.04552 = phi i64 [ 0, %.preheader ], [ %98, %97 ]
  %28 = load ptr, ptr @gBS, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 280
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = getelementptr inbounds ptr, ptr %3, i64 %.04552
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !14
  %34 = call i64 %30(ptr noundef %32, ptr noundef nonnull @gEfiBlockIoProtocolGuid, ptr noundef nonnull %5, ptr noundef %33, ptr noundef %1, i32 noundef 2) #3
  %35 = load ptr, ptr @gBS, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 280
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = load ptr, ptr %31, align 8, !tbaa !5
  %39 = load ptr, ptr %9, align 8, !tbaa !14
  %40 = call i64 %37(ptr noundef %38, ptr noundef nonnull @gEfiBlockIo2ProtocolGuid, ptr noundef nonnull %6, ptr noundef %39, ptr noundef %1, i32 noundef 2) #3
  %41 = call zeroext i8 @DebugAssertEnabled() #3
  %.not49 = icmp eq i8 %41, 0
  %.pre = load ptr, ptr %5, align 8, !tbaa !5
  %.pre54 = ptrtoint ptr %.pre to i64
  %.pre55 = add i64 %.pre54, -24
  %.pre57 = inttoptr i64 %.pre55 to ptr
  br i1 %.not49, label %._crit_edge, label %42

42:                                               ; preds = %27
  %43 = load i64, ptr %.pre57, align 8, !tbaa !17
  %.not50 = icmp eq i64 %43, 1953653072
  br i1 %.not50, label %._crit_edge, label %44

44:                                               ; preds = %42
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 522, ptr noundef nonnull @.str.1) #3
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %27, %42, %44
  %46 = phi ptr [ %45, %44 ], [ %.pre57, %42 ], [ %.pre57, %27 ]
  %47 = load ptr, ptr @gBS, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i64 288
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = load ptr, ptr %9, align 8, !tbaa !14
  %51 = load ptr, ptr %31, align 8, !tbaa !5
  %52 = call i64 %49(ptr noundef %1, ptr noundef nonnull @gEfiDiskIoProtocolGuid, ptr noundef %50, ptr noundef %51) #3
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %.not51 = icmp eq ptr %53, null
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 40
  %56 = load ptr, ptr %55, align 8, !tbaa !22
  %57 = call i64 %56(ptr noundef %54) #3
  br i1 %.not51, label %74, label %58

58:                                               ; preds = %._crit_edge
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %59, i64 32
  %61 = load ptr, ptr %60, align 8, !tbaa !23
  %62 = call i64 %61(ptr noundef %59, ptr noundef null) #3
  %63 = load ptr, ptr @gBS, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 336
  %65 = load ptr, ptr %64, align 8, !tbaa !24
  %66 = load ptr, ptr %31, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %46, i64 16
  %68 = load ptr, ptr %67, align 8, !tbaa !25
  %69 = getelementptr inbounds i8, ptr %46, i64 24
  %70 = getelementptr inbounds i8, ptr %46, i64 72
  %71 = getelementptr inbounds i8, ptr %46, i64 264
  %72 = load ptr, ptr %71, align 8, !tbaa !26
  %73 = call i64 (ptr, ...) %65(ptr noundef %66, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef %68, ptr noundef nonnull @gEfiBlockIoProtocolGuid, ptr noundef nonnull %69, ptr noundef nonnull @gEfiBlockIo2ProtocolGuid, ptr noundef nonnull %70, ptr noundef %72, ptr noundef null, ptr noundef null) #3
  br label %85

74:                                               ; preds = %._crit_edge
  %75 = load ptr, ptr @gBS, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %75, i64 336
  %77 = load ptr, ptr %76, align 8, !tbaa !24
  %78 = load ptr, ptr %31, align 8, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %46, i64 16
  %80 = load ptr, ptr %79, align 8, !tbaa !25
  %81 = getelementptr inbounds i8, ptr %46, i64 24
  %82 = getelementptr inbounds i8, ptr %46, i64 264
  %83 = load ptr, ptr %82, align 8, !tbaa !26
  %84 = call i64 (ptr, ...) %77(ptr noundef %78, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef %80, ptr noundef nonnull @gEfiBlockIoProtocolGuid, ptr noundef nonnull %81, ptr noundef %83, ptr noundef null, ptr noundef null) #3
  br label %85

85:                                               ; preds = %74, %58
  %.046 = phi i64 [ %73, %58 ], [ %84, %74 ]
  %86 = icmp slt i64 %.046, 0
  br i1 %86, label %87, label %94

87:                                               ; preds = %85
  %88 = load ptr, ptr @gBS, align 8, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %88, i64 280
  %90 = load ptr, ptr %89, align 8, !tbaa !16
  %91 = load ptr, ptr %9, align 8, !tbaa !14
  %92 = load ptr, ptr %31, align 8, !tbaa !5
  %93 = call i64 %90(ptr noundef %1, ptr noundef nonnull @gEfiDiskIoProtocolGuid, ptr noundef nonnull %7, ptr noundef %91, ptr noundef %92, i32 noundef 8) #3
  br label %97

94:                                               ; preds = %85
  %95 = getelementptr inbounds i8, ptr %46, i64 16
  %96 = load ptr, ptr %95, align 8, !tbaa !25
  call void @FreePool(ptr noundef %96) #3
  call void @FreePool(ptr noundef nonnull %46) #3
  br label %97

97:                                               ; preds = %94, %87
  %spec.select = phi i8 [ %.053, %94 ], [ 0, %87 ]
  %98 = add nuw i64 %.04552, 1
  %exitcond.not = icmp eq i64 %98, %2
  br i1 %exitcond.not, label %99, label %27, !llvm.loop !27

99:                                               ; preds = %97
  %.not = icmp eq i8 %spec.select, 0
  %. = select i1 %.not, i64 -9223372036854775801, i64 0
  br label %100

100:                                              ; preds = %99, %10
  %.047 = phi i64 [ 0, %10 ], [ %., %99 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret i64 %.047
}

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

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

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

declare void @FreePool(ptr noundef) local_unnamed_addr #2

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 = { mustprogress 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 = !{!10, !6, i64 288}
!10 = !{!"", !11, 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}
!11 = !{!"", !12, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 40}
!15 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40}
!16 = !{!10, !6, i64 280}
!17 = !{!18, !12, i64 0}
!18 = !{!"", !12, i64 0, !6, i64 8, !6, i64 16, !19, i64 24, !20, i64 72, !21, i64 112, !21, i64 160, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !12, i64 240, !12, i64 248, !13, i64 256, !6, i64 264}
!19 = !{!"_EFI_BLOCK_IO_PROTOCOL", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!20 = !{!"_EFI_BLOCK_IO2_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!21 = !{!"", !13, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !13, i64 12, !13, i64 16, !12, i64 24, !12, i64 32, !13, i64 40, !13, i64 44}
!22 = !{!19, !6, i64 40}
!23 = !{!20, !6, i64 32}
!24 = !{!10, !6, i64 336}
!25 = !{!18, !6, i64 16}
!26 = !{!18, !6, i64 264}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


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