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

; 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._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_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 }
%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] }>
%struct.EFI_IPv4_ADDRESS = type { [4 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 }

@gBS = external global ptr, align 8
@gEfiTcp4ProtocolGuid = external global %struct.GUID, align 4
@gEfiTcp6ProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [33 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [134 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiAttatchConnection(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiDetatchConnection(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @IScsiConnLogin(ptr noundef, i16 noundef zeroext) #0

; 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

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiConnReset(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @IScsiCreateConnection(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiDestroyConnection(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @IScsiGetIp6NicInfo(ptr noundef) #0

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

19:                                               ; preds = %1
  store i64 -9223372036854775796, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %140

20:                                               ; preds = %1
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %21, i32 0, i32 6
  %23 = getelementptr inbounds [6 x i8], ptr %22, i64 0, i64 0
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !20
  %27 = getelementptr inbounds %struct._ISCSI_ATTEMPT_CONFIG_NVDATA, ptr %26, i32 0, i32 14
  %28 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %27, i32 0, i32 14
  %29 = getelementptr inbounds [6 x i8], ptr %28, i64 0, i64 0
  %30 = call ptr @CopyMem(ptr noundef %23, ptr noundef %29, i64 noundef 6)
  store i8 0, ptr %8, align 1, !tbaa !9
  br label %31

31:                                               ; preds = %61, %20
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = call ptr @IScsiCreateConnection(ptr noundef %32)
  store ptr %33, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store i64 -9223372036854775799, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %140

37:                                               ; preds = %31
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  call void @IScsiAttatchConnection(ptr noundef %38, ptr noundef %39)
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !20
  %44 = getelementptr inbounds %struct._ISCSI_ATTEMPT_CONFIG_NVDATA, ptr %43, i32 0, i32 14
  %45 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %44, i32 0, i32 12
  %46 = load i16, ptr %45, align 1, !tbaa !21
  %47 = call i64 @IScsiConnLogin(ptr noundef %40, i16 noundef zeroext %46)
  store i64 %47, ptr %4, align 8, !tbaa !25
  %48 = load i64, ptr %4, align 8, !tbaa !25
  %49 = icmp slt i64 %48, 0
  br i1 %49, label %50, label %54

50:                                               ; preds = %37
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  call void @IScsiConnReset(ptr noundef %51)
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  call void @IScsiDetatchConnection(ptr noundef %52)
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  call void @IScsiDestroyConnection(ptr noundef %53)
  br label %54

54:                                               ; preds = %50, %37
  %55 = load i64, ptr %4, align 8, !tbaa !25
  %56 = icmp ne i64 %55, -9223372036854775790
  br i1 %56, label %57, label %58

57:                                               ; preds = %54
  br label %72

58:                                               ; preds = %54
  %59 = load i8, ptr %8, align 1, !tbaa !9
  %60 = add i8 %59, 1
  store i8 %60, ptr %8, align 1, !tbaa !9
  br label %61

61:                                               ; preds = %58
  %62 = load i8, ptr %8, align 1, !tbaa !9
  %63 = zext i8 %62 to i32
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !20
  %67 = getelementptr inbounds %struct._ISCSI_ATTEMPT_CONFIG_NVDATA, ptr %66, i32 0, i32 14
  %68 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %67, i32 0, i32 13
  %69 = load i8, ptr %68, align 1, !tbaa !27
  %70 = zext i8 %69 to i32
  %71 = icmp sle i32 %63, %70
  br i1 %71, label %31, label %72, !llvm.loop !28

72:                                               ; preds = %61, %57
  %73 = load i64, ptr %4, align 8, !tbaa !25
  %74 = icmp slt i64 %73, 0
  br i1 %74, label %138, label %75

75:                                               ; preds = %72
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %76, i32 0, i32 5
  store i8 1, ptr %77, align 8, !tbaa !30
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %78, i32 0, i32 15
  %80 = load i8, ptr %79, align 8, !tbaa !31
  %81 = icmp ne i8 %80, 0
  br i1 %81, label %83, label %82

82:                                               ; preds = %75
  store ptr @gEfiTcp4ProtocolGuid, ptr %7, align 8, !tbaa !5
  br label %84

83:                                               ; preds = %75
  store ptr @gEfiTcp6ProtocolGuid, ptr %7, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %83, %82
  %85 = load ptr, ptr @gBS, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %85, i32 0, i32 33
  %87 = load ptr, ptr %86, align 8, !tbaa !35
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %88, i32 0, i32 16
  %90 = getelementptr inbounds %struct.TCP_IO, ptr %89, i32 0, i32 3
  %91 = load ptr, ptr %90, align 8, !tbaa !38
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %93, i32 0, i32 1
  %95 = load ptr, ptr %94, align 8, !tbaa !10
  %96 = getelementptr inbounds %struct._ISCSI_DRIVER_DATA, ptr %95, i32 0, i32 1
  %97 = load ptr, ptr %96, align 8, !tbaa !39
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %98, i32 0, i32 1
  %100 = load ptr, ptr %99, align 8, !tbaa !10
  %101 = getelementptr inbounds %struct._ISCSI_DRIVER_DATA, ptr %100, i32 0, i32 7
  %102 = load ptr, ptr %101, align 8, !tbaa !40
  %103 = call i64 %87(ptr noundef %91, ptr noundef %92, ptr noundef %6, ptr noundef %97, ptr noundef %102, i32 noundef 8)
  store i64 %103, ptr %4, align 8, !tbaa !25
  br label %104

104:                                              ; preds = %84
  %105 = call zeroext i8 @DebugAssertEnabled()
  %106 = icmp ne i8 %105, 0
  br i1 %106, label %107, label %127

107:                                              ; preds = %104
  %108 = load i64, ptr %4, align 8, !tbaa !25
  %109 = icmp slt i64 %108, 0
  br i1 %109, label %110, label %126

110:                                              ; preds = %107
  br label %111

111:                                              ; preds = %110
  %112 = call zeroext i8 @DebugPrintEnabled()
  %113 = icmp ne i8 %112, 0
  br i1 %113, label %114, label %123

114:                                              ; preds = %111
  br label %115

115:                                              ; preds = %114
  %116 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %117 = icmp ne i8 %116, 0
  br i1 %117, label %118, label %120

118:                                              ; preds = %115
  %119 = load i64, ptr %4, align 8, !tbaa !25
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str, i64 noundef %119)
  br label %120

120:                                              ; preds = %118, %115
  br label %121

121:                                              ; preds = %120
  br label %122

122:                                              ; preds = %121
  br label %123

123:                                              ; preds = %122, %111
  br label %124

124:                                              ; preds = %123
  br label %125

125:                                              ; preds = %124
  call void @DebugAssert(ptr noundef @.str.1, i64 noundef 490, ptr noundef @.str.2)
  br label %126

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

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

128:                                              ; preds = %127
  br label %129

129:                                              ; preds = %128
  %130 = load ptr, ptr %5, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %130, i32 0, i32 15
  %132 = load i8, ptr %131, align 8, !tbaa !31
  %133 = icmp ne i8 %132, 0
  br i1 %133, label %134, label %137

134:                                              ; preds = %129
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  %136 = call i64 @IScsiGetIp6NicInfo(ptr noundef %135)
  store i64 %136, ptr %4, align 8, !tbaa !25
  br label %137

137:                                              ; preds = %134, %129
  br label %138

138:                                              ; preds = %137, %72
  %139 = load i64, ptr %4, align 8, !tbaa !25
  store i64 %139, ptr %2, align 8
  store i32 1, ptr %10, align 4
  br label %140

140:                                              ; preds = %138, %36, %19
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 1, 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
  %141 = load i64, ptr %2, align 8
  ret i64 %141
}

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

declare zeroext i8 @DebugAssertEnabled() #2

declare zeroext i8 @DebugPrintEnabled() #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #2

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

declare void @DebugAssert(ptr noundef, i64 noundef, 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 8}
!11 = !{!"_ISCSI_SESSION", !12, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !7, i64 32, !7, i64 2120, !7, i64 2121, !13, i64 2128, !12, i64 2132, !12, i64 2136, !12, i64 2140, !12, i64 2144, !13, i64 2148, !14, i64 2152, !12, i64 2168, !14, i64 2176, !13, i64 2192, !12, i64 2196, !7, i64 2200, !7, i64 2201, !12, i64 2204, !12, i64 2208, !12, i64 2212, !12, i64 2216, !13, i64 2220, !7, i64 2222, !7, i64 2223, !7, i64 2224}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!16, !6, i64 16}
!16 = !{!"_ISCSI_DRIVER_DATA", !12, i64 0, !6, i64 8, !6, i64 16, !17, i64 24, !6, i64 32, !18, i64 40, !19, i64 104, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144}
!17 = !{!"_ISCSI_PRIVATE_PROTOCOL", !12, i64 0}
!18 = !{!"_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}
!19 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!20 = !{!11, !6, i64 16}
!21 = !{!22, !13, i64 557}
!22 = !{!"_ISCSI_ATTEMPT_CONFIG_NVDATA", !14, i64 0, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !13, i64 22, !13, i64 24, !7, i64 26, !7, i64 122, !7, i64 218, !7, i64 234, !7, i64 250, !23, i64 266, !7, i64 566, !7, i64 567}
!23 = !{!"_ISCSI_SESSION_CONFIG_NVDATA", !13, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !24, i64 20, !7, i64 24, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 266, !7, i64 282, !7, i64 283, !13, i64 291, !7, i64 293, !7, i64 294}
!24 = !{!"", !7, i64 0}
!25 = !{!26, !26, i64 0}
!26 = !{!"long long", !7, i64 0}
!27 = !{!22, !7, i64 559}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!11, !7, i64 2120}
!31 = !{!32, !7, i64 112}
!32 = !{!"_ISCSI_CONNECTION", !12, i64 0, !14, 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, !13, i64 48, !12, i64 52, !33, i64 56, !7, i64 112, !34, i64 120, !12, i64 288, !12, i64 292, !12, i64 296}
!33 = !{!"", !12, i64 0, !26, i64 8, !14, i64 16, !14, i64 32, !12, i64 48, !12, i64 52}
!34 = !{!"", !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}
!35 = !{!36, !6, i64 280}
!36 = !{!"", !37, 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}
!37 = !{!"", !26, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!38 = !{!32, !6, i64 144}
!39 = !{!16, !6, i64 8}
!40 = !{!16, !6, i64 120}


; 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
@gEfiTcp4ProtocolGuid = external global %struct.GUID, align 4
@gEfiTcp6ProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [33 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [134 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiAttatchConnection(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiDetatchConnection(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @IScsiConnLogin(ptr noundef, i16 noundef zeroext) local_unnamed_addr #0

; 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

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiConnReset(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @IScsiCreateConnection(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiDestroyConnection(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @IScsiGetIp6NicInfo(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i64 @IScsiSessionLogin(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #3
  store i8 1, ptr %3, align 1, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !8
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  %8 = call i64 @NetLibDetectMedia(ptr noundef %7, ptr noundef nonnull %3) #3
  %9 = load i8, ptr %3, align 1, !tbaa !5
  %.not = icmp eq i8 %9, 0
  br i1 %.not, label %.thread43, label %10

10:                                               ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 2121
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %13, i64 560
  %15 = call ptr @CopyMem(ptr noundef nonnull %11, ptr noundef nonnull %14, i64 noundef 6) #3
  br label %16

16:                                               ; preds = %26, %10
  %.0 = phi i8 [ 0, %10 ], [ %27, %26 ]
  %17 = call ptr @IScsiCreateConnection(ptr noundef nonnull %0)
  %18 = icmp eq ptr %17, null
  br i1 %18, label %.thread43, label %19

19:                                               ; preds = %16
  call void @IScsiAttatchConnection(ptr noundef nonnull %0, ptr noundef nonnull %17)
  %20 = load ptr, ptr %12, align 8, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %20, i64 557
  %22 = load i16, ptr %21, align 1, !tbaa !20
  %23 = call i64 @IScsiConnLogin(ptr noundef nonnull %17, i16 noundef zeroext %22)
  %24 = icmp slt i64 %23, 0
  br i1 %24, label %25, label %31

25:                                               ; preds = %19
  call void @IScsiConnReset(ptr noundef nonnull %17)
  call void @IScsiDetatchConnection(ptr noundef nonnull %17)
  call void @IScsiDestroyConnection(ptr noundef nonnull %17)
  %.not36 = icmp eq i64 %23, -9223372036854775790
  br i1 %.not36, label %26, label %.thread43

26:                                               ; preds = %25
  %27 = add i8 %.0, 1
  %28 = load ptr, ptr %12, align 8, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %28, i64 559
  %30 = load i8, ptr %29, align 1, !tbaa !24
  %.not37 = icmp ugt i8 %27, %30
  br i1 %.not37, label %.thread43, label %16, !llvm.loop !25

31:                                               ; preds = %19
  %32 = getelementptr inbounds i8, ptr %0, i64 2120
  store i8 1, ptr %32, align 8, !tbaa !27
  %33 = getelementptr inbounds i8, ptr %17, i64 112
  %34 = load i8, ptr %33, align 8, !tbaa !28
  %.not38 = icmp eq i8 %34, 0
  %gEfiTcp4ProtocolGuid.gEfiTcp6ProtocolGuid = select i1 %.not38, ptr @gEfiTcp4ProtocolGuid, ptr @gEfiTcp6ProtocolGuid
  %35 = load ptr, ptr @gBS, align 8, !tbaa !33
  %36 = getelementptr inbounds i8, ptr %35, i64 280
  %37 = load ptr, ptr %36, align 8, !tbaa !34
  %38 = getelementptr inbounds i8, ptr %17, i64 144
  %39 = load ptr, ptr %38, align 8, !tbaa !37
  %40 = load ptr, ptr %4, align 8, !tbaa !8
  %41 = getelementptr inbounds i8, ptr %40, i64 8
  %42 = load ptr, ptr %41, align 8, !tbaa !38
  %43 = getelementptr inbounds i8, ptr %40, i64 120
  %44 = load ptr, ptr %43, align 8, !tbaa !39
  %45 = call i64 %37(ptr noundef %39, ptr noundef nonnull %gEfiTcp4ProtocolGuid.gEfiTcp6ProtocolGuid, ptr noundef nonnull %2, ptr noundef %42, ptr noundef %44, i32 noundef 8) #3
  %46 = call zeroext i8 @DebugAssertEnabled() #3
  %47 = icmp ne i8 %46, 0
  %48 = icmp slt i64 %45, 0
  %or.cond = select i1 %47, i1 %48, i1 false
  br i1 %or.cond, label %49, label %55

49:                                               ; preds = %31
  %50 = call zeroext i8 @DebugPrintEnabled() #3
  %.not39 = icmp eq i8 %50, 0
  br i1 %.not39, label %54, label %51

51:                                               ; preds = %49
  %52 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not40 = icmp eq i8 %52, 0
  br i1 %.not40, label %54, label %53

53:                                               ; preds = %51
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str, i64 noundef %45) #3
  br label %54

54:                                               ; preds = %51, %53, %49
  call void @DebugAssert(ptr noundef nonnull @.str.1, i64 noundef 490, ptr noundef nonnull @.str.2) #3
  br label %55

55:                                               ; preds = %54, %31
  %56 = load i8, ptr %33, align 8, !tbaa !28
  %.not41 = icmp eq i8 %56, 0
  br i1 %.not41, label %.thread43, label %57

57:                                               ; preds = %55
  %58 = call i64 @IScsiGetIp6NicInfo(ptr noundef nonnull %17)
  br label %.thread43

.thread43:                                        ; preds = %26, %25, %16, %57, %55, %1
  %.031 = phi i64 [ -9223372036854775796, %1 ], [ %58, %57 ], [ %45, %55 ], [ -9223372036854775790, %26 ], [ %23, %25 ], [ -9223372036854775799, %16 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret i64 %.031
}

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #2

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

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

declare void @DebugAssert(ptr noundef, i64 noundef, 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"_ISCSI_SESSION", !10, i64 0, !11, i64 8, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 2120, !6, i64 2121, !12, i64 2128, !10, i64 2132, !10, i64 2136, !10, i64 2140, !10, i64 2144, !12, i64 2148, !13, i64 2152, !10, i64 2168, !13, i64 2176, !12, i64 2192, !10, i64 2196, !6, i64 2200, !6, i64 2201, !10, i64 2204, !10, i64 2208, !10, i64 2212, !10, i64 2216, !12, i64 2220, !6, i64 2222, !6, i64 2223, !6, i64 2224}
!10 = !{!"int", !6, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!"short", !6, i64 0}
!13 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!14 = !{!15, !11, i64 16}
!15 = !{!"_ISCSI_DRIVER_DATA", !10, i64 0, !11, i64 8, !11, i64 16, !16, i64 24, !11, i64 32, !17, i64 40, !18, i64 104, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144}
!16 = !{!"_ISCSI_PRIVATE_PROTOCOL", !10, i64 0}
!17 = !{!"_EFI_EXT_SCSI_PASS_THRU_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!18 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!19 = !{!9, !11, i64 16}
!20 = !{!21, !12, i64 557}
!21 = !{!"_ISCSI_ATTEMPT_CONFIG_NVDATA", !13, i64 0, !6, i64 16, !6, i64 17, !6, i64 18, !6, i64 19, !6, i64 20, !6, i64 21, !12, i64 22, !12, i64 24, !6, i64 26, !6, i64 122, !6, i64 218, !6, i64 234, !6, i64 250, !22, i64 266, !6, i64 566, !6, i64 567}
!22 = !{!"_ISCSI_SESSION_CONFIG_NVDATA", !12, i64 0, !6, i64 2, !6, i64 3, !6, i64 4, !23, i64 20, !6, i64 24, !6, i64 40, !6, i64 41, !6, i64 42, !6, i64 266, !6, i64 282, !6, i64 283, !12, i64 291, !6, i64 293, !6, i64 294}
!23 = !{!"", !6, i64 0}
!24 = !{!21, !6, i64 559}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!9, !6, i64 2120}
!28 = !{!29, !6, i64 112}
!29 = !{!"_ISCSI_CONNECTION", !10, i64 0, !13, i64 8, !11, i64 24, !11, i64 32, !6, i64 40, !6, i64 41, !6, i64 42, !6, i64 43, !6, i64 44, !6, i64 45, !6, i64 46, !6, i64 47, !12, i64 48, !10, i64 52, !30, i64 56, !6, i64 112, !32, i64 120, !10, i64 288, !10, i64 292, !10, i64 296}
!30 = !{!"", !10, i64 0, !31, i64 8, !13, i64 16, !13, i64 32, !10, i64 48, !10, i64 52}
!31 = !{!"long long", !6, i64 0}
!32 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 64, !6, i64 88, !6, i64 112, !6, i64 136, !6, i64 160, !6, i64 161, !6, i64 162, !6, i64 163, !6, i64 164}
!33 = !{!11, !11, i64 0}
!34 = !{!35, !11, i64 280}
!35 = !{!"", !36, i64 0, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !11, i64 184, !11, i64 192, !11, i64 200, !11, i64 208, !11, i64 216, !11, i64 224, !11, i64 232, !11, i64 240, !11, i64 248, !11, i64 256, !11, i64 264, !11, i64 272, !11, i64 280, !11, i64 288, !11, i64 296, !11, i64 304, !11, i64 312, !11, i64 320, !11, i64 328, !11, i64 336, !11, i64 344, !11, i64 352, !11, i64 360, !11, i64 368}
!36 = !{!"", !31, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!37 = !{!29, !11, i64 144}
!38 = !{!15, !11, i64 8}
!39 = !{!15, !11, i64 120}


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