; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe (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, i8, i16, i32, %struct.NET_BUF_QUEUE, i8, %struct.TCP_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.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._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, 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 }

@.str.1 = external hidden unnamed_addr constant [134 x i8], align 1
@.str.4 = 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

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

declare zeroext i8 @DebugAssertEnabled() #1

declare void @DebugAssert(ptr noundef, i64 noundef, ptr 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 %170

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.1, i64 noundef 734, ptr noundef @.str.4)
  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 !17
  %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 !19
  %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 !21
  %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 !22
  %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 !19
  %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 !23
  %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 !24
  %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 !25
  %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 !27
  %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 !28
  %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 !29
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %68, i32 0, i32 12
  %70 = load i16, ptr %69, align 8, !tbaa !30
  %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 !31
  %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 !32
  %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 !33
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %80, i32 0, i32 13
  %82 = load i32, ptr %81, align 4, !tbaa !34
  %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 !35
  %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 !36
  %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 %170

99:                                               ; preds = %29
  store i64 0, ptr %7, align 8, !tbaa !37
  %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 !21
  %103 = zext i8 %102 to i32
  switch i32 %103, label %130 [
    i32 0, label %104
    i32 1, label %115
  ]

104:                                              ; preds = %99
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %105, i32 0, i32 3
  %107 = load i8, ptr %106, align 8, !tbaa !38
  %108 = zext i8 %107 to i32
  %109 = icmp ne i32 %108, 2
  br i1 %109, label %110, label %114

110:                                              ; preds = %104
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = call i64 @IScsiCHAPToSendReq(ptr noundef %111, ptr noundef %112)
  store i64 %113, ptr %7, align 8, !tbaa !37
  br label %114

114:                                              ; preds = %110, %104
  br label %131

115:                                              ; preds = %99
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %116, i32 0, i32 11
  %118 = load i8, ptr %117, align 1, !tbaa !39
  %119 = icmp ne i8 %118, 0
  br i1 %119, label %123, label %120

120:                                              ; preds = %115
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  call void @IScsiFillOpParams(ptr noundef %121, ptr noundef %122)
  br label %123

123:                                              ; preds = %120, %115
  %124 = load ptr, ptr %6, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %124, i32 0, i32 1
  %126 = load i8, ptr %125, align 1, !tbaa !40
  %127 = zext i8 %126 to i32
  %128 = or i32 %127, 128
  %129 = trunc i32 %128 to i8
  store i8 %129, ptr %125, align 1, !tbaa !40
  br label %131

130:                                              ; preds = %99
  store i64 -9223372036854775801, ptr %7, align 8, !tbaa !37
  br label %131

131:                                              ; preds = %130, %123, %114
  %132 = load i64, ptr %7, align 8, !tbaa !37
  %133 = icmp slt i64 %132, 0
  br i1 %133, label %134, label %136

134:                                              ; preds = %131
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %135)
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %168

136:                                              ; preds = %131
  %137 = load ptr, ptr %5, align 8, !tbaa !5
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %138, i32 0, i32 4
  %140 = getelementptr inbounds [3 x i8], ptr %139, i64 0, i64 0
  %141 = load i8, ptr %140, align 1, !tbaa !41
  %142 = zext i8 %141 to i32
  %143 = shl i32 %142, 16
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %144, i32 0, i32 4
  %146 = getelementptr inbounds [3 x i8], ptr %145, i64 0, i64 1
  %147 = load i8, ptr %146, align 1, !tbaa !41
  %148 = zext i8 %147 to i32
  %149 = shl i32 %148, 8
  %150 = or i32 %143, %149
  %151 = load ptr, ptr %6, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %151, i32 0, i32 4
  %153 = getelementptr inbounds [3 x i8], ptr %152, i64 0, i64 2
  %154 = load i8, ptr %153, align 1, !tbaa !41
  %155 = zext i8 %154 to i32
  %156 = or i32 %150, %155
  %157 = call i64 @IScsiPadSegment(ptr noundef %137, i32 noundef %156)
  %158 = load ptr, ptr %6, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %158, i32 0, i32 1
  %160 = load i8, ptr %159, align 1, !tbaa !40
  %161 = zext i8 %160 to i32
  %162 = and i32 %161, 128
  %163 = icmp eq i32 %162, 128
  %164 = zext i1 %163 to i32
  %165 = trunc i32 %164 to i8
  %166 = load ptr, ptr %3, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %166, i32 0, i32 10
  store i8 %165, ptr %167, align 2, !tbaa !42
  br label %168

168:                                              ; preds = %136, %134
  %169 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %169, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %170

170:                                              ; preds = %168, %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
  %171 = load ptr, ptr %2, align 8
  ret ptr %171
}

declare void @NetbufFree(ptr noundef) #1

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

declare ptr @NetbufAlloc(i32 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 void @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, !7, i64 47, !13, i64 48, !11, i64 52, !14, i64 56, !7, i64 112, !16, i64 120, !11, i64 288, !11, i64 292, !11, i64 296}
!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 = !{!"", !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}
!17 = !{!18, !7, i64 0}
!18 = !{!"_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}
!19 = !{!20, !7, i64 1}
!20 = !{!"_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}
!21 = !{!10, !7, i64 41}
!22 = !{!10, !7, i64 42}
!23 = !{!20, !7, i64 2}
!24 = !{!20, !7, i64 3}
!25 = !{!26, !13, i64 2128}
!26 = !{!"_ISCSI_SESSION", !11, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !7, i64 32, !7, i64 2120, !7, i64 2121, !13, i64 2128, !11, i64 2132, !11, i64 2136, !11, i64 2140, !11, i64 2144, !13, i64 2148, !12, i64 2152, !11, i64 2168, !12, i64 2176, !13, i64 2192, !11, i64 2196, !7, i64 2200, !7, i64 2201, !11, i64 2204, !11, i64 2208, !11, i64 2212, !11, i64 2216, !13, i64 2220, !7, i64 2222, !7, i64 2223, !7, i64 2224}
!27 = !{!20, !13, i64 14}
!28 = !{!26, !11, i64 2144}
!29 = !{!20, !11, i64 16}
!30 = !{!10, !13, i64 48}
!31 = !{!20, !13, i64 20}
!32 = !{!26, !11, i64 2132}
!33 = !{!20, !11, i64 24}
!34 = !{!10, !11, i64 52}
!35 = !{!20, !11, i64 28}
!36 = !{!10, !7, i64 45}
!37 = !{!15, !15, i64 0}
!38 = !{!26, !7, i64 24}
!39 = !{!10, !7, i64 47}
!40 = !{!18, !7, i64 1}
!41 = !{!7, !7, i64 0}
!42 = !{!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.1 = external hidden unnamed_addr constant [134 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1

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

declare ptr @ZeroMem(ptr noundef, i64 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

; 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 %81, 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.1, i64 noundef 734, ptr noundef nonnull @.str.4) #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 !16
  %14 = getelementptr inbounds i8, ptr %7, i64 1
  %15 = load i8, ptr %14, align 1, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %0, i64 41
  %17 = load i8, ptr %16, align 1, !tbaa !20
  %18 = shl i8 %17, 2
  %19 = getelementptr inbounds i8, ptr %0, i64 42
  %20 = load i8, ptr %19, align 2, !tbaa !21
  %21 = or i8 %20, %15
  %22 = or i8 %21, %18
  store i8 %22, ptr %14, align 1, !tbaa !18
  %23 = getelementptr inbounds i8, ptr %7, i64 2
  store i8 0, ptr %23, align 2, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %7, i64 3
  store i8 0, ptr %24, align 1, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %3, i64 2128
  %26 = load i16, ptr %25, align 8, !tbaa !24
  %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 !26
  %29 = getelementptr inbounds i8, ptr %3, i64 2144
  %30 = load i32, ptr %29, align 8, !tbaa !27
  %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 !28
  %33 = getelementptr inbounds i8, ptr %0, i64 48
  %34 = load i16, ptr %33, align 8, !tbaa !29
  %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 !30
  %37 = getelementptr inbounds i8, ptr %3, i64 2132
  %38 = load i32, ptr %37, align 4, !tbaa !31
  %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 !32
  %41 = getelementptr inbounds i8, ptr %0, i64 52
  %42 = load i32, ptr %41, align 4, !tbaa !33
  %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 !34
  %45 = getelementptr inbounds i8, ptr %7, i64 8
  %46 = getelementptr inbounds i8, ptr %3, i64 2121
  %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 !35
  %.not = icmp eq i8 %49, 0
  br i1 %.not, label %50, label %81

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

52:                                               ; preds = %50
  %53 = getelementptr inbounds i8, ptr %3, i64 24
  %54 = load i8, ptr %53, align 8, !tbaa !36
  %.not48 = icmp eq i8 %54, 2
  br i1 %.not48, label %.critedge, label %55

55:                                               ; preds = %52
  %56 = tail call i64 @IScsiCHAPToSendReq(ptr noundef nonnull %0, ptr noundef nonnull %4) #2
  %57 = icmp slt i64 %56, 0
  br i1 %57, label %.critedge50, label %.critedge

58:                                               ; preds = %50
  %59 = getelementptr inbounds i8, ptr %0, i64 47
  %60 = load i8, ptr %59, align 1, !tbaa !37
  %.not47 = icmp eq i8 %60, 0
  br i1 %.not47, label %61, label %62

61:                                               ; preds = %58
  tail call void @IScsiFillOpParams(ptr noundef nonnull %0, ptr noundef nonnull %4)
  br label %62

62:                                               ; preds = %61, %58
  %63 = load i8, ptr %14, align 1, !tbaa !38
  %64 = or i8 %63, -128
  store i8 %64, ptr %14, align 1, !tbaa !38
  br label %.critedge

.critedge50:                                      ; preds = %50, %55
  tail call void @NetbufFree(ptr noundef nonnull %4) #2
  br label %81

.critedge:                                        ; preds = %62, %52, %55
  %65 = getelementptr inbounds i8, ptr %7, i64 5
  %66 = load i8, ptr %65, align 1, !tbaa !39
  %67 = zext i8 %66 to i32
  %68 = shl nuw nsw i32 %67, 16
  %69 = getelementptr inbounds i8, ptr %7, i64 6
  %70 = load i8, ptr %69, align 1, !tbaa !39
  %71 = zext i8 %70 to i32
  %72 = shl nuw nsw i32 %71, 8
  %73 = or disjoint i32 %72, %68
  %74 = getelementptr inbounds i8, ptr %7, i64 7
  %75 = load i8, ptr %74, align 1, !tbaa !39
  %76 = zext i8 %75 to i32
  %77 = or disjoint i32 %73, %76
  %78 = tail call i64 @IScsiPadSegment(ptr noundef nonnull %4, i32 noundef %77)
  %79 = load i8, ptr %14, align 1, !tbaa !38
  %.lobit = lshr i8 %79, 7
  %80 = getelementptr inbounds i8, ptr %0, i64 46
  store i8 %.lobit, ptr %80, align 2, !tbaa !40
  br label %81

81:                                               ; preds = %.critedge50, %.critedge, %12, %1
  %.044 = phi ptr [ null, %1 ], [ %4, %12 ], [ null, %.critedge50 ], [ %4, %.critedge ]
  ret ptr %.044
}

declare void @NetbufFree(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 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 void @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, !8, i64 47, !12, i64 48, !7, i64 52, !13, i64 56, !8, i64 112, !15, i64 120, !7, i64 288, !7, i64 292, !7, i64 296}
!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 = !{!"", !8, i64 0, !11, i64 8, !11, i64 16, !11, 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}
!16 = !{!17, !8, i64 0}
!17 = !{!"_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}
!18 = !{!19, !8, i64 1}
!19 = !{!"_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}
!20 = !{!6, !8, i64 41}
!21 = !{!6, !8, i64 42}
!22 = !{!19, !8, i64 2}
!23 = !{!19, !8, i64 3}
!24 = !{!25, !12, i64 2128}
!25 = !{!"_ISCSI_SESSION", !7, i64 0, !11, i64 8, !11, i64 16, !8, i64 24, !8, i64 32, !8, i64 2120, !8, i64 2121, !12, i64 2128, !7, i64 2132, !7, i64 2136, !7, i64 2140, !7, i64 2144, !12, i64 2148, !10, i64 2152, !7, i64 2168, !10, i64 2176, !12, i64 2192, !7, i64 2196, !8, i64 2200, !8, i64 2201, !7, i64 2204, !7, i64 2208, !7, i64 2212, !7, i64 2216, !12, i64 2220, !8, i64 2222, !8, i64 2223, !8, i64 2224}
!26 = !{!19, !12, i64 14}
!27 = !{!25, !7, i64 2144}
!28 = !{!19, !7, i64 16}
!29 = !{!6, !12, i64 48}
!30 = !{!19, !12, i64 20}
!31 = !{!25, !7, i64 2132}
!32 = !{!19, !7, i64 24}
!33 = !{!6, !7, i64 52}
!34 = !{!19, !7, i64 28}
!35 = !{!6, !8, i64 45}
!36 = !{!25, !8, i64 24}
!37 = !{!6, !8, i64 47}
!38 = !{!17, !8, i64 1}
!39 = !{!8, !8, i64 0}
!40 = !{!6, !8, i64 46}


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