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

; 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.NET_BUF = type { i32, i64, %struct._LIST_ENTRY, %union.NET_IP_HEAD, ptr, ptr, [64 x i8], ptr, i32, i32, [1 x %struct.NET_BLOCK_OP] }
%struct._LIST_ENTRY = type { ptr, ptr }
%union.NET_IP_HEAD = type { ptr }
%struct.NET_BLOCK_OP = type { ptr, ptr, ptr, ptr, i32 }
%struct.NET_VECTOR = type { i32, i64, ptr, ptr, i32, i32, i32, [1 x %struct.NET_BLOCK] }
%struct.NET_BLOCK = type { i32, ptr }

@.str = external hidden unnamed_addr constant [144 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [123 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [25 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() #0

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

declare void @FreePool(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @NetIpSecNetbufFree(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %3

3:                                                ; preds = %1
  %4 = call zeroext i8 @DebugAssertEnabled()
  %5 = icmp ne i8 %4, 0
  br i1 %5, label %6, label %16

6:                                                ; preds = %3
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %14

9:                                                ; preds = %6
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.NET_BUF, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = icmp eq i32 %12, 1718968942
  br i1 %13, label %15, label %14

14:                                               ; preds = %9, %6
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1861, ptr noundef @.str.7)
  br label %15

15:                                               ; preds = %14, %9
  br label %16

16:                                               ; preds = %15, %3
  br label %17

17:                                               ; preds = %16
  br label %18

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

21:                                               ; preds = %18
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.NET_BUF, ptr %22, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !14
  %25 = icmp sgt i64 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %21
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1862, ptr noundef @.str.8)
  br label %27

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

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

29:                                               ; preds = %28
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.NET_BUF, ptr %30, i32 0, i32 1
  %32 = load i64, ptr %31, align 8, !tbaa !14
  %33 = add nsw i64 %32, -1
  store i64 %33, ptr %31, align 8, !tbaa !14
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.NET_BUF, ptr %34, i32 0, i32 1
  %36 = load i64, ptr %35, align 8, !tbaa !14
  %37 = icmp eq i64 %36, 0
  br i1 %37, label %38, label %106

38:                                               ; preds = %29
  br label %39

39:                                               ; preds = %38
  %40 = call zeroext i8 @DebugAssertEnabled()
  %41 = icmp ne i8 %40, 0
  br i1 %41, label %42, label %56

42:                                               ; preds = %39
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.NET_BUF, ptr %43, i32 0, i32 7
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %54

47:                                               ; preds = %42
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.NET_BUF, ptr %48, i32 0, i32 7
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = getelementptr inbounds %struct.NET_VECTOR, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !16
  %53 = icmp eq i32 %52, 1667593838
  br i1 %53, label %55, label %54

54:                                               ; preds = %47, %42
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1872, ptr noundef @.str.10)
  br label %55

55:                                               ; preds = %54, %47
  br label %56

56:                                               ; preds = %55, %39
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = call zeroext i8 @DebugAssertEnabled()
  %60 = icmp ne i8 %59, 0
  br i1 %60, label %61, label %70

61:                                               ; preds = %58
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.NET_BUF, ptr %62, i32 0, i32 7
  %64 = load ptr, ptr %63, align 8, !tbaa !15
  %65 = getelementptr inbounds %struct.NET_VECTOR, ptr %64, i32 0, i32 1
  %66 = load i64, ptr %65, align 8, !tbaa !18
  %67 = icmp sgt i64 %66, 0
  br i1 %67, label %69, label %68

68:                                               ; preds = %61
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1873, ptr noundef @.str.22)
  br label %69

69:                                               ; preds = %68, %61
  br label %70

70:                                               ; preds = %69, %58
  br label %71

71:                                               ; preds = %70
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.NET_BUF, ptr %72, i32 0, i32 7
  %74 = load ptr, ptr %73, align 8, !tbaa !15
  %75 = getelementptr inbounds %struct.NET_VECTOR, ptr %74, i32 0, i32 1
  %76 = load i64, ptr %75, align 8, !tbaa !18
  %77 = add nsw i64 %76, -1
  store i64 %77, ptr %75, align 8, !tbaa !18
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.NET_BUF, ptr %78, i32 0, i32 7
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = getelementptr inbounds %struct.NET_VECTOR, ptr %80, i32 0, i32 1
  %82 = load i64, ptr %81, align 8, !tbaa !18
  %83 = icmp sgt i64 %82, 0
  br i1 %83, label %84, label %85

84:                                               ; preds = %71
  br label %106

85:                                               ; preds = %71
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.NET_BUF, ptr %86, i32 0, i32 7
  %88 = load ptr, ptr %87, align 8, !tbaa !15
  %89 = getelementptr inbounds %struct.NET_VECTOR, ptr %88, i32 0, i32 4
  %90 = load i32, ptr %89, align 8, !tbaa !19
  %91 = and i32 %90, 1
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %101

93:                                               ; preds = %85
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.NET_BUF, ptr %94, i32 0, i32 7
  %96 = load ptr, ptr %95, align 8, !tbaa !15
  %97 = getelementptr inbounds %struct.NET_VECTOR, ptr %96, i32 0, i32 7
  %98 = getelementptr inbounds [1 x %struct.NET_BLOCK], ptr %97, i64 0, i64 0
  %99 = getelementptr inbounds %struct.NET_BLOCK, ptr %98, i32 0, i32 1
  %100 = load ptr, ptr %99, align 8, !tbaa !20
  call void @FreePool(ptr noundef %100)
  br label %101

101:                                              ; preds = %93, %85
  %102 = load ptr, ptr %2, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.NET_BUF, ptr %102, i32 0, i32 7
  %104 = load ptr, ptr %103, align 8, !tbaa !15
  call void @FreePool(ptr noundef %104)
  %105 = load ptr, ptr %2, align 8, !tbaa !5
  call void @FreePool(ptr noundef %105)
  br label %106

106:                                              ; preds = %101, %84, %29
  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, !11, i64 0}
!10 = !{!"", !11, i64 0, !12, i64 8, !13, i64 16, !7, i64 32, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !11, i64 128, !11, i64 132, !7, i64 136}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!10, !12, i64 8}
!15 = !{!10, !6, i64 120}
!16 = !{!17, !11, i64 0}
!17 = !{!"", !11, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !7, i64 48}
!18 = !{!17, !12, i64 8}
!19 = !{!17, !11, i64 32}
!20 = !{!21, !6, i64 8}
!21 = !{!"", !11, i64 0, !6, i64 8}


; 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 [144 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [123 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [25 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

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

declare void @FreePool(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @NetIpSecNetbufFree(ptr noundef %0) local_unnamed_addr #1 {
  %2 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %2, 0
  br i1 %.not, label %8, label %3

3:                                                ; preds = %1
  %.not15 = icmp eq ptr %0, null
  br i1 %.not15, label %7, label %4

4:                                                ; preds = %3
  %5 = load i32, ptr %0, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 1718968942
  br i1 %6, label %8, label %7

7:                                                ; preds = %4, %3
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1861, ptr noundef nonnull @.str.7) #2
  br label %8

8:                                                ; preds = %4, %7, %1
  %9 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not16 = icmp eq i8 %9, 0
  br i1 %.not16, label %15, label %10

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !13
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1862, ptr noundef nonnull @.str.8) #2
  br label %15

15:                                               ; preds = %8, %14, %10
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = add nsw i64 %17, -1
  store i64 %18, ptr %16, align 8, !tbaa !13
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %20, label %54

20:                                               ; preds = %15
  %21 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not17 = icmp eq i8 %21, 0
  br i1 %.not17, label %29, label %22

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %0, i64 120
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %.not18 = icmp eq ptr %24, null
  br i1 %.not18, label %28, label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %24, align 8, !tbaa !15
  %27 = icmp eq i32 %26, 1667593838
  br i1 %27, label %29, label %28

28:                                               ; preds = %25, %22
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1872, ptr noundef nonnull @.str.10) #2
  br label %29

29:                                               ; preds = %25, %28, %20
  %30 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not19 = icmp eq i8 %30, 0
  br i1 %.not19, label %38, label %31

31:                                               ; preds = %29
  %32 = getelementptr inbounds i8, ptr %0, i64 120
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %34 = getelementptr inbounds i8, ptr %33, i64 8
  %35 = load i64, ptr %34, align 8, !tbaa !17
  %36 = icmp sgt i64 %35, 0
  br i1 %36, label %38, label %37

37:                                               ; preds = %31
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1873, ptr noundef nonnull @.str.22) #2
  br label %38

38:                                               ; preds = %29, %37, %31
  %39 = getelementptr inbounds i8, ptr %0, i64 120
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = getelementptr inbounds i8, ptr %40, i64 8
  %42 = load i64, ptr %41, align 8, !tbaa !17
  %43 = add nsw i64 %42, -1
  store i64 %43, ptr %41, align 8, !tbaa !17
  %44 = icmp sgt i64 %42, 1
  br i1 %44, label %54, label %45

45:                                               ; preds = %38
  %46 = getelementptr inbounds i8, ptr %40, i64 32
  %47 = load i32, ptr %46, align 8, !tbaa !18
  %48 = and i32 %47, 1
  %.not20 = icmp eq i32 %48, 0
  br i1 %.not20, label %52, label %49

49:                                               ; preds = %45
  %50 = getelementptr inbounds i8, ptr %40, i64 56
  %51 = load ptr, ptr %50, align 8, !tbaa !19
  tail call void @FreePool(ptr noundef %51) #2
  %.pre = load ptr, ptr %39, align 8, !tbaa !14
  br label %52

52:                                               ; preds = %49, %45
  %53 = phi ptr [ %.pre, %49 ], [ %40, %45 ]
  tail call void @FreePool(ptr noundef %53) #2
  tail call void @FreePool(ptr noundef nonnull %0) #2
  br label %54

54:                                               ; preds = %38, %52, %15
  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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 16, !8, i64 32, !12, i64 40, !12, i64 48, !8, i64 56, !12, i64 120, !7, i64 128, !7, i64 132, !8, i64 136}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!"_LIST_ENTRY", !12, i64 0, !12, i64 8}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !12, i64 120}
!15 = !{!16, !7, i64 0}
!16 = !{!"", !7, i64 0, !10, i64 8, !12, i64 16, !12, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !8, i64 48}
!17 = !{!16, !10, i64 8}
!18 = !{!16, !7, i64 32}
!19 = !{!20, !12, i64 8}
!20 = !{!"", !7, i64 0, !12, i64 8}


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