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

; 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_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] }
%struct._ISCSI_BASIC_HEADER = type { i8, i8, i16, i8, [3 x i8], [8 x i8], i32, [7 x i32] }

@.str = external hidden unnamed_addr constant [153 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [3 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 zeroext i8 @DebugAssertEnabled() #1

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

declare ptr @AllocatePool(i64 noundef) #1

declare void @FreePool(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @IScsiCHAPToSendReq(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca [256 x i8], align 16
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 256, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  br label %17

17:                                               ; preds = %2
  %18 = call zeroext i8 @DebugAssertEnabled()
  %19 = icmp ne i8 %18, 0
  br i1 %19, label %20, label %28

20:                                               ; preds = %17
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %21, i32 0, i32 5
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  call void @DebugAssert(ptr noundef @.str, i64 noundef 330, ptr noundef @.str.1)
  br label %27

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

28:                                               ; preds = %27, %17
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %31, i32 0, i32 3
  %33 = load ptr, ptr %32, align 8, !tbaa !20
  store ptr %33, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %34, i32 0, i32 2
  store ptr %35, ptr %9, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = call ptr @NetbufGetByte(ptr noundef %36, i32 noundef 0, ptr noundef null)
  store ptr %37, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %30
  store i64 -9223372036854775784, ptr %3, align 8
  store i32 1, ptr %16, align 4
  br label %159

41:                                               ; preds = %30
  store i64 0, ptr %6, align 8, !tbaa !21
  store i32 35, ptr %13, align 4, !tbaa !22
  %42 = load i32, ptr %13, align 4, !tbaa !22
  %43 = zext i32 %42 to i64
  %44 = call ptr @AllocatePool(i64 noundef %43)
  store ptr %44, ptr %12, align 8, !tbaa !5
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %48

47:                                               ; preds = %41
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %16, align 4
  br label %159

48:                                               ; preds = %41
  store i32 35, ptr %15, align 4, !tbaa !22
  %49 = load i32, ptr %15, align 4, !tbaa !22
  %50 = zext i32 %49 to i64
  %51 = call ptr @AllocatePool(i64 noundef %50)
  store ptr %51, ptr %14, align 8, !tbaa !5
  %52 = load ptr, ptr %14, align 8, !tbaa !5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %48
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %16, align 4
  br label %159

55:                                               ; preds = %48
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %56, i32 0, i32 7
  %58 = load i8, ptr %57, align 1, !tbaa !23
  %59 = zext i8 %58 to i32
  switch i32 %59, label %154 [
    i32 0, label %60
    i32 1, label %93
    i32 3, label %101
  ]

60:                                               ; preds = %55
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %62, i32 0, i32 3
  %64 = getelementptr inbounds [224 x i8], ptr %63, i64 0, i64 0
  %65 = call i64 @IScsiAddKeyValuePair(ptr noundef %61, ptr noundef @.str.12, ptr noundef %64)
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = call i64 @IScsiAddKeyValuePair(ptr noundef %66, ptr noundef @.str.13, ptr noundef @.str.14)
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %69, i32 0, i32 1
  %71 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_DATA, ptr %70, i32 0, i32 0
  %72 = getelementptr inbounds %struct.ISCSI_SESSION_CONFIG_NVDATA, ptr %71, i32 0, i32 6
  %73 = getelementptr inbounds [224 x i8], ptr %72, i64 0, i64 0
  %74 = call i64 @IScsiAddKeyValuePair(ptr noundef %68, ptr noundef @.str.15, ptr noundef %73)
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_DATA, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_CONFIG_NVDATA, ptr %76, i32 0, i32 0
  %78 = load i8, ptr %77, align 4, !tbaa !24
  %79 = zext i8 %78 to i32
  %80 = icmp eq i32 %79, 0
  br i1 %80, label %81, label %88

81:                                               ; preds = %60
  store ptr @.str.16, ptr %10, align 8, !tbaa !5
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %82, i32 0, i32 1
  %84 = load i8, ptr %83, align 1, !tbaa !27
  %85 = zext i8 %84 to i32
  %86 = or i32 %85, 128
  %87 = trunc i32 %86 to i8
  store i8 %87, ptr %83, align 1, !tbaa !27
  br label %89

88:                                               ; preds = %60
  store ptr @.str.5, ptr %10, align 8, !tbaa !5
  br label %89

89:                                               ; preds = %88, %81
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = call i64 @IScsiAddKeyValuePair(ptr noundef %90, ptr noundef @.str.4, ptr noundef %91)
  br label %155

93:                                               ; preds = %55
  %94 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %95 = call i64 (ptr, i64, ptr, ...) @AsciiSPrint(ptr noundef %94, i64 noundef 256, ptr noundef @.str.17, i32 noundef 5)
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %98 = call i64 @IScsiAddKeyValuePair(ptr noundef %96, ptr noundef @.str.6, ptr noundef %97)
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %99, i32 0, i32 7
  store i8 2, ptr %100, align 1, !tbaa !23
  br label %155

101:                                              ; preds = %55
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = load ptr, ptr %9, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_DATA, ptr %103, i32 0, i32 0
  %105 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_CONFIG_NVDATA, ptr %104, i32 0, i32 1
  %106 = call i64 @IScsiAddKeyValuePair(ptr noundef %102, ptr noundef @.str.10, ptr noundef %105)
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_DATA, ptr %107, i32 0, i32 4
  %109 = getelementptr inbounds [16 x i8], ptr %108, i64 0, i64 0
  %110 = load ptr, ptr %12, align 8, !tbaa !5
  %111 = call i64 @IScsiBinToHex(ptr noundef %109, i32 noundef 16, ptr noundef %110, ptr noundef %13)
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = call i64 @IScsiAddKeyValuePair(ptr noundef %112, ptr noundef @.str.11, ptr noundef %113)
  %115 = load ptr, ptr %9, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_DATA, ptr %115, i32 0, i32 0
  %117 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_CONFIG_NVDATA, ptr %116, i32 0, i32 0
  %118 = load i8, ptr %117, align 4, !tbaa !24
  %119 = zext i8 %118 to i32
  %120 = icmp eq i32 %119, 2
  br i1 %120, label %121, label %147

121:                                              ; preds = %101
  %122 = load ptr, ptr %9, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_DATA, ptr %122, i32 0, i32 5
  call void @IScsiGenRandom(ptr noundef %123, i64 noundef 1)
  %124 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %125 = load ptr, ptr %9, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_DATA, ptr %125, i32 0, i32 5
  %127 = load i32, ptr %126, align 4, !tbaa !29
  %128 = call i64 (ptr, i64, ptr, ...) @AsciiSPrint(ptr noundef %124, i64 noundef 256, ptr noundef @.str.17, i32 noundef %127)
  %129 = load ptr, ptr %5, align 8, !tbaa !5
  %130 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %131 = call i64 @IScsiAddKeyValuePair(ptr noundef %129, ptr noundef @.str.7, ptr noundef %130)
  %132 = load ptr, ptr %9, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_DATA, ptr %132, i32 0, i32 6
  %134 = getelementptr inbounds [1024 x i8], ptr %133, i64 0, i64 0
  call void @IScsiGenRandom(ptr noundef %134, i64 noundef 16)
  %135 = load ptr, ptr %9, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_DATA, ptr %135, i32 0, i32 7
  store i32 16, ptr %136, align 4, !tbaa !30
  %137 = load ptr, ptr %9, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct._ISCSI_CHAP_AUTH_DATA, ptr %137, i32 0, i32 6
  %139 = getelementptr inbounds [1024 x i8], ptr %138, i64 0, i64 0
  %140 = load ptr, ptr %14, align 8, !tbaa !5
  %141 = call i64 @IScsiBinToHex(ptr noundef %139, i32 noundef 16, ptr noundef %140, ptr noundef %15)
  %142 = load ptr, ptr %5, align 8, !tbaa !5
  %143 = load ptr, ptr %14, align 8, !tbaa !5
  %144 = call i64 @IScsiAddKeyValuePair(ptr noundef %142, ptr noundef @.str.8, ptr noundef %143)
  %145 = load ptr, ptr %4, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %145, i32 0, i32 7
  store i8 4, ptr %146, align 1, !tbaa !23
  br label %147

147:                                              ; preds = %121, %101
  %148 = load ptr, ptr %8, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %148, i32 0, i32 1
  %150 = load i8, ptr %149, align 1, !tbaa !27
  %151 = zext i8 %150 to i32
  %152 = or i32 %151, 128
  %153 = trunc i32 %152 to i8
  store i8 %153, ptr %149, align 1, !tbaa !27
  br label %155

154:                                              ; preds = %55
  store i64 -9223372036854775784, ptr %6, align 8, !tbaa !21
  br label %155

155:                                              ; preds = %154, %147, %93, %89
  %156 = load ptr, ptr %12, align 8, !tbaa !5
  call void @FreePool(ptr noundef %156)
  %157 = load ptr, ptr %14, align 8, !tbaa !5
  call void @FreePool(ptr noundef %157)
  %158 = load i64, ptr %6, align 8, !tbaa !21
  store i64 %158, ptr %3, align 8
  store i32 1, ptr %16, align 4
  br label %159

159:                                              ; preds = %155, %54, %47, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 256, ptr %11) #3
  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 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %160 = load i64, ptr %3, align 8
  ret i64 %160
}

declare ptr @NetbufGetByte(ptr noundef, i32 noundef, ptr noundef) #1

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

declare i64 @AsciiSPrint(ptr noundef, i64 noundef, ptr noundef, ...) #1

declare i64 @IScsiBinToHex(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 41}
!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 = !{!10, !6, i64 32}
!21 = !{!15, !15, i64 0}
!22 = !{!11, !11, i64 0}
!23 = !{!10, !7, i64 43}
!24 = !{!25, !7, i64 0}
!25 = !{!"_ISCSI_CHAP_AUTH_DATA", !26, i64 0, !11, i64 292, !7, i64 296, !11, i64 1320, !7, i64 1324, !11, i64 1340, !7, i64 1344, !11, i64 2368}
!26 = !{!"_ISCSI_CHAP_AUTH_CONFIG_NVDATA", !7, i64 0, !7, i64 1, !7, i64 128, !7, i64 145, !7, i64 272}
!27 = !{!28, !7, i64 1}
!28 = !{!"_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}
!29 = !{!25, !11, i64 1340}
!30 = !{!25, !11, i64 2368}


; 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 [153 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

declare ptr @AllocatePool(i64 noundef) local_unnamed_addr #1

declare void @FreePool(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775799, 1) i64 @IScsiCHAPToSendReq(ptr nocapture noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca [256 x i8], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %6 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %12, label %7

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 41
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %10 = icmp eq i8 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 330, ptr noundef nonnull @.str.1) #3
  br label %12

12:                                               ; preds = %7, %11, %2
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load ptr, ptr %13, align 8, !tbaa !19
  %15 = getelementptr inbounds i8, ptr %14, i64 276
  %16 = tail call ptr @NetbufGetByte(ptr noundef %1, i32 noundef 0, ptr noundef null) #3
  %17 = icmp eq ptr %16, null
  br i1 %17, label %66, label %18

18:                                               ; preds = %12
  store i32 35, ptr %4, align 4, !tbaa !20
  %19 = tail call ptr @AllocatePool(i64 noundef 35) #3
  %20 = icmp eq ptr %19, null
  br i1 %20, label %66, label %21

21:                                               ; preds = %18
  store i32 35, ptr %5, align 4, !tbaa !20
  %22 = tail call ptr @AllocatePool(i64 noundef 35) #3
  %23 = icmp eq ptr %22, null
  br i1 %23, label %66, label %24

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %0, i64 43
  %26 = load i8, ptr %25, align 1, !tbaa !21
  switch i8 %26, label %65 [
    i8 0, label %27
    i8 1, label %41
    i8 3, label %44
  ]

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %14, i64 2648
  %29 = tail call i64 @IScsiAddKeyValuePair(ptr noundef %1, ptr noundef nonnull @.str.12, ptr noundef nonnull %28) #3
  %30 = tail call i64 @IScsiAddKeyValuePair(ptr noundef %1, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.14) #3
  %31 = getelementptr inbounds i8, ptr %14, i64 19
  %32 = tail call i64 @IScsiAddKeyValuePair(ptr noundef %1, ptr noundef nonnull @.str.15, ptr noundef nonnull %31) #3
  %33 = load i8, ptr %15, align 4, !tbaa !22
  %34 = icmp eq i8 %33, 0
  br i1 %34, label %35, label %39

35:                                               ; preds = %27
  %36 = getelementptr inbounds i8, ptr %16, i64 1
  %37 = load i8, ptr %36, align 1, !tbaa !25
  %38 = or i8 %37, -128
  store i8 %38, ptr %36, align 1, !tbaa !25
  br label %39

39:                                               ; preds = %27, %35
  %.041 = phi ptr [ @.str.16, %35 ], [ @.str.5, %27 ]
  %40 = tail call i64 @IScsiAddKeyValuePair(ptr noundef %1, ptr noundef nonnull @.str.4, ptr noundef nonnull %.041) #3
  br label %65

41:                                               ; preds = %24
  %42 = call i64 (ptr, i64, ptr, ...) @AsciiSPrint(ptr noundef nonnull %3, i64 noundef 256, ptr noundef nonnull @.str.17, i32 noundef 5) #3
  %43 = call i64 @IScsiAddKeyValuePair(ptr noundef %1, ptr noundef nonnull @.str.6, ptr noundef nonnull %3) #3
  store i8 2, ptr %25, align 1, !tbaa !21
  br label %65

44:                                               ; preds = %24
  %45 = getelementptr inbounds i8, ptr %14, i64 277
  %46 = tail call i64 @IScsiAddKeyValuePair(ptr noundef %1, ptr noundef nonnull @.str.10, ptr noundef nonnull %45) #3
  %47 = getelementptr inbounds i8, ptr %14, i64 1600
  %48 = call i64 @IScsiBinToHex(ptr noundef nonnull %47, i32 noundef 16, ptr noundef nonnull %19, ptr noundef nonnull %4) #3
  %49 = call i64 @IScsiAddKeyValuePair(ptr noundef %1, ptr noundef nonnull @.str.11, ptr noundef nonnull %19) #3
  %50 = load i8, ptr %15, align 4, !tbaa !22
  %51 = icmp eq i8 %50, 2
  br i1 %51, label %52, label %61

52:                                               ; preds = %44
  %53 = getelementptr inbounds i8, ptr %14, i64 1616
  call void @IScsiGenRandom(ptr noundef nonnull %53, i64 noundef 1) #3
  %54 = load i32, ptr %53, align 4, !tbaa !27
  %55 = call i64 (ptr, i64, ptr, ...) @AsciiSPrint(ptr noundef nonnull %3, i64 noundef 256, ptr noundef nonnull @.str.17, i32 noundef %54) #3
  %56 = call i64 @IScsiAddKeyValuePair(ptr noundef %1, ptr noundef nonnull @.str.7, ptr noundef nonnull %3) #3
  %57 = getelementptr inbounds i8, ptr %14, i64 1620
  call void @IScsiGenRandom(ptr noundef nonnull %57, i64 noundef 16) #3
  %58 = getelementptr inbounds i8, ptr %14, i64 2644
  store i32 16, ptr %58, align 4, !tbaa !28
  %59 = call i64 @IScsiBinToHex(ptr noundef nonnull %57, i32 noundef 16, ptr noundef nonnull %22, ptr noundef nonnull %5) #3
  %60 = call i64 @IScsiAddKeyValuePair(ptr noundef %1, ptr noundef nonnull @.str.8, ptr noundef nonnull %22) #3
  store i8 4, ptr %25, align 1, !tbaa !21
  br label %61

61:                                               ; preds = %52, %44
  %62 = getelementptr inbounds i8, ptr %16, i64 1
  %63 = load i8, ptr %62, align 1, !tbaa !25
  %64 = or i8 %63, -128
  store i8 %64, ptr %62, align 1, !tbaa !25
  br label %65

65:                                               ; preds = %24, %61, %41, %39
  %.040 = phi i64 [ 0, %61 ], [ 0, %41 ], [ 0, %39 ], [ -9223372036854775784, %24 ]
  call void @FreePool(ptr noundef nonnull %19) #3
  call void @FreePool(ptr noundef nonnull %22) #3
  br label %66

66:                                               ; preds = %21, %18, %12, %65
  %.0 = phi i64 [ %.040, %65 ], [ -9223372036854775784, %12 ], [ -9223372036854775799, %18 ], [ -9223372036854775799, %21 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #3
  ret i64 %.0
}

declare ptr @NetbufGetByte(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

declare i64 @AsciiSPrint(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #1

declare i64 @IScsiBinToHex(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @IScsiGenRandom(ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !8, i64 41}
!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 = !{!6, !11, i64 32}
!20 = !{!7, !7, i64 0}
!21 = !{!6, !8, i64 43}
!22 = !{!23, !8, i64 0}
!23 = !{!"_ISCSI_CHAP_AUTH_DATA", !24, i64 0, !7, i64 292, !8, i64 296, !7, i64 1320, !8, i64 1324, !7, i64 1340, !8, i64 1344, !7, i64 2368}
!24 = !{!"_ISCSI_CHAP_AUTH_CONFIG_NVDATA", !8, i64 0, !8, i64 1, !8, i64 128, !8, i64 145, !8, i64 272}
!25 = !{!26, !8, i64 1}
!26 = !{!"_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}
!27 = !{!23, !7, i64 1340}
!28 = !{!23, !7, i64 2368}


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