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

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

%union.TCP_IO_CONFIG_DATA = type { %struct.TCP4_IO_CONFIG_DATA }
%struct.TCP4_IO_CONFIG_DATA = type { %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, %struct.EFI_IPv4_ADDRESS, i16, i8 }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct._ISCSI_SESSION = type { i32, ptr, ptr, i8, %union.anon, i8, [6 x i8], i16, i32, i32, i32, i32, i16, %struct._LIST_ENTRY, i32, %struct._LIST_ENTRY, i16, i32, i8, i8, i32, i32, i32, i32, i16, i8, i8, i8 }
%union.anon = type { %struct._ISCSI_CHAP_AUTH_DATA }
%struct._ISCSI_CHAP_AUTH_DATA = type { ptr, i32, [1024 x i8], i32, [16 x i8], i32, [1024 x i8], i32 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct._ISCSI_ATTEMPT_CONFIG_NVDATA = type <{ %struct._LIST_ENTRY, i8, i8, i8, i8, i8, i8, i16, i16, [96 x i8], [96 x i8], %union.EFI_IP_ADDRESS, %union.EFI_IP_ADDRESS, %union.EFI_IP_ADDRESS, %struct._ISCSI_SESSION_CONFIG_NVDATA, i8, %union.anon.2 }>
%union.EFI_IP_ADDRESS = type { [4 x i32] }
%struct._ISCSI_SESSION_CONFIG_NVDATA = type <{ i16, i8, i8, %union.EFI_IP_ADDRESS, %struct.EFI_IPv4_ADDRESS, %union.EFI_IP_ADDRESS, i8, i8, [224 x i8], %union.EFI_IP_ADDRESS, i8, [8 x i8], i16, i8, [6 x i8] }>
%union.anon.2 = type { %struct._ISCSI_CHAP_AUTH_CONFIG_NVDATA }
%struct._ISCSI_CHAP_AUTH_CONFIG_NVDATA = type { i8, [127 x i8], [17 x i8], [127 x i8], [17 x i8] }
%struct._ISCSI_CONNECTION = type { i32, %struct._LIST_ENTRY, ptr, ptr, i8, i8, i8, i8, i8, i8, i8, i8, i16, i32, %struct.NET_BUF_QUEUE, i8, %struct.TCP_IO, i32, i32, i32 }
%struct.NET_BUF_QUEUE = type { i32, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32 }
%struct.TCP_IO = type { i8, ptr, ptr, ptr, %union.TCP_IO_PROTOCOL, %union.TCP_IO_PROTOCOL, %union.TCP_IO_CONNECTION_TOKEN, %union.TCP_IO_IO_TOKEN, %union.TCP_IO_IO_TOKEN, %union.TCP_IO_CLOSE_TOKEN, %union.TCP_IO_LISTEN_TOKEN, i8, i8, i8, i8, i8 }
%union.TCP_IO_PROTOCOL = type { ptr }
%union.TCP_IO_CONNECTION_TOKEN = type { %struct.EFI_TCP4_CONNECTION_TOKEN }
%struct.EFI_TCP4_CONNECTION_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN }
%struct.EFI_TCP4_COMPLETION_TOKEN = type { ptr, i64 }
%union.TCP_IO_IO_TOKEN = type { %struct.EFI_TCP4_IO_TOKEN }
%struct.EFI_TCP4_IO_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, %union.anon.0 }
%union.anon.0 = type { ptr }
%union.TCP_IO_CLOSE_TOKEN = type { %struct.EFI_TCP4_CLOSE_TOKEN }
%struct.EFI_TCP4_CLOSE_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, i8 }
%union.TCP_IO_LISTEN_TOKEN = type { %struct.EFI_TCP4_LISTEN_TOKEN }
%struct.EFI_TCP4_LISTEN_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, 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 }
%struct.TCP6_IO_CONFIG_DATA = type { i16, %struct.EFI_IPv6_ADDRESS, i16, i8 }
%struct.EFI_IPv6_ADDRESS = type { [16 x i8] }
%struct._ISCSI_DRIVER_DATA = type { i32, ptr, ptr, %struct._ISCSI_PRIVATE_PROTOCOL, ptr, %struct._EFI_EXT_SCSI_PASS_THRU_PROTOCOL, %struct.EFI_EXT_SCSI_PASS_THRU_MODE, ptr, ptr, ptr, ptr }
%struct._ISCSI_PRIVATE_PROTOCOL = type { i32 }
%struct._EFI_EXT_SCSI_PASS_THRU_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_EXT_SCSI_PASS_THRU_MODE = type { i32, i32, i32 }

@gBS = external global ptr, 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

; Function Attrs: nounwind uwtable
define dso_local ptr @IScsiCreateConnection(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %union.TCP_IO_CONFIG_DATA, align 2
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = 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 22, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %12, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  store ptr %14, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds %struct._ISCSI_ATTEMPT_CONFIG_NVDATA, ptr %17, i32 0, i32 14
  store ptr %18, ptr %5, align 8, !tbaa !5
  %19 = call ptr @AllocateZeroPool(i64 noundef 304)
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %11, align 4
  br label %166

23:                                               ; preds = %1
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %24, i32 0, i32 0
  store i32 1313035081, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %26, i32 0, i32 4
  store i8 0, ptr %27, align 8, !tbaa !20
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %28, i32 0, i32 5
  store i8 0, ptr %29, align 1, !tbaa !21
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %30, i32 0, i32 6
  store i8 1, ptr %31, align 2, !tbaa !22
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %32, i32 0, i32 7
  store i8 0, ptr %33, align 1, !tbaa !23
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %34, i32 0, i32 13
  store i32 0, ptr %35, align 4, !tbaa !24
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %36, i32 0, i32 8
  store i8 0, ptr %37, align 4, !tbaa !25
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %38, i32 0, i32 9
  store i8 0, ptr %39, align 1, !tbaa !26
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %40, i32 0, i32 11
  store i8 0, ptr %41, align 1, !tbaa !27
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %42, i32 0, i32 12
  %44 = load i16, ptr %43, align 4, !tbaa !28
  %45 = add i16 %44, 1
  store i16 %45, ptr %43, align 4, !tbaa !28
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %46, i32 0, i32 12
  store i16 %44, ptr %47, align 8, !tbaa !29
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %48, i32 0, i32 2
  %50 = load i8, ptr %49, align 1, !tbaa !30
  %51 = zext i8 %50 to i32
  %52 = icmp eq i32 %51, 1
  br i1 %52, label %61, label %53

53:                                               ; preds = %23
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  %57 = getelementptr inbounds %struct._ISCSI_ATTEMPT_CONFIG_NVDATA, ptr %56, i32 0, i32 6
  %58 = load i8, ptr %57, align 1, !tbaa !33
  %59 = zext i8 %58 to i32
  %60 = icmp eq i32 %59, 4
  br label %61

61:                                               ; preds = %53, %23
  %62 = phi i1 [ true, %23 ], [ %60, %53 ]
  %63 = zext i1 %62 to i32
  %64 = trunc i32 %63 to i8
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %65, i32 0, i32 15
  store i8 %64, ptr %66, align 8, !tbaa !35
  %67 = load ptr, ptr @gBS, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %67, i32 0, i32 8
  %69 = load ptr, ptr %68, align 8, !tbaa !36
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %70, i32 0, i32 2
  %72 = call i64 %69(i32 noundef -2147483648, i64 noundef 8, ptr noundef null, ptr noundef null, ptr noundef %71)
  store i64 %72, ptr %10, align 8, !tbaa !39
  %73 = load i64, ptr %10, align 8, !tbaa !39
  %74 = icmp slt i64 %73, 0
  br i1 %74, label %75, label %77

75:                                               ; preds = %61
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  call void @FreePool(ptr noundef %76)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %11, align 4
  br label %166

77:                                               ; preds = %61
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %78, i32 0, i32 14
  call void @NetbufQueInit(ptr noundef %79)
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %80, i32 0, i32 17
  store i32 8192, ptr %81, align 8, !tbaa !40
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %82, i32 0, i32 18
  store i32 0, ptr %83, align 4, !tbaa !41
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %84, i32 0, i32 19
  store i32 0, ptr %85, align 8, !tbaa !42
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %86, i32 0, i32 15
  %88 = load i8, ptr %87, align 8, !tbaa !35
  %89 = icmp ne i8 %88, 0
  br i1 %89, label %120, label %90

90:                                               ; preds = %77
  store ptr %7, ptr %8, align 8, !tbaa !5
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.TCP4_IO_CONFIG_DATA, ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %93, i32 0, i32 3
  %95 = call ptr @CopyMem(ptr noundef %92, ptr noundef %94, i64 noundef 4)
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.TCP4_IO_CONFIG_DATA, ptr %96, i32 0, i32 1
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %98, i32 0, i32 4
  %100 = call ptr @CopyMem(ptr noundef %97, ptr noundef %99, i64 noundef 4)
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.TCP4_IO_CONFIG_DATA, ptr %101, i32 0, i32 2
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %103, i32 0, i32 5
  %105 = call ptr @CopyMem(ptr noundef %102, ptr noundef %104, i64 noundef 4)
  %106 = load ptr, ptr %8, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.TCP4_IO_CONFIG_DATA, ptr %106, i32 0, i32 4
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %108, i32 0, i32 9
  %110 = call ptr @CopyMem(ptr noundef %107, ptr noundef %109, i64 noundef 4)
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %111, i32 0, i32 0
  %113 = load i16, ptr %112, align 1, !tbaa !43
  %114 = load ptr, ptr %8, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.TCP4_IO_CONFIG_DATA, ptr %114, i32 0, i32 5
  store i16 %113, ptr %115, align 2, !tbaa !44
  %116 = load ptr, ptr %8, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.TCP4_IO_CONFIG_DATA, ptr %116, i32 0, i32 6
  store i8 1, ptr %117, align 2, !tbaa !46
  %118 = load ptr, ptr %8, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.TCP4_IO_CONFIG_DATA, ptr %118, i32 0, i32 3
  store i16 0, ptr %119, align 2, !tbaa !47
  br label %135

120:                                              ; preds = %77
  store ptr %7, ptr %9, align 8, !tbaa !5
  %121 = load ptr, ptr %9, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.TCP6_IO_CONFIG_DATA, ptr %121, i32 0, i32 1
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %123, i32 0, i32 9
  %125 = call ptr @CopyMem(ptr noundef %122, ptr noundef %124, i64 noundef 16)
  %126 = load ptr, ptr %5, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %126, i32 0, i32 0
  %128 = load i16, ptr %127, align 1, !tbaa !43
  %129 = load ptr, ptr %9, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.TCP6_IO_CONFIG_DATA, ptr %129, i32 0, i32 2
  store i16 %128, ptr %130, align 2, !tbaa !48
  %131 = load ptr, ptr %9, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.TCP6_IO_CONFIG_DATA, ptr %131, i32 0, i32 3
  store i8 1, ptr %132, align 2, !tbaa !50
  %133 = load ptr, ptr %9, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.TCP6_IO_CONFIG_DATA, ptr %133, i32 0, i32 0
  store i16 0, ptr %134, align 2, !tbaa !51
  br label %135

135:                                              ; preds = %120, %90
  %136 = load ptr, ptr %4, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct._ISCSI_DRIVER_DATA, ptr %136, i32 0, i32 1
  %138 = load ptr, ptr %137, align 8, !tbaa !52
  %139 = load ptr, ptr %4, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct._ISCSI_DRIVER_DATA, ptr %139, i32 0, i32 2
  %141 = load ptr, ptr %140, align 8, !tbaa !57
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %142, i32 0, i32 15
  %144 = load i8, ptr %143, align 8, !tbaa !35
  %145 = icmp ne i8 %144, 0
  %146 = xor i1 %145, true
  %147 = zext i1 %146 to i64
  %148 = select i1 %146, i32 4, i32 6
  %149 = trunc i32 %148 to i8
  %150 = load ptr, ptr %6, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %150, i32 0, i32 16
  %152 = call i64 @TcpIoCreateSocket(ptr noundef %138, ptr noundef %141, i8 noundef zeroext %149, ptr noundef %7, ptr noundef %151)
  store i64 %152, ptr %10, align 8, !tbaa !39
  %153 = load i64, ptr %10, align 8, !tbaa !39
  %154 = icmp slt i64 %153, 0
  br i1 %154, label %155, label %164

155:                                              ; preds = %135
  %156 = load ptr, ptr @gBS, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %156, i32 0, i32 12
  %158 = load ptr, ptr %157, align 8, !tbaa !58
  %159 = load ptr, ptr %6, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %159, i32 0, i32 2
  %161 = load ptr, ptr %160, align 8, !tbaa !59
  %162 = call i64 %158(ptr noundef %161)
  %163 = load ptr, ptr %6, align 8, !tbaa !5
  call void @FreePool(ptr noundef %163)
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %164

164:                                              ; preds = %155, %135
  %165 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %165, ptr %2, align 8
  store i32 1, ptr %11, align 4
  br label %166

166:                                              ; preds = %164, %75, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  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 22, 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
  %167 = load ptr, ptr %2, align 8
  ret ptr %167
}

declare ptr @AllocateZeroPool(i64 noundef) #2

declare void @FreePool(ptr noundef) #2

declare void @NetbufQueInit(ptr noundef) #2

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) #2

declare i64 @TcpIoCreateSocket(ptr noundef, ptr noundef, i8 noundef zeroext, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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 8}
!10 = !{!"_ISCSI_SESSION", !11, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !7, i64 32, !7, i64 2120, !7, i64 2121, !12, i64 2128, !11, i64 2132, !11, i64 2136, !11, i64 2140, !11, i64 2144, !12, i64 2148, !13, i64 2152, !11, i64 2168, !13, i64 2176, !12, i64 2192, !11, i64 2196, !7, i64 2200, !7, i64 2201, !11, i64 2204, !11, i64 2208, !11, i64 2212, !11, i64 2216, !12, i64 2220, !7, i64 2222, !7, i64 2223, !7, i64 2224}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!10, !6, i64 16}
!15 = !{!16, !11, i64 0}
!16 = !{!"_ISCSI_CONNECTION", !11, i64 0, !13, i64 8, !6, i64 24, !6, i64 32, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !7, i64 44, !7, i64 45, !7, i64 46, !7, i64 47, !12, i64 48, !11, i64 52, !17, i64 56, !7, i64 112, !19, i64 120, !11, i64 288, !11, i64 292, !11, i64 296}
!17 = !{!"", !11, i64 0, !18, i64 8, !13, i64 16, !13, i64 32, !11, i64 48, !11, i64 52}
!18 = !{!"long long", !7, i64 0}
!19 = !{!"", !7, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 64, !7, i64 88, !7, i64 112, !7, i64 136, !7, i64 160, !7, i64 161, !7, i64 162, !7, i64 163, !7, i64 164}
!20 = !{!16, !7, i64 40}
!21 = !{!16, !7, i64 41}
!22 = !{!16, !7, i64 42}
!23 = !{!16, !7, i64 43}
!24 = !{!16, !11, i64 52}
!25 = !{!16, !7, i64 44}
!26 = !{!16, !7, i64 45}
!27 = !{!16, !7, i64 47}
!28 = !{!10, !12, i64 2148}
!29 = !{!16, !12, i64 48}
!30 = !{!31, !7, i64 3}
!31 = !{!"_ISCSI_SESSION_CONFIG_NVDATA", !12, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !32, i64 20, !7, i64 24, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 266, !7, i64 282, !7, i64 283, !12, i64 291, !7, i64 293, !7, i64 294}
!32 = !{!"", !7, i64 0}
!33 = !{!34, !7, i64 21}
!34 = !{!"_ISCSI_ATTEMPT_CONFIG_NVDATA", !13, i64 0, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !12, i64 22, !12, i64 24, !7, i64 26, !7, i64 122, !7, i64 218, !7, i64 234, !7, i64 250, !31, i64 266, !7, i64 566, !7, i64 567}
!35 = !{!16, !7, i64 112}
!36 = !{!37, !6, i64 80}
!37 = !{!"", !38, 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}
!38 = !{!"", !18, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!39 = !{!18, !18, i64 0}
!40 = !{!16, !11, i64 288}
!41 = !{!16, !11, i64 292}
!42 = !{!16, !11, i64 296}
!43 = !{!31, !12, i64 0}
!44 = !{!45, !12, i64 18}
!45 = !{!"", !32, i64 0, !32, i64 4, !32, i64 8, !12, i64 12, !32, i64 14, !12, i64 18, !7, i64 20}
!46 = !{!45, !7, i64 20}
!47 = !{!45, !12, i64 12}
!48 = !{!49, !12, i64 18}
!49 = !{!"", !12, i64 0, !32, i64 2, !12, i64 18, !7, i64 20}
!50 = !{!49, !7, i64 20}
!51 = !{!49, !12, i64 0}
!52 = !{!53, !6, i64 8}
!53 = !{!"_ISCSI_DRIVER_DATA", !11, i64 0, !6, i64 8, !6, i64 16, !54, i64 24, !6, i64 32, !55, i64 40, !56, i64 104, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144}
!54 = !{!"_ISCSI_PRIVATE_PROTOCOL", !11, i64 0}
!55 = !{!"_EFI_EXT_SCSI_PASS_THRU_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!56 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!57 = !{!53, !6, i64 16}
!58 = !{!37, !6, i64 112}
!59 = !{!16, !6, i64 24}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%union.TCP_IO_CONFIG_DATA = type { %struct.TCP4_IO_CONFIG_DATA }
%struct.TCP4_IO_CONFIG_DATA = type { %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, %struct.EFI_IPv4_ADDRESS, i16, i8 }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }

@gBS = external local_unnamed_addr global ptr, 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

; Function Attrs: nounwind uwtable
define dso_local ptr @IScsiCreateConnection(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = alloca %union.TCP_IO_CONFIG_DATA, align 2
  call void @llvm.lifetime.start.p0(i64 22, ptr nonnull %2) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %6, i64 266
  %8 = tail call ptr @AllocateZeroPool(i64 noundef 304) #3
  %9 = icmp eq ptr %8, null
  br i1 %9, label %82, label %10

10:                                               ; preds = %1
  store i32 1313035081, ptr %8, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %8, i64 40
  store <4 x i8> <i8 0, i8 0, i8 1, i8 0>, ptr %11, align 8, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %8, i64 52
  store i32 0, ptr %12, align 4, !tbaa !20
  %13 = getelementptr inbounds i8, ptr %8, i64 44
  store i8 0, ptr %13, align 4, !tbaa !21
  %14 = getelementptr inbounds i8, ptr %8, i64 45
  store i8 0, ptr %14, align 1, !tbaa !22
  %15 = getelementptr inbounds i8, ptr %8, i64 47
  store i8 0, ptr %15, align 1, !tbaa !23
  %16 = getelementptr inbounds i8, ptr %0, i64 2148
  %17 = load i16, ptr %16, align 4, !tbaa !24
  %18 = add i16 %17, 1
  store i16 %18, ptr %16, align 4, !tbaa !24
  %19 = getelementptr inbounds i8, ptr %8, i64 48
  store i16 %17, ptr %19, align 8, !tbaa !25
  %20 = getelementptr inbounds i8, ptr %6, i64 269
  %21 = load i8, ptr %20, align 1, !tbaa !26
  %22 = icmp eq i8 %21, 1
  br i1 %22, label %29, label %23

23:                                               ; preds = %10
  %24 = load ptr, ptr %5, align 8, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %24, i64 21
  %26 = load i8, ptr %25, align 1, !tbaa !29
  %27 = icmp eq i8 %26, 4
  %28 = zext i1 %27 to i8
  br label %29

29:                                               ; preds = %23, %10
  %30 = phi i8 [ 1, %10 ], [ %28, %23 ]
  %31 = getelementptr inbounds i8, ptr %8, i64 112
  store i8 %30, ptr %31, align 8, !tbaa !31
  %32 = load ptr, ptr @gBS, align 8, !tbaa !32
  %33 = getelementptr inbounds i8, ptr %32, i64 80
  %34 = load ptr, ptr %33, align 8, !tbaa !33
  %35 = getelementptr inbounds i8, ptr %8, i64 24
  %36 = tail call i64 %34(i32 noundef -2147483648, i64 noundef 8, ptr noundef null, ptr noundef null, ptr noundef nonnull %35) #3
  %37 = icmp slt i64 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %29
  tail call void @FreePool(ptr noundef nonnull %8) #3
  br label %82

39:                                               ; preds = %29
  %40 = getelementptr inbounds i8, ptr %8, i64 56
  tail call void @NetbufQueInit(ptr noundef nonnull %40) #3
  %41 = getelementptr inbounds i8, ptr %8, i64 288
  store i32 8192, ptr %41, align 8, !tbaa !36
  %42 = getelementptr inbounds i8, ptr %8, i64 292
  store i32 0, ptr %42, align 4, !tbaa !37
  %43 = getelementptr inbounds i8, ptr %8, i64 296
  store i32 0, ptr %43, align 8, !tbaa !38
  %44 = load i8, ptr %31, align 8, !tbaa !31
  %.not = icmp eq i8 %44, 0
  br i1 %.not, label %45, label %59

45:                                               ; preds = %39
  %46 = getelementptr inbounds i8, ptr %6, i64 270
  %47 = call ptr @CopyMem(ptr noundef nonnull %2, ptr noundef nonnull %46, i64 noundef 4) #3
  %48 = getelementptr inbounds i8, ptr %2, i64 4
  %49 = getelementptr inbounds i8, ptr %6, i64 286
  %50 = call ptr @CopyMem(ptr noundef nonnull %48, ptr noundef nonnull %49, i64 noundef 4) #3
  %51 = getelementptr inbounds i8, ptr %2, i64 8
  %52 = getelementptr inbounds i8, ptr %6, i64 290
  %53 = call ptr @CopyMem(ptr noundef nonnull %51, ptr noundef nonnull %52, i64 noundef 4) #3
  %54 = getelementptr inbounds i8, ptr %2, i64 14
  %55 = getelementptr inbounds i8, ptr %6, i64 532
  %56 = call ptr @CopyMem(ptr noundef nonnull %54, ptr noundef nonnull %55, i64 noundef 4) #3
  %57 = load i16, ptr %7, align 1, !tbaa !39
  %58 = getelementptr inbounds i8, ptr %2, i64 12
  store i16 0, ptr %58, align 2, !tbaa !40
  br label %64

59:                                               ; preds = %39
  %60 = getelementptr inbounds i8, ptr %2, i64 2
  %61 = getelementptr inbounds i8, ptr %6, i64 532
  %62 = call ptr @CopyMem(ptr noundef nonnull %60, ptr noundef nonnull %61, i64 noundef 16) #3
  %63 = load i16, ptr %7, align 1, !tbaa !39
  store i16 0, ptr %2, align 2, !tbaa !42
  br label %64

64:                                               ; preds = %59, %45
  %.sink = phi i16 [ %57, %45 ], [ %63, %59 ]
  %65 = getelementptr inbounds i8, ptr %2, i64 18
  store i16 %.sink, ptr %65, align 2
  %66 = getelementptr inbounds i8, ptr %2, i64 20
  store i8 1, ptr %66, align 2
  %67 = getelementptr inbounds i8, ptr %4, i64 8
  %68 = load ptr, ptr %67, align 8, !tbaa !44
  %69 = getelementptr inbounds i8, ptr %4, i64 16
  %70 = load ptr, ptr %69, align 8, !tbaa !49
  %71 = load i8, ptr %31, align 8, !tbaa !31
  %.not53 = icmp eq i8 %71, 0
  %72 = select i1 %.not53, i8 4, i8 6
  %73 = getelementptr inbounds i8, ptr %8, i64 120
  %74 = call i64 @TcpIoCreateSocket(ptr noundef %68, ptr noundef %70, i8 noundef zeroext %72, ptr noundef nonnull %2, ptr noundef nonnull %73) #3
  %75 = icmp slt i64 %74, 0
  br i1 %75, label %76, label %82

76:                                               ; preds = %64
  %77 = load ptr, ptr @gBS, align 8, !tbaa !32
  %78 = getelementptr inbounds i8, ptr %77, i64 112
  %79 = load ptr, ptr %78, align 8, !tbaa !50
  %80 = load ptr, ptr %35, align 8, !tbaa !51
  %81 = call i64 %79(ptr noundef %80) #3
  call void @FreePool(ptr noundef nonnull %8) #3
  br label %82

82:                                               ; preds = %64, %76, %1, %38
  %.0 = phi ptr [ null, %38 ], [ null, %1 ], [ null, %76 ], [ %8, %64 ]
  call void @llvm.lifetime.end.p0(i64 22, ptr nonnull %2) #3
  ret ptr %.0
}

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #2

declare void @FreePool(ptr noundef) local_unnamed_addr #2

declare void @NetbufQueInit(ptr noundef) local_unnamed_addr #2

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i64 @TcpIoCreateSocket(ptr noundef, ptr noundef, i8 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "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, !10, i64 8}
!6 = !{!"_ISCSI_SESSION", !7, i64 0, !10, i64 8, !10, i64 16, !8, i64 24, !8, i64 32, !8, i64 2120, !8, i64 2121, !11, i64 2128, !7, i64 2132, !7, i64 2136, !7, i64 2140, !7, i64 2144, !11, i64 2148, !12, i64 2152, !7, i64 2168, !12, i64 2176, !11, i64 2192, !7, i64 2196, !8, i64 2200, !8, i64 2201, !7, i64 2204, !7, i64 2208, !7, i64 2212, !7, i64 2216, !11, i64 2220, !8, i64 2222, !8, i64 2223, !8, i64 2224}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}
!13 = !{!6, !10, i64 16}
!14 = !{!15, !7, i64 0}
!15 = !{!"_ISCSI_CONNECTION", !7, i64 0, !12, i64 8, !10, i64 24, !10, i64 32, !8, i64 40, !8, i64 41, !8, i64 42, !8, i64 43, !8, i64 44, !8, i64 45, !8, i64 46, !8, i64 47, !11, i64 48, !7, i64 52, !16, i64 56, !8, i64 112, !18, i64 120, !7, i64 288, !7, i64 292, !7, i64 296}
!16 = !{!"", !7, i64 0, !17, i64 8, !12, i64 16, !12, i64 32, !7, i64 48, !7, i64 52}
!17 = !{!"long long", !8, i64 0}
!18 = !{!"", !8, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 64, !8, i64 88, !8, i64 112, !8, i64 136, !8, i64 160, !8, i64 161, !8, i64 162, !8, i64 163, !8, i64 164}
!19 = !{!8, !8, i64 0}
!20 = !{!15, !7, i64 52}
!21 = !{!15, !8, i64 44}
!22 = !{!15, !8, i64 45}
!23 = !{!15, !8, i64 47}
!24 = !{!6, !11, i64 2148}
!25 = !{!15, !11, i64 48}
!26 = !{!27, !8, i64 3}
!27 = !{!"_ISCSI_SESSION_CONFIG_NVDATA", !11, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !28, i64 20, !8, i64 24, !8, i64 40, !8, i64 41, !8, i64 42, !8, i64 266, !8, i64 282, !8, i64 283, !11, i64 291, !8, i64 293, !8, i64 294}
!28 = !{!"", !8, i64 0}
!29 = !{!30, !8, i64 21}
!30 = !{!"_ISCSI_ATTEMPT_CONFIG_NVDATA", !12, i64 0, !8, i64 16, !8, i64 17, !8, i64 18, !8, i64 19, !8, i64 20, !8, i64 21, !11, i64 22, !11, i64 24, !8, i64 26, !8, i64 122, !8, i64 218, !8, i64 234, !8, i64 250, !27, i64 266, !8, i64 566, !8, i64 567}
!31 = !{!15, !8, i64 112}
!32 = !{!10, !10, i64 0}
!33 = !{!34, !10, i64 80}
!34 = !{!"", !35, i64 0, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272, !10, i64 280, !10, i64 288, !10, i64 296, !10, i64 304, !10, i64 312, !10, i64 320, !10, i64 328, !10, i64 336, !10, i64 344, !10, i64 352, !10, i64 360, !10, i64 368}
!35 = !{!"", !17, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!36 = !{!15, !7, i64 288}
!37 = !{!15, !7, i64 292}
!38 = !{!15, !7, i64 296}
!39 = !{!27, !11, i64 0}
!40 = !{!41, !11, i64 12}
!41 = !{!"", !28, i64 0, !28, i64 4, !28, i64 8, !11, i64 12, !28, i64 14, !11, i64 18, !8, i64 20}
!42 = !{!43, !11, i64 0}
!43 = !{!"", !11, i64 0, !28, i64 2, !11, i64 18, !8, i64 20}
!44 = !{!45, !10, i64 8}
!45 = !{!"_ISCSI_DRIVER_DATA", !7, i64 0, !10, i64 8, !10, i64 16, !46, i64 24, !10, i64 32, !47, i64 40, !48, i64 104, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144}
!46 = !{!"_ISCSI_PRIVATE_PROTOCOL", !7, i64 0}
!47 = !{!"_EFI_EXT_SCSI_PASS_THRU_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!48 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!49 = !{!45, !10, i64 16}
!50 = !{!34, !10, i64 112}
!51 = !{!15, !10, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass