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

; 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.0, 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.0 = 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_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.1 }
%union.anon.1 = type { ptr }
%union.TCP_IO_CLOSE_TOKEN = type { %struct.EFI_TCP4_CLOSE_TOKEN }
%struct.EFI_TCP4_CLOSE_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, i8 }
%union.TCP_IO_LISTEN_TOKEN = type { %struct.EFI_TCP4_LISTEN_TOKEN }
%struct.EFI_TCP4_LISTEN_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, ptr }
%struct.EFI_BOOT_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }
%struct.IPv4_DEVICE_PATH = type <{ %struct.EFI_DEVICE_PATH_PROTOCOL, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, i16, i16, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS }>
%struct.EFI_DEVICE_PATH_PROTOCOL = type { i8, i8, [2 x i8] }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%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 }>
%union.EFI_IP_ADDRESS = type { [4 x i32] }
%struct._ISCSI_SESSION_CONFIG_NVDATA = type <{ i16, i8, i8, %union.EFI_IP_ADDRESS, %struct.EFI_IPv4_ADDRESS, %union.EFI_IP_ADDRESS, i8, i8, [224 x i8], %union.EFI_IP_ADDRESS, i8, [8 x i8], i16, i8, [6 x i8] }>
%union.anon = 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.IPv6_DEVICE_PATH = type { %struct.EFI_DEVICE_PATH_PROTOCOL, %struct.EFI_IPv6_ADDRESS, %struct.EFI_IPv6_ADDRESS, i16, i16, i16, i8, i8, %struct.EFI_IPv6_ADDRESS }
%struct.EFI_IPv6_ADDRESS = type { [16 x i8] }

@.str.1 = external hidden unnamed_addr constant [133 x i8], align 1
@gBS = external global ptr, align 8
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@.str.17 = external hidden unnamed_addr constant [21 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 @ZeroMem(ptr noundef, i64 noundef) #1

declare ptr @CopyMem(ptr noundef, 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 @IScsiGetTcpConnDevicePath(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 i64, align 8
  %7 = alloca ptr, 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_SESSION, ptr %9, i32 0, i32 5
  %11 = load i8, ptr %10, align 8, !tbaa !9
  %12 = zext i8 %11 to i32
  %13 = icmp ne i32 %12, 1
  br i1 %13, label %14, label %15

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

15:                                               ; preds = %1
  %16 = call zeroext i8 @DebugAssertEnabled()
  %17 = zext i8 %16 to i32
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %35

19:                                               ; preds = %15
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %20, i32 0, i32 13
  %22 = getelementptr inbounds %struct._LIST_ENTRY, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = ptrtoint ptr %23 to i64
  %25 = sub i64 %24, ptrtoint (ptr getelementptr inbounds (%struct._ISCSI_CONNECTION, ptr null, i32 0, i32 1) to i64)
  %26 = inttoptr i64 %25 to ptr
  %27 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !15
  %29 = icmp ne i32 %28, 1313035081
  br i1 %29, label %30, label %35

30:                                               ; preds = %19
  call void @DebugAssert(ptr noundef @.str.1, i64 noundef 1365, ptr noundef @.str.17)
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %31, i32 0, i32 13
  %33 = getelementptr inbounds %struct._LIST_ENTRY, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  br label %43

35:                                               ; preds = %19, %15
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %36, i32 0, i32 13
  %38 = getelementptr inbounds %struct._LIST_ENTRY, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = ptrtoint ptr %39 to i64
  %41 = sub i64 %40, ptrtoint (ptr getelementptr inbounds (%struct._ISCSI_CONNECTION, ptr null, i32 0, i32 1) to i64)
  %42 = inttoptr i64 %41 to ptr
  br label %43

43:                                               ; preds = %35, %30
  %44 = phi ptr [ %34, %30 ], [ %42, %35 ]
  store ptr %44, ptr %4, align 8, !tbaa !5
  %45 = load ptr, ptr @gBS, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %45, i32 0, i32 17
  %47 = load ptr, ptr %46, align 8, !tbaa !20
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %48, i32 0, i32 16
  %50 = getelementptr inbounds %struct.TCP_IO, ptr %49, i32 0, i32 3
  %51 = load ptr, ptr %50, align 8, !tbaa !23
  %52 = call i64 %47(ptr noundef %51, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %5)
  store i64 %52, ptr %6, align 8, !tbaa !24
  %53 = load i64, ptr %6, align 8, !tbaa !24
  %54 = icmp slt i64 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %43
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %143

56:                                               ; preds = %43
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = call ptr @DuplicateDevicePath(ptr noundef %57)
  store ptr %58, ptr %5, align 8, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = icmp eq ptr %59, null
  br i1 %60, label %61, label %62

61:                                               ; preds = %56
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %143

62:                                               ; preds = %56
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %63, ptr %7, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %138, %62
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = call zeroext i8 @IsDevicePathEnd(ptr noundef %65)
  %67 = icmp ne i8 %66, 0
  %68 = xor i1 %67, true
  br i1 %68, label %69, label %141

69:                                               ; preds = %64
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = call zeroext i8 @DevicePathType(ptr noundef %70)
  %72 = zext i8 %71 to i32
  %73 = icmp eq i32 %72, 3
  br i1 %73, label %74, label %138

74:                                               ; preds = %69
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %75, i32 0, i32 15
  %77 = load i8, ptr %76, align 8, !tbaa !25
  %78 = icmp ne i8 %77, 0
  br i1 %78, label %115, label %79

79:                                               ; preds = %74
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = call zeroext i8 @DevicePathSubType(ptr noundef %80)
  %82 = zext i8 %81 to i32
  %83 = icmp eq i32 %82, 12
  br i1 %83, label %84, label %115

84:                                               ; preds = %79
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %85, i32 0, i32 3
  store i16 0, ptr %86, align 1, !tbaa !26
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %87, i32 0, i32 2
  %89 = load ptr, ptr %88, align 8, !tbaa !27
  %90 = getelementptr inbounds %struct._ISCSI_ATTEMPT_CONFIG_NVDATA, ptr %89, i32 0, i32 14
  %91 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %90, i32 0, i32 6
  %92 = load i8, ptr %91, align 1, !tbaa !28
  %93 = icmp ne i8 %92, 0
  %94 = xor i1 %93, true
  %95 = zext i1 %94 to i32
  %96 = trunc i32 %95 to i8
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %97, i32 0, i32 6
  store i8 %96, ptr %98, align 1, !tbaa !26
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %99, i32 0, i32 7
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %101, i32 0, i32 2
  %103 = load ptr, ptr %102, align 8, !tbaa !27
  %104 = getelementptr inbounds %struct._ISCSI_ATTEMPT_CONFIG_NVDATA, ptr %103, i32 0, i32 14
  %105 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %104, i32 0, i32 5
  %106 = call ptr @CopyMem(ptr noundef %100, ptr noundef %105, i64 noundef 4)
  %107 = load ptr, ptr %7, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %107, i32 0, i32 8
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._ISCSI_SESSION, ptr %109, i32 0, i32 2
  %111 = load ptr, ptr %110, align 8, !tbaa !27
  %112 = getelementptr inbounds %struct._ISCSI_ATTEMPT_CONFIG_NVDATA, ptr %111, i32 0, i32 14
  %113 = getelementptr inbounds %struct._ISCSI_SESSION_CONFIG_NVDATA, ptr %112, i32 0, i32 4
  %114 = call ptr @CopyMem(ptr noundef %108, ptr noundef %113, i64 noundef 4)
  br label %141

115:                                              ; preds = %79, %74
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %116, i32 0, i32 15
  %118 = load i8, ptr %117, align 8, !tbaa !25
  %119 = zext i8 %118 to i32
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %136

121:                                              ; preds = %115
  %122 = load ptr, ptr %7, align 8, !tbaa !5
  %123 = call zeroext i8 @DevicePathSubType(ptr noundef %122)
  %124 = zext i8 %123 to i32
  %125 = icmp eq i32 %124, 13
  br i1 %125, label %126, label %136

126:                                              ; preds = %121
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %127, i32 0, i32 3
  store i16 0, ptr %128, align 1, !tbaa !26
  %129 = load ptr, ptr %7, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %129, i32 0, i32 6
  store i8 0, ptr %130, align 1, !tbaa !26
  %131 = load ptr, ptr %7, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %131, i32 0, i32 7
  store i8 64, ptr %132, align 1, !tbaa !26
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.IPv6_DEVICE_PATH, ptr %133, i32 0, i32 8
  %135 = call ptr @ZeroMem(ptr noundef %134, i64 noundef 16)
  br label %141

136:                                              ; preds = %121, %115
  br label %137

137:                                              ; preds = %136
  br label %138

138:                                              ; preds = %137, %69
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  %140 = call ptr @NextDevicePathNode(ptr noundef %139)
  store ptr %140, ptr %7, align 8, !tbaa !5
  br label %64, !llvm.loop !32

141:                                              ; preds = %126, %84, %64
  %142 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %142, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %143

143:                                              ; preds = %141, %61, %55, %14
  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
  %144 = load ptr, ptr %2, align 8
  ret ptr %144
}

declare ptr @DuplicateDevicePath(ptr noundef) #1

declare zeroext i8 @IsDevicePathEnd(ptr noundef) #1

declare zeroext i8 @DevicePathType(ptr noundef) #1

declare zeroext i8 @DevicePathSubType(ptr noundef) #1

declare ptr @NextDevicePathNode(ptr 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 2120}
!10 = !{!"_ISCSI_SESSION", !11, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !7, i64 32, !7, i64 2120, !7, i64 2121, !12, i64 2128, !11, i64 2132, !11, i64 2136, !11, i64 2140, !11, i64 2144, !12, i64 2148, !13, i64 2152, !11, i64 2168, !13, i64 2176, !12, i64 2192, !11, i64 2196, !7, i64 2200, !7, i64 2201, !11, i64 2204, !11, i64 2208, !11, i64 2212, !11, i64 2216, !12, i64 2220, !7, i64 2222, !7, i64 2223, !7, i64 2224}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!10, !6, i64 2152}
!15 = !{!16, !11, i64 0}
!16 = !{!"_ISCSI_CONNECTION", !11, i64 0, !13, i64 8, !6, i64 24, !6, i64 32, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !7, i64 44, !7, i64 45, !7, i64 46, !7, i64 47, !12, i64 48, !11, i64 52, !17, i64 56, !7, i64 112, !19, i64 120, !11, i64 288, !11, i64 292, !11, i64 296}
!17 = !{!"", !11, i64 0, !18, i64 8, !13, i64 16, !13, i64 32, !11, i64 48, !11, i64 52}
!18 = !{!"long long", !7, i64 0}
!19 = !{!"", !7, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 64, !7, i64 88, !7, i64 112, !7, i64 136, !7, i64 160, !7, i64 161, !7, i64 162, !7, i64 163, !7, i64 164}
!20 = !{!21, !6, i64 152}
!21 = !{!"", !22, 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}
!22 = !{!"", !18, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!23 = !{!16, !6, i64 144}
!24 = !{!18, !18, i64 0}
!25 = !{!16, !7, i64 112}
!26 = !{!7, !7, i64 0}
!27 = !{!10, !6, i64 16}
!28 = !{!29, !7, i64 306}
!29 = !{!"_ISCSI_ATTEMPT_CONFIG_NVDATA", !13, i64 0, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !12, i64 22, !12, i64 24, !7, i64 26, !7, i64 122, !7, i64 218, !7, i64 234, !7, i64 250, !30, i64 266, !7, i64 566, !7, i64 567}
!30 = !{!"_ISCSI_SESSION_CONFIG_NVDATA", !12, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !31, i64 20, !7, i64 24, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 266, !7, i64 282, !7, i64 283, !12, i64 291, !7, i64 293, !7, i64 294}
!31 = !{!"", !7, i64 0}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


; 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] }

@.str.1 = external hidden unnamed_addr constant [133 x i8], align 1
@gBS = external local_unnamed_addr global ptr, align 8
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@.str.17 = external hidden unnamed_addr constant [21 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 ptr @ZeroMem(ptr noundef, i64 noundef) local_unnamed_addr #1

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @IScsiGetTcpConnDevicePath(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 2120
  %4 = load i8, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i8 %4, 1
  br i1 %.not, label %5, label %62

5:                                                ; preds = %1
  %6 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not26 = icmp eq i8 %6, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 2152
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !13
  %.pre39 = ptrtoint ptr %.pre to i64
  %.pre40 = add i64 %.pre39, -8
  %.pre42 = inttoptr i64 %.pre40 to ptr
  br i1 %.not26, label %._crit_edge, label %7

7:                                                ; preds = %5
  %8 = load i32, ptr %.pre42, align 8, !tbaa !14
  %.not27 = icmp eq i32 %8, 1313035081
  br i1 %.not27, label %._crit_edge, label %9

9:                                                ; preds = %7
  tail call void @DebugAssert(ptr noundef nonnull @.str.1, i64 noundef 1365, ptr noundef nonnull @.str.17) #3
  %10 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !13
  br label %._crit_edge

._crit_edge:                                      ; preds = %5, %7, %9
  %11 = phi ptr [ %10, %9 ], [ %.pre42, %7 ], [ %.pre42, %5 ]
  %12 = load ptr, ptr @gBS, align 8, !tbaa !19
  %13 = getelementptr inbounds i8, ptr %12, i64 152
  %14 = load ptr, ptr %13, align 8, !tbaa !20
  %15 = getelementptr inbounds i8, ptr %11, i64 144
  %16 = load ptr, ptr %15, align 8, !tbaa !23
  %17 = call i64 %14(ptr noundef %16, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef nonnull %2) #3
  %18 = icmp slt i64 %17, 0
  br i1 %18, label %62, label %19

19:                                               ; preds = %._crit_edge
  %20 = load ptr, ptr %2, align 8, !tbaa !19
  %21 = call ptr @DuplicateDevicePath(ptr noundef %20) #3
  store ptr %21, ptr %2, align 8, !tbaa !19
  %22 = icmp eq ptr %21, null
  br i1 %22, label %62, label %.preheader

.preheader:                                       ; preds = %19
  %23 = call zeroext i8 @IsDevicePathEnd(ptr noundef nonnull %21) #3
  %.not2835 = icmp eq i8 %23, 0
  br i1 %.not2835, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %24 = getelementptr inbounds i8, ptr %11, i64 112
  br label %25

25:                                               ; preds = %.lr.ph, %58
  %.036 = phi ptr [ %21, %.lr.ph ], [ %59, %58 ]
  %26 = call zeroext i8 @DevicePathType(ptr noundef %.036) #3
  %27 = icmp eq i8 %26, 3
  br i1 %27, label %28, label %58

28:                                               ; preds = %25
  %29 = load i8, ptr %24, align 8, !tbaa !24
  %.not29 = icmp eq i8 %29, 0
  br i1 %.not29, label %30, label %.thread

30:                                               ; preds = %28
  %31 = call zeroext i8 @DevicePathSubType(ptr noundef %.036) #3
  %32 = icmp eq i8 %31, 12
  br i1 %32, label %33, label %49

33:                                               ; preds = %30
  %34 = getelementptr inbounds i8, ptr %.036, i64 12
  store i16 0, ptr %34, align 1, !tbaa !25
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = load ptr, ptr %35, align 8, !tbaa !26
  %37 = getelementptr inbounds i8, ptr %36, i64 306
  %38 = load i8, ptr %37, align 1, !tbaa !27
  %.not30 = icmp eq i8 %38, 0
  %39 = zext i1 %.not30 to i8
  %40 = getelementptr inbounds i8, ptr %.036, i64 18
  store i8 %39, ptr %40, align 1, !tbaa !25
  %41 = getelementptr inbounds i8, ptr %.036, i64 19
  %42 = load ptr, ptr %35, align 8, !tbaa !26
  %43 = getelementptr inbounds i8, ptr %42, i64 290
  %44 = call ptr @CopyMem(ptr noundef nonnull %41, ptr noundef nonnull %43, i64 noundef 4) #3
  %45 = getelementptr inbounds i8, ptr %.036, i64 23
  %46 = load ptr, ptr %35, align 8, !tbaa !26
  %47 = getelementptr inbounds i8, ptr %46, i64 286
  %48 = call ptr @CopyMem(ptr noundef nonnull %45, ptr noundef nonnull %47, i64 noundef 4) #3
  br label %.loopexit

49:                                               ; preds = %30
  %.pr = load i8, ptr %24, align 8, !tbaa !24
  %.not31 = icmp eq i8 %.pr, 0
  br i1 %.not31, label %58, label %.thread

.thread:                                          ; preds = %28, %49
  %50 = call zeroext i8 @DevicePathSubType(ptr noundef %.036) #3
  %51 = icmp eq i8 %50, 13
  br i1 %51, label %52, label %58

52:                                               ; preds = %.thread
  %53 = getelementptr inbounds i8, ptr %.036, i64 36
  store i16 0, ptr %53, align 1, !tbaa !25
  %54 = getelementptr inbounds i8, ptr %.036, i64 42
  store i8 0, ptr %54, align 1, !tbaa !25
  %55 = getelementptr inbounds i8, ptr %.036, i64 43
  store i8 64, ptr %55, align 1, !tbaa !25
  %56 = getelementptr inbounds i8, ptr %.036, i64 44
  %57 = call ptr @ZeroMem(ptr noundef nonnull %56, i64 noundef 16) #3
  br label %.loopexit

58:                                               ; preds = %.thread, %49, %25
  %59 = call ptr @NextDevicePathNode(ptr noundef %.036) #3
  %60 = call zeroext i8 @IsDevicePathEnd(ptr noundef %59) #3
  %.not28 = icmp eq i8 %60, 0
  br i1 %.not28, label %25, label %.loopexit, !llvm.loop !31

.loopexit:                                        ; preds = %58, %.preheader, %52, %33
  %61 = load ptr, ptr %2, align 8, !tbaa !19
  br label %62

62:                                               ; preds = %19, %._crit_edge, %1, %.loopexit
  %.024 = phi ptr [ %61, %.loopexit ], [ null, %1 ], [ null, %._crit_edge ], [ null, %19 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret ptr %.024
}

declare ptr @DuplicateDevicePath(ptr noundef) local_unnamed_addr #1

declare zeroext i8 @IsDevicePathEnd(ptr noundef) local_unnamed_addr #1

declare zeroext i8 @DevicePathType(ptr noundef) local_unnamed_addr #1

declare zeroext i8 @DevicePathSubType(ptr noundef) local_unnamed_addr #1

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


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass