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

; 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._TCP_CB = type { %struct._LIST_ENTRY, ptr, ptr, %struct._TCP_PEER, %struct._TCP_PEER, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32, i8, i8, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i32, i32, i32, i32, i32, i16, i16, [6 x i32], i32, i32, i32, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i8, i8, i32, i32, i32, i8, i8, i16, i32, i32, i32, i8, i8, i8, %struct.EFI_IPv4_ADDRESS, ptr }
%struct._TCP_PEER = type { i32, i16 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct._TCP_SEG = type { i32, i32, i32, i8, i16, i32 }

@.str.4 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [59 x i8], align 1

declare i64 @TcpRetransmit(ptr noundef, i32 noundef) #0

declare zeroext i8 @DebugPrintEnabled() #0

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @TcpFastLossRecover(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct._TCP_CB, ptr %5, i32 0, i32 13
  %7 = load i32, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._TCP_SEG, ptr %8, i32 0, i32 2
  %10 = load i32, ptr %9, align 4, !tbaa !16
  %11 = sub i32 %7, %10
  %12 = icmp slt i32 %11, 0
  br i1 %12, label %13, label %66

13:                                               ; preds = %2
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._TCP_CB, ptr %14, i32 0, i32 49
  %16 = load i32, ptr %15, align 8, !tbaa !18
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._TCP_SEG, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 4, !tbaa !16
  %20 = sub i32 %16, %19
  %21 = icmp sle i32 %20, 0
  br i1 %21, label %22, label %43

22:                                               ; preds = %13
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._TCP_CB, ptr %23, i32 0, i32 48
  store i8 0, ptr %24, align 1, !tbaa !19
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._TCP_CB, ptr %25, i32 0, i32 47
  store i8 3, ptr %26, align 2, !tbaa !20
  br label %27

27:                                               ; preds = %22
  %28 = call zeroext i8 @DebugPrintEnabled()
  %29 = icmp ne i8 %28, 0
  br i1 %29, label %30, label %41

30:                                               ; preds = %27
  br label %31

31:                                               ; preds = %30
  %32 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64)
  %33 = icmp ne i8 %32, 0
  br i1 %33, label %34, label %39

34:                                               ; preds = %31
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._TCP_SEG, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 4, !tbaa !16
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 64, ptr noundef @.str.4, i32 noundef %37, ptr noundef %38)
  br label %39

39:                                               ; preds = %34, %31
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40, %27
  br label %42

42:                                               ; preds = %41
  br label %65

43:                                               ; preds = %13
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._TCP_SEG, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 4, !tbaa !16
  %48 = call i64 @TcpRetransmit(ptr noundef %44, i32 noundef %47)
  br label %49

49:                                               ; preds = %43
  %50 = call zeroext i8 @DebugPrintEnabled()
  %51 = icmp ne i8 %50, 0
  br i1 %51, label %52, label %63

52:                                               ; preds = %49
  br label %53

53:                                               ; preds = %52
  %54 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64)
  %55 = icmp ne i8 %54, 0
  br i1 %55, label %56, label %61

56:                                               ; preds = %53
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._TCP_SEG, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %58, align 4, !tbaa !16
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 64, ptr noundef @.str.5, i32 noundef %59, ptr noundef %60)
  br label %61

61:                                               ; preds = %56, %53
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62, %49
  br label %64

64:                                               ; preds = %63
  br label %65

65:                                               ; preds = %64, %42
  br label %66

66:                                               ; preds = %65, %2
  ret void
}

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

!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, !13, i64 96}
!10 = !{!"_TCP_CB", !11, i64 0, !6, i64 16, !6, i64 24, !12, i64 32, !12, i64 40, !11, i64 48, !11, i64 64, !13, i64 80, !13, i64 84, !7, i64 88, !7, i64 89, !14, i64 90, !13, i64 92, !13, i64 96, !13, i64 100, !13, i64 104, !13, i64 108, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124, !14, i64 128, !13, i64 132, !13, i64 136, !13, i64 140, !13, i64 144, !13, i64 148, !14, i64 152, !14, i64 154, !7, i64 156, !13, i64 180, !13, i64 184, !13, i64 188, !7, i64 192, !7, i64 193, !7, i64 194, !13, i64 196, !13, i64 200, !13, i64 204, !13, i64 208, !13, i64 212, !13, i64 216, !13, i64 220, !13, i64 224, !13, i64 228, !13, i64 232, !14, i64 236, !7, i64 238, !7, i64 239, !13, i64 240, !13, i64 244, !13, i64 248, !7, i64 252, !7, i64 253, !14, i64 254, !13, i64 256, !13, i64 260, !13, i64 264, !7, i64 268, !7, i64 269, !7, i64 270, !15, i64 271, !6, i64 280}
!11 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!12 = !{!"_TCP_PEER", !13, i64 0, !14, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !7, i64 0}
!16 = !{!17, !13, i64 8}
!17 = !{!"_TCP_SEG", !13, i64 0, !13, i64 4, !13, i64 8, !7, i64 12, !14, i64 14, !13, i64 16}
!18 = !{!10, !13, i64 240}
!19 = !{!10, !7, i64 239}
!20 = !{!10, !7, i64 238}


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

declare i64 @TcpRetransmit(ptr noundef, i32 noundef) local_unnamed_addr #0

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @TcpFastLossRecover(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 96
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i32, ptr %5, align 4, !tbaa !15
  %7 = sub i32 %4, %6
  %8 = icmp slt i32 %7, 0
  br i1 %8, label %9, label %26

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 240
  %11 = load i32, ptr %10, align 8, !tbaa !17
  %12 = sub i32 %11, %6
  %13 = icmp slt i32 %12, 1
  br i1 %13, label %14, label %20

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %0, i64 239
  store i8 0, ptr %15, align 1, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %0, i64 238
  store i8 3, ptr %16, align 2, !tbaa !19
  %17 = tail call zeroext i8 @DebugPrintEnabled() #2
  %.not13 = icmp eq i8 %17, 0
  br i1 %.not13, label %26, label %18

18:                                               ; preds = %14
  %19 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64) #2
  %.not14 = icmp eq i8 %19, 0
  br i1 %.not14, label %26, label %.sink.split

20:                                               ; preds = %9
  %21 = tail call i64 @TcpRetransmit(ptr noundef nonnull %0, i32 noundef %6) #2
  %22 = tail call zeroext i8 @DebugPrintEnabled() #2
  %.not = icmp eq i8 %22, 0
  br i1 %.not, label %26, label %23

23:                                               ; preds = %20
  %24 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64) #2
  %.not12 = icmp eq i8 %24, 0
  br i1 %.not12, label %26, label %.sink.split

.sink.split:                                      ; preds = %23, %18
  %.str.4.sink = phi ptr [ @.str.4, %18 ], [ @.str.5, %23 ]
  %25 = load i32, ptr %5, align 4, !tbaa !15
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 64, ptr noundef nonnull %.str.4.sink, i32 noundef %25, ptr noundef nonnull %0) #2
  br label %26

26:                                               ; preds = %.sink.split, %14, %18, %20, %23, %2
  ret void
}

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, !12, i64 96}
!6 = !{!"_TCP_CB", !7, i64 0, !8, i64 16, !8, i64 24, !11, i64 32, !11, i64 40, !7, i64 48, !7, i64 64, !12, i64 80, !12, i64 84, !9, i64 88, !9, i64 89, !13, i64 90, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !13, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !12, i64 148, !13, i64 152, !13, i64 154, !9, i64 156, !12, i64 180, !12, i64 184, !12, i64 188, !9, i64 192, !9, i64 193, !9, i64 194, !12, i64 196, !12, i64 200, !12, i64 204, !12, i64 208, !12, i64 212, !12, i64 216, !12, i64 220, !12, i64 224, !12, i64 228, !12, i64 232, !13, i64 236, !9, i64 238, !9, i64 239, !12, i64 240, !12, i64 244, !12, i64 248, !9, i64 252, !9, i64 253, !13, i64 254, !12, i64 256, !12, i64 260, !12, i64 264, !9, i64 268, !9, i64 269, !9, i64 270, !14, i64 271, !8, i64 280}
!7 = !{!"_LIST_ENTRY", !8, i64 0, !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"_TCP_PEER", !12, i64 0, !13, i64 4}
!12 = !{!"int", !9, i64 0}
!13 = !{!"short", !9, i64 0}
!14 = !{!"", !9, i64 0}
!15 = !{!16, !12, i64 8}
!16 = !{!"_TCP_SEG", !12, i64 0, !12, i64 4, !12, i64 8, !9, i64 12, !13, i64 14, !12, i64 16}
!17 = !{!6, !12, i64 240}
!18 = !{!6, !9, i64 239}
!19 = !{!6, !9, i64 238}


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