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

; 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._SOCKET = type { i32, ptr, ptr, ptr, ptr, %struct._LIST_ENTRY, i8, i32, i8, i16, %struct.EFI_LOCK, %struct._SOCK_BUFFER, %struct._SOCK_BUFFER, i64, i8, i32, i32, ptr, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct._LIST_ENTRY, ptr, ptr, ptr, [20 x i8], %union._NET_PROTOCOL, ptr, ptr, ptr }
%struct.EFI_LOCK = type { i64, i64, i32 }
%struct._SOCK_BUFFER = type { i32, i32, ptr }
%struct._LIST_ENTRY = type { ptr, ptr }
%union._NET_PROTOCOL = type { %struct._EFI_TCP4_PROTOCOL }
%struct._EFI_TCP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._SOCK_COMPLETION_TOKEN = type { ptr, i64 }
%struct.EFI_TCP4_LISTEN_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, ptr }
%struct.EFI_TCP4_COMPLETION_TOKEN = type { ptr, i64 }
%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 }

@.str.1 = external hidden unnamed_addr constant [156 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [53 x i8], align 1
@gBS = external global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [49 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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @SockTokenExisted(ptr noundef, ptr noundef) #1

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

declare zeroext i8 @DebugPrintEnabled() #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #2

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

declare zeroext i8 @DebugAssertEnabled() #2

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

declare i64 @EfiAcquireLockOrFail(ptr noundef) #2

declare void @EfiReleaseLock(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @SockAccept(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = 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
  br label %12

12:                                               ; preds = %2
  %13 = call zeroext i8 @DebugAssertEnabled()
  %14 = icmp ne i8 %13, 0
  br i1 %14, label %15, label %22

15:                                               ; preds = %12
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._SOCKET, ptr %16, i32 0, i32 7
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = icmp eq i32 1, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  call void @DebugAssert(ptr noundef @.str.1, i64 noundef 400, ptr noundef @.str.11)
  br label %21

21:                                               ; preds = %20, %15
  br label %22

22:                                               ; preds = %21, %12
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._SOCKET, ptr %25, i32 0, i32 10
  %27 = call i64 @EfiAcquireLockOrFail(ptr noundef %26)
  store i64 %27, ptr %8, align 8, !tbaa !17
  %28 = load i64, ptr %8, align 8, !tbaa !17
  %29 = icmp slt i64 %28, 0
  br i1 %29, label %30, label %46

30:                                               ; preds = %24
  br label %31

31:                                               ; preds = %30
  %32 = call zeroext i8 @DebugPrintEnabled()
  %33 = icmp ne i8 %32, 0
  br i1 %33, label %34, label %43

34:                                               ; preds = %31
  br label %35

35:                                               ; preds = %34
  %36 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %37 = icmp ne i8 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %35
  %39 = load i64, ptr %8, align 8, !tbaa !17
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.12, i64 noundef %39)
  br label %40

40:                                               ; preds = %38, %35
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42, %31
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  store i64 -9223372036854775793, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %177

46:                                               ; preds = %24
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._SOCKET, ptr %47, i32 0, i32 6
  %49 = load i8, ptr %48, align 8, !tbaa !18
  %50 = zext i8 %49 to i32
  %51 = icmp eq i32 %50, 3
  br i1 %51, label %52, label %53

52:                                               ; preds = %46
  store i64 -9223372036854775791, ptr %8, align 8, !tbaa !17
  br label %173

53:                                               ; preds = %46
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._SOCKET, ptr %54, i32 0, i32 6
  %56 = load i8, ptr %55, align 8, !tbaa !18
  %57 = zext i8 %56 to i32
  %58 = icmp eq i32 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %53
  store i64 -9223372036854775789, ptr %8, align 8, !tbaa !17
  br label %173

60:                                               ; preds = %53
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._SOCKET, ptr %61, i32 0, i32 8
  %63 = load i8, ptr %62, align 8, !tbaa !19
  %64 = zext i8 %63 to i32
  %65 = icmp eq i32 %64, 1
  br i1 %65, label %67, label %66

66:                                               ; preds = %60
  store i64 -9223372036854775793, ptr %8, align 8, !tbaa !17
  br label %173

67:                                               ; preds = %60
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._SOCK_COMPLETION_TOKEN, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !20
  store ptr %70, ptr %10, align 8, !tbaa !5
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = call zeroext i8 @SockTokenExisted(ptr noundef %71, ptr noundef %72)
  %74 = icmp ne i8 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %67
  store i64 -9223372036854775793, ptr %8, align 8, !tbaa !17
  br label %173

76:                                               ; preds = %67
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %77, ptr %6, align 8, !tbaa !5
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._SOCKET, ptr %78, i32 0, i32 18
  %80 = getelementptr inbounds %struct._LIST_ENTRY, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !22
  store ptr %81, ptr %7, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %160, %76
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._SOCKET, ptr %84, i32 0, i32 18
  %86 = icmp ne ptr %83, %85
  br i1 %86, label %87, label %164

87:                                               ; preds = %82
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = ptrtoint ptr %88 to i64
  %90 = sub i64 %89, ptrtoint (ptr getelementptr inbounds (%struct._SOCKET, ptr null, i32 0, i32 18) to i64)
  %91 = inttoptr i64 %90 to ptr
  store ptr %91, ptr %9, align 8, !tbaa !5
  %92 = load ptr, ptr %9, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._SOCKET, ptr %92, i32 0, i32 8
  %94 = load i8, ptr %93, align 8, !tbaa !19
  %95 = zext i8 %94 to i32
  %96 = icmp eq i32 %95, 3
  br i1 %96, label %97, label %159

97:                                               ; preds = %87
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._SOCKET, ptr %98, i32 0, i32 1
  %100 = load ptr, ptr %99, align 8, !tbaa !23
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.EFI_TCP4_LISTEN_TOKEN, ptr %101, i32 0, i32 1
  store ptr %100, ptr %102, align 8, !tbaa !24
  br label %103

103:                                              ; preds = %97
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.EFI_TCP4_LISTEN_TOKEN, ptr %104, i32 0, i32 0
  %106 = getelementptr inbounds %struct.EFI_TCP4_COMPLETION_TOKEN, ptr %105, i32 0, i32 1
  store i64 0, ptr %106, align 8, !tbaa !27
  %107 = load ptr, ptr @gBS, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %107, i32 0, i32 11
  %109 = load ptr, ptr %108, align 8, !tbaa !28
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.EFI_TCP4_LISTEN_TOKEN, ptr %110, i32 0, i32 0
  %112 = getelementptr inbounds %struct.EFI_TCP4_COMPLETION_TOKEN, ptr %111, i32 0, i32 0
  %113 = load ptr, ptr %112, align 8, !tbaa !31
  %114 = call i64 %109(ptr noundef %113)
  br label %115

115:                                              ; preds = %103
  br label %116

116:                                              ; preds = %115
  %117 = load ptr, ptr %7, align 8, !tbaa !5
  %118 = call ptr @RemoveEntryList(ptr noundef %117)
  br label %119

119:                                              ; preds = %116
  %120 = call zeroext i8 @DebugAssertEnabled()
  %121 = icmp ne i8 %120, 0
  br i1 %121, label %122, label %129

122:                                              ; preds = %119
  %123 = load ptr, ptr %9, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct._SOCKET, ptr %123, i32 0, i32 17
  %125 = load ptr, ptr %124, align 8, !tbaa !32
  %126 = icmp ne ptr %125, null
  br i1 %126, label %128, label %127

127:                                              ; preds = %122
  call void @DebugAssert(ptr noundef @.str.1, i64 noundef 451, ptr noundef @.str.13)
  br label %128

128:                                              ; preds = %127, %122
  br label %129

129:                                              ; preds = %128, %119
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  %132 = load ptr, ptr %9, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct._SOCKET, ptr %132, i32 0, i32 17
  %134 = load ptr, ptr %133, align 8, !tbaa !32
  %135 = getelementptr inbounds %struct._SOCKET, ptr %134, i32 0, i32 16
  %136 = load i32, ptr %135, align 8, !tbaa !33
  %137 = add i32 %136, -1
  store i32 %137, ptr %135, align 8, !tbaa !33
  br label %138

138:                                              ; preds = %131
  %139 = call zeroext i8 @DebugPrintEnabled()
  %140 = icmp ne i8 %139, 0
  br i1 %140, label %141, label %154

141:                                              ; preds = %138
  br label %142

142:                                              ; preds = %141
  %143 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64)
  %144 = icmp ne i8 %143, 0
  br i1 %144, label %145, label %151

145:                                              ; preds = %142
  %146 = load ptr, ptr %9, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct._SOCKET, ptr %146, i32 0, i32 17
  %148 = load ptr, ptr %147, align 8, !tbaa !32
  %149 = getelementptr inbounds %struct._SOCKET, ptr %148, i32 0, i32 16
  %150 = load i32, ptr %149, align 8, !tbaa !33
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 64, ptr noundef @.str.14, i32 noundef %150)
  br label %151

151:                                              ; preds = %145, %142
  br label %152

152:                                              ; preds = %151
  br label %153

153:                                              ; preds = %152
  br label %154

154:                                              ; preds = %153, %138
  br label %155

155:                                              ; preds = %154
  br label %156

156:                                              ; preds = %155
  %157 = load ptr, ptr %9, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct._SOCKET, ptr %157, i32 0, i32 17
  store ptr null, ptr %158, align 8, !tbaa !32
  br label %173

159:                                              ; preds = %87
  br label %160

160:                                              ; preds = %159
  %161 = load ptr, ptr %7, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct._LIST_ENTRY, ptr %161, i32 0, i32 0
  %163 = load ptr, ptr %162, align 8, !tbaa !34
  store ptr %163, ptr %7, align 8, !tbaa !5
  br label %82, !llvm.loop !35

164:                                              ; preds = %82
  %165 = load ptr, ptr %4, align 8, !tbaa !5
  %166 = load ptr, ptr %4, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct._SOCKET, ptr %166, i32 0, i32 19
  %168 = load ptr, ptr %5, align 8, !tbaa !5
  %169 = call ptr @SockBufferToken(ptr noundef %165, ptr noundef %167, ptr noundef %168, i32 noundef 0)
  %170 = icmp eq ptr null, %169
  br i1 %170, label %171, label %172

171:                                              ; preds = %164
  store i64 -9223372036854775799, ptr %8, align 8, !tbaa !17
  br label %172

172:                                              ; preds = %171, %164
  br label %173

173:                                              ; preds = %172, %156, %75, %66, %59, %52
  %174 = load ptr, ptr %4, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct._SOCKET, ptr %174, i32 0, i32 10
  call void @EfiReleaseLock(ptr noundef %175)
  %176 = load i64, ptr %8, align 8, !tbaa !17
  store i64 %176, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %177

177:                                              ; preds = %173, %45
  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
  %178 = load i64, ptr %3, align 8
  ret i64 %178
}

declare ptr @RemoveEntryList(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !11, i64 60}
!10 = !{!"_SOCKET", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !7, i64 56, !11, i64 60, !7, i64 64, !13, i64 66, !14, i64 72, !16, i64 96, !16, i64 112, !15, i64 128, !7, i64 136, !11, i64 140, !11, i64 144, !6, i64 152, !12, i64 160, !12, i64 176, !12, i64 192, !12, i64 208, !12, i64 224, !6, i64 240, !6, i64 248, !6, i64 256, !7, i64 264, !7, i64 288, !6, i64 368, !6, i64 376, !6, i64 384}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !15, i64 0, !15, i64 8, !11, i64 16}
!15 = !{!"long long", !7, i64 0}
!16 = !{!"_SOCK_BUFFER", !11, i64 0, !11, i64 4, !6, i64 8}
!17 = !{!15, !15, i64 0}
!18 = !{!10, !7, i64 56}
!19 = !{!10, !7, i64 64}
!20 = !{!21, !6, i64 0}
!21 = !{!"_SOCK_COMPLETION_TOKEN", !6, i64 0, !15, i64 8}
!22 = !{!10, !6, i64 160}
!23 = !{!10, !6, i64 8}
!24 = !{!25, !6, i64 16}
!25 = !{!"", !26, i64 0, !6, i64 16}
!26 = !{!"", !6, i64 0, !15, i64 8}
!27 = !{!25, !15, i64 8}
!28 = !{!29, !6, i64 104}
!29 = !{!"", !30, 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}
!30 = !{!"", !15, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!31 = !{!25, !6, i64 0}
!32 = !{!10, !6, i64 152}
!33 = !{!10, !11, i64 144}
!34 = !{!12, !6, i64 0}
!35 = distinct !{!35, !36}
!36 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [156 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [53 x i8], align 1
@gBS = external local_unnamed_addr global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [49 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @SockTokenExisted(ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #1

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

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

declare i64 @EfiAcquireLockOrFail(ptr noundef) local_unnamed_addr #1

declare void @EfiReleaseLock(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i64 0, -9223372036854775788) i64 @SockAccept(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %3, 0
  br i1 %.not, label %9, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 60
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %9, label %8

8:                                                ; preds = %4
  tail call void @DebugAssert(ptr noundef nonnull @.str.1, i64 noundef 400, ptr noundef nonnull @.str.11) #2
  br label %9

9:                                                ; preds = %4, %8, %2
  %10 = getelementptr inbounds i8, ptr %0, i64 72
  %11 = tail call i64 @EfiAcquireLockOrFail(ptr noundef nonnull %10) #2
  %12 = icmp slt i64 %11, 0
  br i1 %12, label %13, label %18

13:                                               ; preds = %9
  %14 = tail call zeroext i8 @DebugPrintEnabled() #2
  %.not41 = icmp eq i8 %14, 0
  br i1 %.not41, label %74, label %15

15:                                               ; preds = %13
  %16 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #2
  %.not42 = icmp eq i8 %16, 0
  br i1 %.not42, label %74, label %17

17:                                               ; preds = %15
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.12, i64 noundef %11) #2
  br label %74

18:                                               ; preds = %9
  %19 = getelementptr inbounds i8, ptr %0, i64 56
  %20 = load i8, ptr %19, align 8, !tbaa !16
  switch i8 %20, label %22 [
    i8 3, label %73
    i8 0, label %21
  ]

21:                                               ; preds = %18
  br label %73

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %0, i64 64
  %24 = load i8, ptr %23, align 8, !tbaa !17
  %25 = icmp eq i8 %24, 1
  br i1 %25, label %26, label %73

26:                                               ; preds = %22
  %27 = load ptr, ptr %1, align 8, !tbaa !18
  %28 = tail call zeroext i8 @SockTokenExisted(ptr noundef nonnull %0, ptr noundef %27)
  %.not35 = icmp eq i8 %28, 0
  br i1 %.not35, label %29, label %73

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %0, i64 160
  br label %31

31:                                               ; preds = %32, %29
  %.031.in = phi ptr [ %30, %29 ], [ %.031, %32 ]
  %.031 = load ptr, ptr %.031.in, align 8, !tbaa !20
  %.not36 = icmp eq ptr %.031, %30
  br i1 %.not36, label %69, label %32

32:                                               ; preds = %31
  %33 = ptrtoint ptr %.031 to i64
  %34 = add i64 %33, -160
  %35 = inttoptr i64 %34 to ptr
  %36 = getelementptr inbounds i8, ptr %35, i64 64
  %37 = load i8, ptr %36, align 8, !tbaa !17
  %38 = icmp eq i8 %37, 3
  br i1 %38, label %39, label %31, !llvm.loop !21

39:                                               ; preds = %32
  %40 = getelementptr inbounds i8, ptr %35, i64 8
  %41 = load ptr, ptr %40, align 8, !tbaa !23
  %42 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %41, ptr %42, align 8, !tbaa !24
  %43 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 0, ptr %43, align 8, !tbaa !27
  %44 = load ptr, ptr @gBS, align 8, !tbaa !28
  %45 = getelementptr inbounds i8, ptr %44, i64 104
  %46 = load ptr, ptr %45, align 8, !tbaa !29
  %47 = load ptr, ptr %1, align 8, !tbaa !32
  %48 = tail call i64 %46(ptr noundef %47) #2
  %49 = tail call ptr @RemoveEntryList(ptr noundef %.031) #2
  %50 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not37 = icmp eq i8 %50, 0
  br i1 %.not37, label %55, label %51

51:                                               ; preds = %39
  %52 = getelementptr inbounds i8, ptr %35, i64 152
  %53 = load ptr, ptr %52, align 8, !tbaa !33
  %.not38 = icmp eq ptr %53, null
  br i1 %.not38, label %54, label %55

54:                                               ; preds = %51
  tail call void @DebugAssert(ptr noundef nonnull @.str.1, i64 noundef 451, ptr noundef nonnull @.str.13) #2
  br label %55

55:                                               ; preds = %51, %54, %39
  %56 = getelementptr inbounds i8, ptr %35, i64 152
  %57 = load ptr, ptr %56, align 8, !tbaa !33
  %58 = getelementptr inbounds i8, ptr %57, i64 144
  %59 = load i32, ptr %58, align 8, !tbaa !34
  %60 = add i32 %59, -1
  store i32 %60, ptr %58, align 8, !tbaa !34
  %61 = tail call zeroext i8 @DebugPrintEnabled() #2
  %.not39 = icmp eq i8 %61, 0
  br i1 %.not39, label %68, label %62

62:                                               ; preds = %55
  %63 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64) #2
  %.not40 = icmp eq i8 %63, 0
  br i1 %.not40, label %68, label %64

64:                                               ; preds = %62
  %65 = load ptr, ptr %56, align 8, !tbaa !33
  %66 = getelementptr inbounds i8, ptr %65, i64 144
  %67 = load i32, ptr %66, align 8, !tbaa !34
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 64, ptr noundef nonnull @.str.14, i32 noundef %67) #2
  br label %68

68:                                               ; preds = %62, %64, %55
  store ptr null, ptr %56, align 8, !tbaa !33
  br label %73

69:                                               ; preds = %31
  %70 = getelementptr inbounds i8, ptr %0, i64 176
  %71 = tail call ptr @SockBufferToken(ptr noundef %0, ptr noundef nonnull %70, ptr noundef nonnull %1, i32 noundef 0)
  %72 = icmp eq ptr %71, null
  %spec.select = select i1 %72, i64 -9223372036854775799, i64 %11
  br label %73

73:                                               ; preds = %69, %26, %22, %18, %68, %21
  %.032 = phi i64 [ -9223372036854775789, %21 ], [ %11, %68 ], [ -9223372036854775791, %18 ], [ -9223372036854775793, %22 ], [ -9223372036854775793, %26 ], [ %spec.select, %69 ]
  tail call void @EfiReleaseLock(ptr noundef nonnull %10) #2
  br label %74

74:                                               ; preds = %13, %17, %15, %73
  %.0 = phi i64 [ %.032, %73 ], [ -9223372036854775793, %15 ], [ -9223372036854775793, %17 ], [ -9223372036854775793, %13 ]
  ret i64 %.0
}

declare ptr @RemoveEntryList(ptr noundef) local_unnamed_addr #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "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, !7, i64 60}
!6 = !{!"_SOCKET", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !8, i64 56, !7, i64 60, !8, i64 64, !12, i64 66, !13, i64 72, !15, i64 96, !15, i64 112, !14, i64 128, !8, i64 136, !7, i64 140, !7, i64 144, !10, i64 152, !11, i64 160, !11, i64 176, !11, i64 192, !11, i64 208, !11, i64 224, !10, i64 240, !10, i64 248, !10, i64 256, !8, i64 264, !8, i64 288, !10, i64 368, !10, i64 376, !10, i64 384}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}
!12 = !{!"short", !8, i64 0}
!13 = !{!"", !14, i64 0, !14, i64 8, !7, i64 16}
!14 = !{!"long long", !8, i64 0}
!15 = !{!"_SOCK_BUFFER", !7, i64 0, !7, i64 4, !10, i64 8}
!16 = !{!6, !8, i64 56}
!17 = !{!6, !8, i64 64}
!18 = !{!19, !10, i64 0}
!19 = !{!"_SOCK_COMPLETION_TOKEN", !10, i64 0, !14, i64 8}
!20 = !{!11, !10, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!6, !10, i64 8}
!24 = !{!25, !10, i64 16}
!25 = !{!"", !26, i64 0, !10, i64 16}
!26 = !{!"", !10, i64 0, !14, i64 8}
!27 = !{!25, !14, i64 8}
!28 = !{!10, !10, i64 0}
!29 = !{!30, !10, i64 104}
!30 = !{!"", !31, 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}
!31 = !{!"", !14, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!32 = !{!25, !10, i64 0}
!33 = !{!6, !10, i64 152}
!34 = !{!6, !7, i64 144}


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