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

; 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._ISCSI_CONNECTION = type { i32, %struct._LIST_ENTRY, ptr, ptr, i8, i8, i8, i8, i8, i8, i8, i16, i32, %struct.NET_BUF_QUEUE, %struct._TCP4_IO, i32, i32, i32 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.NET_BUF_QUEUE = type { i32, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32 }
%struct._TCP4_IO = type { ptr, ptr, ptr, ptr, %struct.EFI_TCP4_CONNECTION_TOKEN, %struct.EFI_TCP4_IO_TOKEN, %struct.EFI_TCP4_IO_TOKEN, %struct.EFI_TCP4_CLOSE_TOKEN, i8, i8, i8, i8 }
%struct.EFI_TCP4_CONNECTION_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN }
%struct.EFI_TCP4_COMPLETION_TOKEN = type { ptr, i64 }
%struct.EFI_TCP4_IO_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, %union.anon }
%union.anon = type { ptr }
%struct.EFI_TCP4_CLOSE_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, i8 }
%struct._ISCSI_BASIC_HEADER = type { i8, i8, i16, i8, [3 x i8], [8 x i8], i32, [7 x i32] }
%struct._ISCSI_LOGIN_REQUEST = type { i8, i8, i8, i8, i8, [3 x i8], [6 x i8], i16, i32, i16, i16, i32, i32, [4 x i32] }
%struct._ISCSI_SESSION = type { i32, %struct._ISCSI_SESSION_CONFIG_DATA, %struct._ISCSI_CHAP_AUTH_DATA, [224 x i8], i64, 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 }
%struct._ISCSI_SESSION_CONFIG_DATA = type { %struct.ISCSI_SESSION_CONFIG_NVDATA, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS }
%struct.ISCSI_SESSION_CONFIG_NVDATA = type <{ i8, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i8, [224 x i8], %struct.EFI_IPv4_ADDRESS, i16, [8 x i8], [6 x i8] }>
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct._ISCSI_CHAP_AUTH_DATA = type { %struct._ISCSI_CHAP_AUTH_CONFIG_NVDATA, i32, [1024 x i8], i32, [16 x i8], i32, [1024 x i8], i32 }
%struct._ISCSI_CHAP_AUTH_CONFIG_NVDATA = type { i8, [127 x i8], [17 x i8], [127 x i8], [17 x i8] }

@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @IScsiPrepareLoginReq(ptr noundef %0) #2 {
  %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 i64, align 8
  %8 = 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
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %9, i32 0, i32 3
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = call ptr @NetbufAlloc(i32 noundef 8240)
  store ptr %12, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %158

16:                                               ; preds = %1
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call ptr @NetbufAllocSpace(ptr noundef %17, i32 noundef 48, i8 noundef zeroext 0)
  store ptr %18, ptr %6, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %16
  %20 = call zeroext i8 @DebugAssertEnabled()
  %21 = icmp ne i8 %20, 0
  br i1 %21, label %22, label %27

22:                                               ; preds = %19
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  call void @DebugAssert(ptr noundef @.str, i64 noundef 518, ptr noundef @.str.2)
  br label %26

26:                                               ; preds = %25, %22
  br label %27

27:                                               ; preds = %26, %19
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call ptr @ZeroMem(ptr noundef %30, i64 noundef 48)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %32, i32 0, i32 0
  store i8 67, ptr %33, align 4, !tbaa !20
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %34, i32 0, i32 1
  %36 = load i8, ptr %35, align 1, !tbaa !22
  %37 = zext i8 %36 to i32
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %38, i32 0, i32 5
  %40 = load i8, ptr %39, align 1, !tbaa !24
  %41 = zext i8 %40 to i32
  %42 = shl i32 %41, 2
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %43, i32 0, i32 6
  %45 = load i8, ptr %44, align 2, !tbaa !25
  %46 = zext i8 %45 to i32
  %47 = or i32 %42, %46
  %48 = or i32 %37, %47
  %49 = trunc i32 %48 to i8
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %50, i32 0, i32 1
  store i8 %49, ptr %51, align 1, !tbaa !22
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %52, i32 0, i32 2
  store i8 0, ptr %53, align 2, !tbaa !26
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %54, i32 0, i32 3
  store i8 0, ptr %55, align 1, !tbaa !27
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %56, i32 0, i32 7
  %58 = load i16, ptr %57, align 8, !tbaa !28
  %59 = call zeroext i16 @SwapBytes16(i16 noundef zeroext %58)
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %60, i32 0, i32 7
  store i16 %59, ptr %61, align 2, !tbaa !35
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %62, i32 0, i32 11
  %64 = load i32, ptr %63, align 8, !tbaa !36
  %65 = call i32 @SwapBytes32(i32 noundef %64)
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %66, i32 0, i32 8
  store i32 %65, ptr %67, align 4, !tbaa !37
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %68, i32 0, i32 11
  %70 = load i16, ptr %69, align 8, !tbaa !38
  %71 = call zeroext i16 @SwapBytes16(i16 noundef zeroext %70)
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %72, i32 0, i32 9
  store i16 %71, ptr %73, align 4, !tbaa !39
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %74, i32 0, i32 8
  %76 = load i32, ptr %75, align 4, !tbaa !40
  %77 = call i32 @SwapBytes32(i32 noundef %76)
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %78, i32 0, i32 11
  store i32 %77, ptr %79, align 4, !tbaa !41
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %80, i32 0, i32 12
  %82 = load i32, ptr %81, align 4, !tbaa !42
  %83 = call i32 @SwapBytes32(i32 noundef %82)
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %84, i32 0, i32 12
  store i32 %83, ptr %85, align 4, !tbaa !43
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._ISCSI_LOGIN_REQUEST, ptr %86, i32 0, i32 6
  %88 = getelementptr inbounds [6 x i8], ptr %87, i64 0, i64 0
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %89, i32 0, i32 6
  %91 = getelementptr inbounds [6 x i8], ptr %90, i64 0, i64 0
  %92 = call ptr @CopyMem(ptr noundef %88, ptr noundef %91, i64 noundef 6)
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %93, i32 0, i32 9
  %95 = load i8, ptr %94, align 1, !tbaa !44
  %96 = icmp ne i8 %95, 0
  br i1 %96, label %97, label %99

97:                                               ; preds = %29
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %98, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %158

99:                                               ; preds = %29
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %100, i32 0, i32 5
  %102 = load i8, ptr %101, align 1, !tbaa !24
  %103 = zext i8 %102 to i32
  switch i32 %103, label %118 [
    i32 0, label %104
    i32 1, label %108
  ]

104:                                              ; preds = %99
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = call i64 @IScsiCHAPToSendReq(ptr noundef %105, ptr noundef %106)
  store i64 %107, ptr %7, align 8, !tbaa !45
  br label %119

108:                                              ; preds = %99
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = call i64 @IScsiFillOpParams(ptr noundef %109, ptr noundef %110)
  store i64 %111, ptr %7, align 8, !tbaa !45
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %112, i32 0, i32 1
  %114 = load i8, ptr %113, align 1, !tbaa !46
  %115 = zext i8 %114 to i32
  %116 = or i32 %115, 128
  %117 = trunc i32 %116 to i8
  store i8 %117, ptr %113, align 1, !tbaa !46
  br label %119

118:                                              ; preds = %99
  store i64 -9223372036854775801, ptr %7, align 8, !tbaa !45
  br label %119

119:                                              ; preds = %118, %108, %104
  %120 = load i64, ptr %7, align 8, !tbaa !45
  %121 = icmp slt i64 %120, 0
  br i1 %121, label %122, label %124

122:                                              ; preds = %119
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %123)
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %156

124:                                              ; preds = %119
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = load ptr, ptr %6, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %126, i32 0, i32 4
  %128 = getelementptr inbounds [3 x i8], ptr %127, i64 0, i64 0
  %129 = load i8, ptr %128, align 1, !tbaa !47
  %130 = zext i8 %129 to i32
  %131 = shl i32 %130, 16
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %132, i32 0, i32 4
  %134 = getelementptr inbounds [3 x i8], ptr %133, i64 0, i64 1
  %135 = load i8, ptr %134, align 1, !tbaa !47
  %136 = zext i8 %135 to i32
  %137 = shl i32 %136, 8
  %138 = or i32 %131, %137
  %139 = load ptr, ptr %6, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %139, i32 0, i32 4
  %141 = getelementptr inbounds [3 x i8], ptr %140, i64 0, i64 2
  %142 = load i8, ptr %141, align 1, !tbaa !47
  %143 = zext i8 %142 to i32
  %144 = or i32 %138, %143
  %145 = call i64 @IScsiPadSegment(ptr noundef %125, i32 noundef %144)
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %146, i32 0, i32 1
  %148 = load i8, ptr %147, align 1, !tbaa !46
  %149 = zext i8 %148 to i32
  %150 = and i32 %149, 128
  %151 = icmp eq i32 %150, 128
  %152 = zext i1 %151 to i32
  %153 = trunc i32 %152 to i8
  %154 = load ptr, ptr %3, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %154, i32 0, i32 10
  store i8 %153, ptr %155, align 2, !tbaa !48
  br label %156

156:                                              ; preds = %124, %122
  %157 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %157, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %158

158:                                              ; preds = %156, %97, %15
  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
  %159 = load ptr, ptr %2, align 8
  ret ptr %159
}

declare void @NetbufFree(ptr noundef) #1

declare zeroext i8 @DebugAssertEnabled() #1

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

declare ptr @NetbufAllocSpace(ptr noundef, i32 noundef, i8 noundef zeroext) #1

declare ptr @NetbufAlloc(i32 noundef) #1

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

declare zeroext i16 @SwapBytes16(i16 noundef zeroext) #1

declare i32 @SwapBytes32(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @IScsiFillOpParams(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @IScsiPadSegment(ptr noundef, i32 noundef) #2

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 32}
!10 = !{!"_ISCSI_CONNECTION", !11, i64 0, !12, 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, !13, i64 48, !11, i64 52, !14, i64 56, !16, i64 112, !11, i64 240, !11, i64 244, !11, i64 248}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !11, i64 0, !15, i64 8, !12, i64 16, !12, i64 32, !11, i64 48, !11, i64 52}
!15 = !{!"long long", !7, i64 0}
!16 = !{!"_TCP4_IO", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !17, i64 32, !19, i64 48, !19, i64 72, !19, i64 96, !7, i64 120, !7, i64 121, !7, i64 122, !7, i64 123}
!17 = !{!"", !18, i64 0}
!18 = !{!"", !6, i64 0, !15, i64 8}
!19 = !{!"", !18, i64 0, !7, i64 16}
!20 = !{!21, !7, i64 0}
!21 = !{!"_ISCSI_BASIC_HEADER", !7, i64 0, !7, i64 1, !13, i64 2, !7, i64 4, !7, i64 5, !7, i64 8, !11, i64 16, !7, i64 20}
!22 = !{!23, !7, i64 1}
!23 = !{!"_ISCSI_LOGIN_REQUEST", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 8, !13, i64 14, !11, i64 16, !13, i64 20, !13, i64 22, !11, i64 24, !11, i64 28, !7, i64 32}
!24 = !{!10, !7, i64 41}
!25 = !{!10, !7, i64 42}
!26 = !{!23, !7, i64 2}
!27 = !{!23, !7, i64 3}
!28 = !{!29, !13, i64 2888}
!29 = !{!"_ISCSI_SESSION", !11, i64 0, !30, i64 4, !33, i64 276, !7, i64 2648, !15, i64 2872, !7, i64 2880, !7, i64 2881, !13, i64 2888, !11, i64 2892, !11, i64 2896, !11, i64 2900, !11, i64 2904, !13, i64 2908, !12, i64 2912, !11, i64 2928, !12, i64 2936, !13, i64 2952, !11, i64 2956, !7, i64 2960, !7, i64 2961, !11, i64 2964, !11, i64 2968, !11, i64 2972, !11, i64 2976, !13, i64 2980, !7, i64 2982, !7, i64 2983, !7, i64 2984}
!30 = !{!"_ISCSI_SESSION_CONFIG_DATA", !31, i64 0, !32, i64 259, !32, i64 263, !32, i64 267}
!31 = !{!"", !7, i64 0, !7, i64 1, !32, i64 2, !32, i64 6, !32, i64 10, !7, i64 14, !7, i64 15, !32, i64 239, !13, i64 243, !7, i64 245, !7, i64 253}
!32 = !{!"", !7, i64 0}
!33 = !{!"_ISCSI_CHAP_AUTH_DATA", !34, i64 0, !11, i64 292, !7, i64 296, !11, i64 1320, !7, i64 1324, !11, i64 1340, !7, i64 1344, !11, i64 2368}
!34 = !{!"_ISCSI_CHAP_AUTH_CONFIG_NVDATA", !7, i64 0, !7, i64 1, !7, i64 128, !7, i64 145, !7, i64 272}
!35 = !{!23, !13, i64 14}
!36 = !{!29, !11, i64 2904}
!37 = !{!23, !11, i64 16}
!38 = !{!10, !13, i64 48}
!39 = !{!23, !13, i64 20}
!40 = !{!29, !11, i64 2892}
!41 = !{!23, !11, i64 24}
!42 = !{!10, !11, i64 52}
!43 = !{!23, !11, i64 28}
!44 = !{!10, !7, i64 45}
!45 = !{!15, !15, i64 0}
!46 = !{!21, !7, i64 1}
!47 = !{!7, !7, i64 0}
!48 = !{!10, !7, i64 46}


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

@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @IScsiPrepareLoginReq(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = tail call ptr @NetbufAlloc(i32 noundef 8240) #2
  %5 = icmp eq ptr %4, null
  br i1 %5, label %77, label %6

6:                                                ; preds = %1
  %7 = tail call ptr @NetbufAllocSpace(ptr noundef nonnull %4, i32 noundef 48, i8 noundef zeroext 0) #2
  %8 = tail call zeroext i8 @DebugAssertEnabled() #2
  %9 = icmp eq i8 %8, 0
  %10 = icmp ne ptr %7, null
  %or.cond = select i1 %9, i1 true, i1 %10
  br i1 %or.cond, label %12, label %11

11:                                               ; preds = %6
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 518, ptr noundef nonnull @.str.2) #2
  br label %12

12:                                               ; preds = %11, %6
  %13 = tail call ptr @ZeroMem(ptr noundef %7, i64 noundef 48) #2
  store i8 67, ptr %7, align 4, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %7, i64 1
  %15 = load i8, ptr %14, align 1, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %0, i64 41
  %17 = load i8, ptr %16, align 1, !tbaa !23
  %18 = shl i8 %17, 2
  %19 = getelementptr inbounds i8, ptr %0, i64 42
  %20 = load i8, ptr %19, align 2, !tbaa !24
  %21 = or i8 %20, %15
  %22 = or i8 %21, %18
  store i8 %22, ptr %14, align 1, !tbaa !21
  %23 = getelementptr inbounds i8, ptr %7, i64 2
  store i8 0, ptr %23, align 2, !tbaa !25
  %24 = getelementptr inbounds i8, ptr %7, i64 3
  store i8 0, ptr %24, align 1, !tbaa !26
  %25 = getelementptr inbounds i8, ptr %3, i64 2888
  %26 = load i16, ptr %25, align 8, !tbaa !27
  %27 = tail call zeroext i16 @SwapBytes16(i16 noundef zeroext %26) #2
  %28 = getelementptr inbounds i8, ptr %7, i64 14
  store i16 %27, ptr %28, align 2, !tbaa !34
  %29 = getelementptr inbounds i8, ptr %3, i64 2904
  %30 = load i32, ptr %29, align 8, !tbaa !35
  %31 = tail call i32 @SwapBytes32(i32 noundef %30) #2
  %32 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 %31, ptr %32, align 4, !tbaa !36
  %33 = getelementptr inbounds i8, ptr %0, i64 48
  %34 = load i16, ptr %33, align 8, !tbaa !37
  %35 = tail call zeroext i16 @SwapBytes16(i16 noundef zeroext %34) #2
  %36 = getelementptr inbounds i8, ptr %7, i64 20
  store i16 %35, ptr %36, align 4, !tbaa !38
  %37 = getelementptr inbounds i8, ptr %3, i64 2892
  %38 = load i32, ptr %37, align 4, !tbaa !39
  %39 = tail call i32 @SwapBytes32(i32 noundef %38) #2
  %40 = getelementptr inbounds i8, ptr %7, i64 24
  store i32 %39, ptr %40, align 4, !tbaa !40
  %41 = getelementptr inbounds i8, ptr %0, i64 52
  %42 = load i32, ptr %41, align 4, !tbaa !41
  %43 = tail call i32 @SwapBytes32(i32 noundef %42) #2
  %44 = getelementptr inbounds i8, ptr %7, i64 28
  store i32 %43, ptr %44, align 4, !tbaa !42
  %45 = getelementptr inbounds i8, ptr %7, i64 8
  %46 = getelementptr inbounds i8, ptr %3, i64 2881
  %47 = tail call ptr @CopyMem(ptr noundef nonnull %45, ptr noundef nonnull %46, i64 noundef 6) #2
  %48 = getelementptr inbounds i8, ptr %0, i64 45
  %49 = load i8, ptr %48, align 1, !tbaa !43
  %.not = icmp eq i8 %49, 0
  br i1 %.not, label %50, label %77

50:                                               ; preds = %12
  %51 = load i8, ptr %16, align 1, !tbaa !23
  switch i8 %51, label %.thread [
    i8 0, label %52
    i8 1, label %54
  ]

52:                                               ; preds = %50
  %53 = tail call i64 @IScsiCHAPToSendReq(ptr noundef nonnull %0, ptr noundef nonnull %4) #2
  br label %58

54:                                               ; preds = %50
  %55 = tail call i64 @IScsiFillOpParams(ptr noundef nonnull %0, ptr noundef nonnull %4)
  %56 = load i8, ptr %14, align 1, !tbaa !44
  %57 = or i8 %56, -128
  store i8 %57, ptr %14, align 1, !tbaa !44
  br label %58

58:                                               ; preds = %54, %52
  %.0 = phi i64 [ %55, %54 ], [ %53, %52 ]
  %59 = icmp slt i64 %.0, 0
  br i1 %59, label %.thread, label %60

.thread:                                          ; preds = %50, %58
  tail call void @NetbufFree(ptr noundef nonnull %4) #2
  br label %77

60:                                               ; preds = %58
  %61 = getelementptr inbounds i8, ptr %7, i64 5
  %62 = load i8, ptr %61, align 1, !tbaa !45
  %63 = zext i8 %62 to i32
  %64 = shl nuw nsw i32 %63, 16
  %65 = getelementptr inbounds i8, ptr %7, i64 6
  %66 = load i8, ptr %65, align 1, !tbaa !45
  %67 = zext i8 %66 to i32
  %68 = shl nuw nsw i32 %67, 8
  %69 = or disjoint i32 %68, %64
  %70 = getelementptr inbounds i8, ptr %7, i64 7
  %71 = load i8, ptr %70, align 1, !tbaa !45
  %72 = zext i8 %71 to i32
  %73 = or disjoint i32 %69, %72
  %74 = tail call i64 @IScsiPadSegment(ptr noundef nonnull %4, i32 noundef %73)
  %75 = load i8, ptr %14, align 1, !tbaa !44
  %.lobit = lshr i8 %75, 7
  %76 = getelementptr inbounds i8, ptr %0, i64 46
  store i8 %.lobit, ptr %76, align 2, !tbaa !46
  br label %77

77:                                               ; preds = %.thread, %60, %12, %1
  %.042 = phi ptr [ null, %1 ], [ %4, %12 ], [ null, %.thread ], [ %4, %60 ]
  ret ptr %.042
}

declare void @NetbufFree(ptr noundef) local_unnamed_addr #0

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

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

declare ptr @NetbufAllocSpace(ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #0

declare ptr @NetbufAlloc(i32 noundef) local_unnamed_addr #0

declare ptr @ZeroMem(ptr noundef, i64 noundef) local_unnamed_addr #0

declare zeroext i16 @SwapBytes16(i16 noundef zeroext) local_unnamed_addr #0

declare i32 @SwapBytes32(i32 noundef) local_unnamed_addr #0

declare i64 @IScsiCHAPToSendReq(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @IScsiFillOpParams(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @IScsiPadSegment(ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #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 = { 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 = { 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, !11, i64 32}
!6 = !{!"_ISCSI_CONNECTION", !7, i64 0, !10, i64 8, !11, i64 24, !11, i64 32, !8, i64 40, !8, i64 41, !8, i64 42, !8, i64 43, !8, i64 44, !8, i64 45, !8, i64 46, !12, i64 48, !7, i64 52, !13, i64 56, !15, i64 112, !7, i64 240, !7, i64 244, !7, i64 248}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!"", !7, i64 0, !14, i64 8, !10, i64 16, !10, i64 32, !7, i64 48, !7, i64 52}
!14 = !{!"long long", !8, i64 0}
!15 = !{!"_TCP4_IO", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !16, i64 32, !18, i64 48, !18, i64 72, !18, i64 96, !8, i64 120, !8, i64 121, !8, i64 122, !8, i64 123}
!16 = !{!"", !17, i64 0}
!17 = !{!"", !11, i64 0, !14, i64 8}
!18 = !{!"", !17, i64 0, !8, i64 16}
!19 = !{!20, !8, i64 0}
!20 = !{!"_ISCSI_BASIC_HEADER", !8, i64 0, !8, i64 1, !12, i64 2, !8, i64 4, !8, i64 5, !8, i64 8, !7, i64 16, !8, i64 20}
!21 = !{!22, !8, i64 1}
!22 = !{!"_ISCSI_LOGIN_REQUEST", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 8, !12, i64 14, !7, i64 16, !12, i64 20, !12, i64 22, !7, i64 24, !7, i64 28, !8, i64 32}
!23 = !{!6, !8, i64 41}
!24 = !{!6, !8, i64 42}
!25 = !{!22, !8, i64 2}
!26 = !{!22, !8, i64 3}
!27 = !{!28, !12, i64 2888}
!28 = !{!"_ISCSI_SESSION", !7, i64 0, !29, i64 4, !32, i64 276, !8, i64 2648, !14, i64 2872, !8, i64 2880, !8, i64 2881, !12, i64 2888, !7, i64 2892, !7, i64 2896, !7, i64 2900, !7, i64 2904, !12, i64 2908, !10, i64 2912, !7, i64 2928, !10, i64 2936, !12, i64 2952, !7, i64 2956, !8, i64 2960, !8, i64 2961, !7, i64 2964, !7, i64 2968, !7, i64 2972, !7, i64 2976, !12, i64 2980, !8, i64 2982, !8, i64 2983, !8, i64 2984}
!29 = !{!"_ISCSI_SESSION_CONFIG_DATA", !30, i64 0, !31, i64 259, !31, i64 263, !31, i64 267}
!30 = !{!"", !8, i64 0, !8, i64 1, !31, i64 2, !31, i64 6, !31, i64 10, !8, i64 14, !8, i64 15, !31, i64 239, !12, i64 243, !8, i64 245, !8, i64 253}
!31 = !{!"", !8, i64 0}
!32 = !{!"_ISCSI_CHAP_AUTH_DATA", !33, i64 0, !7, i64 292, !8, i64 296, !7, i64 1320, !8, i64 1324, !7, i64 1340, !8, i64 1344, !7, i64 2368}
!33 = !{!"_ISCSI_CHAP_AUTH_CONFIG_NVDATA", !8, i64 0, !8, i64 1, !8, i64 128, !8, i64 145, !8, i64 272}
!34 = !{!22, !12, i64 14}
!35 = !{!28, !7, i64 2904}
!36 = !{!22, !7, i64 16}
!37 = !{!6, !12, i64 48}
!38 = !{!22, !12, i64 20}
!39 = !{!28, !7, i64 2892}
!40 = !{!22, !7, i64 24}
!41 = !{!6, !7, i64 52}
!42 = !{!22, !7, i64 28}
!43 = !{!6, !8, i64 45}
!44 = !{!20, !8, i64 1}
!45 = !{!8, !8, i64 0}
!46 = !{!6, !8, i64 46}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass