; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe (IScsiUnload)

; 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._EFI_DRIVER_BINDING_PROTOCOL = type { ptr, ptr, ptr, i32, ptr, ptr }
%struct.GUID = type { i32, i16, i16, [8 x i8] }
%struct._EFI_AUTHENTICATION_INFO_PROTOCOL = type { ptr, ptr }
%struct._EFI_ISCSI_INITIATOR_NAME_PROTOCOL = type { ptr, ptr }
%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 }

@gIScsiIp4DriverBinding = external dso_local global %struct._EFI_DRIVER_BINDING_PROTOCOL, align 8
@gIScsiIp6DriverBinding = external dso_local global %struct._EFI_DRIVER_BINDING_PROTOCOL, align 8
@gBS = external global ptr, align 8
@gEfiTcp4ProtocolGuid = external global %struct.GUID, align 4
@gEfiTcp6ProtocolGuid = external global %struct.GUID, align 4
@gEfiIScsiInitiatorNameProtocolGuid = external global %struct.GUID, align 4
@gEfiAuthenticationInfoProtocolGuid = external global %struct.GUID, align 4
@gIScsiAuthenticationInfo = external global %struct._EFI_AUTHENTICATION_INFO_PROTOCOL, align 8
@gIScsiControllerNameTable = external global ptr, align 8
@gEfiComponentNameProtocolGuid = external global %struct.GUID, align 4
@gEfiComponentName2ProtocolGuid = external global %struct.GUID, align 4
@gEfiDriverBindingProtocolGuid = external global %struct.GUID, align 4
@gIScsiInitiatorName = external global %struct._EFI_ISCSI_INITIATOR_NAME_PROTOCOL, align 8

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

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

declare void @FreePool(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @IScsiUnload(ptr noundef %0) #2 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, 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
  %11 = load ptr, ptr @gBS, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %11, i32 0, i32 37
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = call i64 %13(i32 noundef 0, ptr noundef null, ptr noundef null, ptr noundef %5, ptr noundef %6)
  store i64 %14, ptr %4, align 8, !tbaa !14
  %15 = load i64, ptr %4, align 8, !tbaa !14
  %16 = icmp slt i64 %15, 0
  br i1 %16, label %17, label %19

17:                                               ; preds = %1
  %18 = load i64, ptr %4, align 8, !tbaa !14
  store i64 %18, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %206

19:                                               ; preds = %1
  store i64 0, ptr %7, align 8, !tbaa !14
  br label %20

20:                                               ; preds = %48, %19
  %21 = load i64, ptr %7, align 8, !tbaa !14
  %22 = load i64, ptr %5, align 8, !tbaa !14
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %24, label %51

24:                                               ; preds = %20
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i64, ptr %7, align 8, !tbaa !14
  %27 = getelementptr inbounds ptr, ptr %25, i64 %26
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp4DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %30 = call i64 @IScsiTestManagedDevice(ptr noundef %28, ptr noundef %29, ptr noundef @gEfiTcp4ProtocolGuid)
  store i64 %30, ptr %4, align 8, !tbaa !14
  %31 = load i64, ptr %4, align 8, !tbaa !14
  %32 = icmp slt i64 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %24
  br label %48

34:                                               ; preds = %24
  %35 = load ptr, ptr @gBS, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %35, i32 0, i32 32
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i64, ptr %7, align 8, !tbaa !14
  %40 = getelementptr inbounds ptr, ptr %38, i64 %39
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp4DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %43 = call i64 %37(ptr noundef %41, ptr noundef %42, ptr noundef null)
  store i64 %43, ptr %4, align 8, !tbaa !14
  %44 = load i64, ptr %4, align 8, !tbaa !14
  %45 = icmp slt i64 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %34
  br label %199

47:                                               ; preds = %34
  br label %48

48:                                               ; preds = %47, %33
  %49 = load i64, ptr %7, align 8, !tbaa !14
  %50 = add i64 %49, 1
  store i64 %50, ptr %7, align 8, !tbaa !14
  br label %20, !llvm.loop !18

51:                                               ; preds = %20
  store i64 0, ptr %7, align 8, !tbaa !14
  br label %52

52:                                               ; preds = %80, %51
  %53 = load i64, ptr %7, align 8, !tbaa !14
  %54 = load i64, ptr %5, align 8, !tbaa !14
  %55 = icmp ult i64 %53, %54
  br i1 %55, label %56, label %83

56:                                               ; preds = %52
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i64, ptr %7, align 8, !tbaa !14
  %59 = getelementptr inbounds ptr, ptr %57, i64 %58
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp6DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %62 = call i64 @IScsiTestManagedDevice(ptr noundef %60, ptr noundef %61, ptr noundef @gEfiTcp6ProtocolGuid)
  store i64 %62, ptr %4, align 8, !tbaa !14
  %63 = load i64, ptr %4, align 8, !tbaa !14
  %64 = icmp slt i64 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %56
  br label %80

66:                                               ; preds = %56
  %67 = load ptr, ptr @gBS, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %67, i32 0, i32 32
  %69 = load ptr, ptr %68, align 8, !tbaa !17
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = load i64, ptr %7, align 8, !tbaa !14
  %72 = getelementptr inbounds ptr, ptr %70, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp6DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %75 = call i64 %69(ptr noundef %73, ptr noundef %74, ptr noundef null)
  store i64 %75, ptr %4, align 8, !tbaa !14
  %76 = load i64, ptr %4, align 8, !tbaa !14
  %77 = icmp slt i64 %76, 0
  br i1 %77, label %78, label %79

78:                                               ; preds = %66
  br label %199

79:                                               ; preds = %66
  br label %80

80:                                               ; preds = %79, %65
  %81 = load i64, ptr %7, align 8, !tbaa !14
  %82 = add i64 %81, 1
  store i64 %82, ptr %7, align 8, !tbaa !14
  br label %52, !llvm.loop !20

83:                                               ; preds = %52
  %84 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp4DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %85 = call i64 @IScsiConfigFormUnload(ptr noundef %84)
  store i64 %85, ptr %4, align 8, !tbaa !14
  %86 = load i64, ptr %4, align 8, !tbaa !14
  %87 = icmp slt i64 %86, 0
  br i1 %87, label %88, label %89

88:                                               ; preds = %83
  br label %199

89:                                               ; preds = %83
  %90 = load ptr, ptr @gBS, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %90, i32 0, i32 40
  %92 = load ptr, ptr %91, align 8, !tbaa !21
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = call i64 (ptr, ...) %92(ptr noundef %93, ptr noundef @gEfiAuthenticationInfoProtocolGuid, ptr noundef @gIScsiAuthenticationInfo, ptr noundef null)
  store i64 %94, ptr %4, align 8, !tbaa !14
  %95 = load i64, ptr %4, align 8, !tbaa !14
  %96 = icmp slt i64 %95, 0
  br i1 %96, label %97, label %98

97:                                               ; preds = %89
  br label %199

98:                                               ; preds = %89
  %99 = load ptr, ptr @gIScsiControllerNameTable, align 8, !tbaa !5
  %100 = icmp ne ptr %99, null
  br i1 %100, label %101, label %108

101:                                              ; preds = %98
  %102 = load ptr, ptr @gIScsiControllerNameTable, align 8, !tbaa !5
  %103 = call i64 @FreeUnicodeStringTable(ptr noundef %102)
  store i64 %103, ptr %4, align 8, !tbaa !14
  %104 = load i64, ptr %4, align 8, !tbaa !14
  %105 = icmp slt i64 %104, 0
  br i1 %105, label %106, label %107

106:                                              ; preds = %101
  br label %199

107:                                              ; preds = %101
  store ptr null, ptr @gIScsiControllerNameTable, align 8, !tbaa !5
  br label %108

108:                                              ; preds = %107, %98
  %109 = load ptr, ptr @gBS, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %109, i32 0, i32 17
  %111 = load ptr, ptr %110, align 8, !tbaa !22
  %112 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp4DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %113 = call i64 %111(ptr noundef %112, ptr noundef @gEfiComponentNameProtocolGuid, ptr noundef %8)
  store i64 %113, ptr %4, align 8, !tbaa !14
  %114 = load i64, ptr %4, align 8, !tbaa !14
  %115 = icmp slt i64 %114, 0
  br i1 %115, label %127, label %116

116:                                              ; preds = %108
  %117 = load ptr, ptr @gBS, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %117, i32 0, i32 40
  %119 = load ptr, ptr %118, align 8, !tbaa !21
  %120 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp4DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %121 = load ptr, ptr %8, align 8, !tbaa !5
  %122 = call i64 (ptr, ...) %119(ptr noundef %120, ptr noundef @gEfiComponentNameProtocolGuid, ptr noundef %121, ptr noundef null)
  store i64 %122, ptr %4, align 8, !tbaa !14
  %123 = load i64, ptr %4, align 8, !tbaa !14
  %124 = icmp slt i64 %123, 0
  br i1 %124, label %125, label %126

125:                                              ; preds = %116
  br label %199

126:                                              ; preds = %116
  br label %127

127:                                              ; preds = %126, %108
  %128 = load ptr, ptr @gBS, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %128, i32 0, i32 17
  %130 = load ptr, ptr %129, align 8, !tbaa !22
  %131 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp4DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %132 = call i64 %130(ptr noundef %131, ptr noundef @gEfiComponentName2ProtocolGuid, ptr noundef %9)
  store i64 %132, ptr %4, align 8, !tbaa !14
  %133 = load i64, ptr %4, align 8, !tbaa !14
  %134 = icmp slt i64 %133, 0
  br i1 %134, label %146, label %135

135:                                              ; preds = %127
  %136 = load ptr, ptr @gBS, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %136, i32 0, i32 40
  %138 = load ptr, ptr %137, align 8, !tbaa !21
  %139 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp4DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %140 = load ptr, ptr %9, align 8, !tbaa !5
  %141 = call i64 (ptr, ...) %138(ptr noundef %139, ptr noundef @gEfiComponentName2ProtocolGuid, ptr noundef %140, ptr noundef null)
  %142 = load i64, ptr %4, align 8, !tbaa !14
  %143 = icmp slt i64 %142, 0
  br i1 %143, label %144, label %145

144:                                              ; preds = %135
  br label %199

145:                                              ; preds = %135
  br label %146

146:                                              ; preds = %145, %127
  %147 = load ptr, ptr @gBS, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %147, i32 0, i32 17
  %149 = load ptr, ptr %148, align 8, !tbaa !22
  %150 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp6DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %151 = call i64 %149(ptr noundef %150, ptr noundef @gEfiComponentNameProtocolGuid, ptr noundef %8)
  store i64 %151, ptr %4, align 8, !tbaa !14
  %152 = load i64, ptr %4, align 8, !tbaa !14
  %153 = icmp slt i64 %152, 0
  br i1 %153, label %165, label %154

154:                                              ; preds = %146
  %155 = load ptr, ptr @gBS, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %155, i32 0, i32 40
  %157 = load ptr, ptr %156, align 8, !tbaa !21
  %158 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp6DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %159 = load ptr, ptr %8, align 8, !tbaa !5
  %160 = call i64 (ptr, ...) %157(ptr noundef %158, ptr noundef @gEfiComponentNameProtocolGuid, ptr noundef %159, ptr noundef null)
  store i64 %160, ptr %4, align 8, !tbaa !14
  %161 = load i64, ptr %4, align 8, !tbaa !14
  %162 = icmp slt i64 %161, 0
  br i1 %162, label %163, label %164

163:                                              ; preds = %154
  br label %199

164:                                              ; preds = %154
  br label %165

165:                                              ; preds = %164, %146
  %166 = load ptr, ptr @gBS, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %166, i32 0, i32 17
  %168 = load ptr, ptr %167, align 8, !tbaa !22
  %169 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp6DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %170 = call i64 %168(ptr noundef %169, ptr noundef @gEfiComponentName2ProtocolGuid, ptr noundef %9)
  store i64 %170, ptr %4, align 8, !tbaa !14
  %171 = load i64, ptr %4, align 8, !tbaa !14
  %172 = icmp slt i64 %171, 0
  br i1 %172, label %184, label %173

173:                                              ; preds = %165
  %174 = load ptr, ptr @gBS, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %174, i32 0, i32 40
  %176 = load ptr, ptr %175, align 8, !tbaa !21
  %177 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp6DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %178 = load ptr, ptr %9, align 8, !tbaa !5
  %179 = call i64 (ptr, ...) %176(ptr noundef %177, ptr noundef @gEfiComponentName2ProtocolGuid, ptr noundef %178, ptr noundef null)
  %180 = load i64, ptr %4, align 8, !tbaa !14
  %181 = icmp slt i64 %180, 0
  br i1 %181, label %182, label %183

182:                                              ; preds = %173
  br label %199

183:                                              ; preds = %173
  br label %184

184:                                              ; preds = %183, %165
  %185 = load ptr, ptr @gBS, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %185, i32 0, i32 40
  %187 = load ptr, ptr %186, align 8, !tbaa !21
  %188 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp4DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %189 = call i64 (ptr, ...) %187(ptr noundef %188, ptr noundef @gEfiDriverBindingProtocolGuid, ptr noundef @gIScsiIp4DriverBinding, ptr noundef @gEfiIScsiInitiatorNameProtocolGuid, ptr noundef @gIScsiInitiatorName, ptr noundef null)
  store i64 %189, ptr %4, align 8, !tbaa !14
  %190 = load i64, ptr %4, align 8, !tbaa !14
  %191 = icmp slt i64 %190, 0
  br i1 %191, label %192, label %193

192:                                              ; preds = %184
  br label %199

193:                                              ; preds = %184
  %194 = load ptr, ptr @gBS, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %194, i32 0, i32 40
  %196 = load ptr, ptr %195, align 8, !tbaa !21
  %197 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gIScsiIp6DriverBinding, i32 0, i32 5), align 8, !tbaa !15
  %198 = call i64 (ptr, ...) %196(ptr noundef %197, ptr noundef @gEfiDriverBindingProtocolGuid, ptr noundef @gIScsiIp6DriverBinding, ptr noundef null)
  store i64 %198, ptr %4, align 8, !tbaa !14
  br label %199

199:                                              ; preds = %193, %192, %182, %163, %144, %125, %106, %97, %88, %78, %46
  %200 = load ptr, ptr %6, align 8, !tbaa !5
  %201 = icmp ne ptr %200, null
  br i1 %201, label %202, label %204

202:                                              ; preds = %199
  %203 = load ptr, ptr %6, align 8, !tbaa !5
  call void @FreePool(ptr noundef %203)
  br label %204

204:                                              ; preds = %202, %199
  %205 = load i64, ptr %4, align 8, !tbaa !14
  store i64 %205, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %206

206:                                              ; preds = %204, %17
  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 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %207 = load i64, ptr %2, align 8
  ret i64 %207
}

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

declare i64 @IScsiConfigFormUnload(ptr noundef) #1

declare i64 @FreeUnicodeStringTable(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, !6, i64 312}
!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 = !{!12, !12, i64 0}
!15 = !{!16, !6, i64 40}
!16 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!10, !6, i64 272}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!10, !6, i64 336}
!22 = !{!10, !6, i64 152}


; 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._EFI_DRIVER_BINDING_PROTOCOL = type { ptr, ptr, ptr, i32, ptr, ptr }
%struct.GUID = type { i32, i16, i16, [8 x i8] }
%struct._EFI_AUTHENTICATION_INFO_PROTOCOL = type { ptr, ptr }
%struct._EFI_ISCSI_INITIATOR_NAME_PROTOCOL = type { ptr, ptr }

@gIScsiIp4DriverBinding = external dso_local global %struct._EFI_DRIVER_BINDING_PROTOCOL, align 8
@gIScsiIp6DriverBinding = external dso_local global %struct._EFI_DRIVER_BINDING_PROTOCOL, align 8
@gBS = external local_unnamed_addr global ptr, align 8
@gEfiTcp4ProtocolGuid = external global %struct.GUID, align 4
@gEfiTcp6ProtocolGuid = external global %struct.GUID, align 4
@gEfiIScsiInitiatorNameProtocolGuid = external global %struct.GUID, align 4
@gEfiAuthenticationInfoProtocolGuid = external global %struct.GUID, align 4
@gIScsiAuthenticationInfo = external global %struct._EFI_AUTHENTICATION_INFO_PROTOCOL, align 8
@gIScsiControllerNameTable = external local_unnamed_addr global ptr, align 8
@gEfiComponentNameProtocolGuid = external global %struct.GUID, align 4
@gEfiComponentName2ProtocolGuid = external global %struct.GUID, align 4
@gEfiDriverBindingProtocolGuid = external global %struct.GUID, align 4
@gIScsiInitiatorName = external global %struct._EFI_ISCSI_INITIATOR_NAME_PROTOCOL, align 8

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

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

declare void @FreePool(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @IScsiUnload(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = load ptr, ptr @gBS, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 312
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = call i64 %8(i32 noundef 0, ptr noundef null, ptr noundef null, ptr noundef nonnull %2, ptr noundef nonnull %3) #3
  %10 = icmp slt i64 %9, 0
  br i1 %10, label %141, label %.preheader44

.preheader44:                                     ; preds = %1
  %11 = load i64, ptr %2, align 8, !tbaa !14
  %.not50 = icmp eq i64 %11, 0
  br i1 %.not50, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %29
  %12 = icmp eq i64 %31, 0
  br i1 %12, label %._crit_edge, label %.lr.ph49

.lr.ph:                                           ; preds = %.preheader44, %29
  %.047 = phi i64 [ %30, %29 ], [ 0, %.preheader44 ]
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds ptr, ptr %13, i64 %.047
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp4DriverBinding, i64 40), align 8, !tbaa !15
  %17 = call i64 @IScsiTestManagedDevice(ptr noundef %15, ptr noundef %16, ptr noundef nonnull @gEfiTcp4ProtocolGuid) #3
  %18 = icmp slt i64 %17, 0
  br i1 %18, label %29, label %19

19:                                               ; preds = %.lr.ph
  %20 = load ptr, ptr @gBS, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 272
  %22 = load ptr, ptr %21, align 8, !tbaa !17
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds ptr, ptr %23, i64 %.047
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp4DriverBinding, i64 40), align 8, !tbaa !15
  %27 = call i64 %22(ptr noundef %25, ptr noundef %26, ptr noundef null) #3
  %28 = icmp slt i64 %27, 0
  br i1 %28, label %.loopexit, label %29

29:                                               ; preds = %19, %.lr.ph
  %30 = add nuw i64 %.047, 1
  %31 = load i64, ptr %2, align 8, !tbaa !14
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %.lr.ph, label %.preheader, !llvm.loop !18

.lr.ph49:                                         ; preds = %.preheader, %49
  %.148 = phi i64 [ %50, %49 ], [ 0, %.preheader ]
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds ptr, ptr %33, i64 %.148
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp6DriverBinding, i64 40), align 8, !tbaa !15
  %37 = call i64 @IScsiTestManagedDevice(ptr noundef %35, ptr noundef %36, ptr noundef nonnull @gEfiTcp6ProtocolGuid) #3
  %38 = icmp slt i64 %37, 0
  br i1 %38, label %49, label %39

39:                                               ; preds = %.lr.ph49
  %40 = load ptr, ptr @gBS, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 272
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds ptr, ptr %43, i64 %.148
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp6DriverBinding, i64 40), align 8, !tbaa !15
  %47 = call i64 %42(ptr noundef %45, ptr noundef %46, ptr noundef null) #3
  %48 = icmp slt i64 %47, 0
  br i1 %48, label %.loopexit, label %49

49:                                               ; preds = %39, %.lr.ph49
  %50 = add nuw i64 %.148, 1
  %51 = load i64, ptr %2, align 8, !tbaa !14
  %52 = icmp ult i64 %50, %51
  br i1 %52, label %.lr.ph49, label %._crit_edge, !llvm.loop !20

._crit_edge:                                      ; preds = %49, %.preheader44, %.preheader
  %53 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp4DriverBinding, i64 40), align 8, !tbaa !15
  %54 = call i64 @IScsiConfigFormUnload(ptr noundef %53) #3
  %55 = icmp slt i64 %54, 0
  br i1 %55, label %.loopexit, label %56

56:                                               ; preds = %._crit_edge
  %57 = load ptr, ptr @gBS, align 8, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %57, i64 336
  %59 = load ptr, ptr %58, align 8, !tbaa !21
  %60 = call i64 (ptr, ...) %59(ptr noundef %0, ptr noundef nonnull @gEfiAuthenticationInfoProtocolGuid, ptr noundef nonnull @gIScsiAuthenticationInfo, ptr noundef null) #3
  %61 = icmp slt i64 %60, 0
  br i1 %61, label %.loopexit, label %62

62:                                               ; preds = %56
  %63 = load ptr, ptr @gIScsiControllerNameTable, align 8, !tbaa !5
  %.not = icmp eq ptr %63, null
  br i1 %.not, label %68, label %64

64:                                               ; preds = %62
  %65 = call i64 @FreeUnicodeStringTable(ptr noundef nonnull %63) #3
  %66 = icmp slt i64 %65, 0
  br i1 %66, label %.loopexit, label %67

67:                                               ; preds = %64
  store ptr null, ptr @gIScsiControllerNameTable, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %67, %62
  %69 = load ptr, ptr @gBS, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %69, i64 152
  %71 = load ptr, ptr %70, align 8, !tbaa !22
  %72 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp4DriverBinding, i64 40), align 8, !tbaa !15
  %73 = call i64 %71(ptr noundef %72, ptr noundef nonnull @gEfiComponentNameProtocolGuid, ptr noundef nonnull %4) #3
  %74 = icmp slt i64 %73, 0
  br i1 %74, label %83, label %75

75:                                               ; preds = %68
  %76 = load ptr, ptr @gBS, align 8, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %76, i64 336
  %78 = load ptr, ptr %77, align 8, !tbaa !21
  %79 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp4DriverBinding, i64 40), align 8, !tbaa !15
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = call i64 (ptr, ...) %78(ptr noundef %79, ptr noundef nonnull @gEfiComponentNameProtocolGuid, ptr noundef %80, ptr noundef null) #3
  %82 = icmp slt i64 %81, 0
  br i1 %82, label %.loopexit, label %83

83:                                               ; preds = %75, %68
  %84 = load ptr, ptr @gBS, align 8, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %84, i64 152
  %86 = load ptr, ptr %85, align 8, !tbaa !22
  %87 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp4DriverBinding, i64 40), align 8, !tbaa !15
  %88 = call i64 %86(ptr noundef %87, ptr noundef nonnull @gEfiComponentName2ProtocolGuid, ptr noundef nonnull %5) #3
  %89 = icmp slt i64 %88, 0
  br i1 %89, label %97, label %90

90:                                               ; preds = %83
  %91 = load ptr, ptr @gBS, align 8, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %91, i64 336
  %93 = load ptr, ptr %92, align 8, !tbaa !21
  %94 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp4DriverBinding, i64 40), align 8, !tbaa !15
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = call i64 (ptr, ...) %93(ptr noundef %94, ptr noundef nonnull @gEfiComponentName2ProtocolGuid, ptr noundef %95, ptr noundef null) #3
  br label %97

97:                                               ; preds = %90, %83
  %98 = load ptr, ptr @gBS, align 8, !tbaa !5
  %99 = getelementptr inbounds i8, ptr %98, i64 152
  %100 = load ptr, ptr %99, align 8, !tbaa !22
  %101 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp6DriverBinding, i64 40), align 8, !tbaa !15
  %102 = call i64 %100(ptr noundef %101, ptr noundef nonnull @gEfiComponentNameProtocolGuid, ptr noundef nonnull %4) #3
  %103 = icmp slt i64 %102, 0
  br i1 %103, label %112, label %104

104:                                              ; preds = %97
  %105 = load ptr, ptr @gBS, align 8, !tbaa !5
  %106 = getelementptr inbounds i8, ptr %105, i64 336
  %107 = load ptr, ptr %106, align 8, !tbaa !21
  %108 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp6DriverBinding, i64 40), align 8, !tbaa !15
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = call i64 (ptr, ...) %107(ptr noundef %108, ptr noundef nonnull @gEfiComponentNameProtocolGuid, ptr noundef %109, ptr noundef null) #3
  %111 = icmp slt i64 %110, 0
  br i1 %111, label %.loopexit, label %112

112:                                              ; preds = %104, %97
  %113 = load ptr, ptr @gBS, align 8, !tbaa !5
  %114 = getelementptr inbounds i8, ptr %113, i64 152
  %115 = load ptr, ptr %114, align 8, !tbaa !22
  %116 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp6DriverBinding, i64 40), align 8, !tbaa !15
  %117 = call i64 %115(ptr noundef %116, ptr noundef nonnull @gEfiComponentName2ProtocolGuid, ptr noundef nonnull %5) #3
  %118 = icmp slt i64 %117, 0
  br i1 %118, label %126, label %119

119:                                              ; preds = %112
  %120 = load ptr, ptr @gBS, align 8, !tbaa !5
  %121 = getelementptr inbounds i8, ptr %120, i64 336
  %122 = load ptr, ptr %121, align 8, !tbaa !21
  %123 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp6DriverBinding, i64 40), align 8, !tbaa !15
  %124 = load ptr, ptr %5, align 8, !tbaa !5
  %125 = call i64 (ptr, ...) %122(ptr noundef %123, ptr noundef nonnull @gEfiComponentName2ProtocolGuid, ptr noundef %124, ptr noundef null) #3
  br label %126

126:                                              ; preds = %119, %112
  %127 = load ptr, ptr @gBS, align 8, !tbaa !5
  %128 = getelementptr inbounds i8, ptr %127, i64 336
  %129 = load ptr, ptr %128, align 8, !tbaa !21
  %130 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp4DriverBinding, i64 40), align 8, !tbaa !15
  %131 = call i64 (ptr, ...) %129(ptr noundef %130, ptr noundef nonnull @gEfiDriverBindingProtocolGuid, ptr noundef nonnull @gIScsiIp4DriverBinding, ptr noundef nonnull @gEfiIScsiInitiatorNameProtocolGuid, ptr noundef nonnull @gIScsiInitiatorName, ptr noundef null) #3
  %132 = icmp slt i64 %131, 0
  br i1 %132, label %.loopexit, label %133

133:                                              ; preds = %126
  %134 = load ptr, ptr @gBS, align 8, !tbaa !5
  %135 = getelementptr inbounds i8, ptr %134, i64 336
  %136 = load ptr, ptr %135, align 8, !tbaa !21
  %137 = load ptr, ptr getelementptr inbounds (i8, ptr @gIScsiIp6DriverBinding, i64 40), align 8, !tbaa !15
  %138 = call i64 (ptr, ...) %136(ptr noundef %137, ptr noundef nonnull @gEfiDriverBindingProtocolGuid, ptr noundef nonnull @gIScsiIp6DriverBinding, ptr noundef null) #3
  br label %.loopexit

.loopexit:                                        ; preds = %19, %39, %126, %104, %75, %64, %56, %._crit_edge, %133
  %.028 = phi i64 [ %54, %._crit_edge ], [ %60, %56 ], [ %65, %64 ], [ %131, %126 ], [ %138, %133 ], [ %110, %104 ], [ %81, %75 ], [ %47, %39 ], [ %27, %19 ]
  %139 = load ptr, ptr %3, align 8, !tbaa !5
  %.not43 = icmp eq ptr %139, null
  br i1 %.not43, label %141, label %140

140:                                              ; preds = %.loopexit
  call void @FreePool(ptr noundef nonnull %139) #3
  br label %141

141:                                              ; preds = %.loopexit, %140, %1
  %.029 = phi i64 [ %9, %1 ], [ %.028, %140 ], [ %.028, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret i64 %.029
}

declare i64 @IScsiTestManagedDevice(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i64 @IScsiConfigFormUnload(ptr noundef) local_unnamed_addr #1

declare i64 @FreeUnicodeStringTable(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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 312}
!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 = !{!12, !12, i64 0}
!15 = !{!16, !6, i64 40}
!16 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!10, !6, i64 272}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!10, !6, i64 336}
!22 = !{!10, !6, i64 152}


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