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

; 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.ARP_INSTANCE_DATA = type { i32, ptr, ptr, %struct._EFI_ARP_PROTOCOL, %struct._LIST_ENTRY, %struct.EFI_ARP_CONFIG_DATA, i8, i8 }
%struct._EFI_ARP_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_ARP_CONFIG_DATA = type { i16, i8, ptr, i32, i32, i32 }
%struct._ARP_SERVICE_DATA = type { i32, %struct._EFI_SERVICE_BINDING_PROTOCOL, ptr, ptr, ptr, ptr, %struct.EFI_MANAGED_NETWORK_CONFIG_DATA, %struct.EFI_MANAGED_NETWORK_COMPLETION_TOKEN, %struct.EFI_SIMPLE_NETWORK_MODE, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct._LIST_ENTRY, ptr }
%struct._EFI_SERVICE_BINDING_PROTOCOL = type { ptr, ptr }
%struct.EFI_MANAGED_NETWORK_CONFIG_DATA = type { i32, i32, i16, i8, i8, i8, i8, i8, i8, i8 }
%struct.EFI_MANAGED_NETWORK_COMPLETION_TOKEN = type { ptr, i64, %union.anon }
%union.anon = type { ptr }
%struct.EFI_SIMPLE_NETWORK_MODE = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x %struct.EFI_MAC_ADDRESS], %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, i8, i8, i8, i8, i8 }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }

@.str = external hidden unnamed_addr constant [149 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [115 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @ArpDeleteCacheEntryInTable(ptr noundef, i8 noundef zeroext, i16 noundef zeroext, ptr noundef, i8 noundef zeroext) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @ArpDeleteCacheEntry(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2, i8 noundef zeroext %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i8 %3, ptr %8, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  br label %11

11:                                               ; preds = %4
  %12 = call zeroext i8 @DebugAssertEnabled()
  %13 = icmp ne i8 %12, 0
  br i1 %13, label %14, label %24

14:                                               ; preds = %11
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %22

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ARP_INSTANCE_DATA, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !10
  %21 = icmp eq i32 %20, 1230000705
  br i1 %21, label %23, label %22

22:                                               ; preds = %17, %14
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1324, ptr noundef @.str.2)
  br label %23

23:                                               ; preds = %22, %17
  br label %24

24:                                               ; preds = %23, %11
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ARP_INSTANCE_DATA, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  store ptr %29, ptr %9, align 8, !tbaa !5
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._ARP_SERVICE_DATA, ptr %30, i32 0, i32 12
  %32 = load i8, ptr %6, align 1, !tbaa !9
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ARP_INSTANCE_DATA, ptr %33, i32 0, i32 5
  %35 = getelementptr inbounds %struct.EFI_ARP_CONFIG_DATA, ptr %34, i32 0, i32 0
  %36 = load i16, ptr %35, align 8, !tbaa !18
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load i8, ptr %8, align 1, !tbaa !9
  %39 = call i64 @ArpDeleteCacheEntryInTable(ptr noundef %31, i8 noundef zeroext %32, i16 noundef zeroext %36, ptr noundef %37, i8 noundef zeroext %38)
  store i64 %39, ptr %10, align 8, !tbaa !19
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._ARP_SERVICE_DATA, ptr %40, i32 0, i32 13
  %42 = load i8, ptr %6, align 1, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ARP_INSTANCE_DATA, ptr %43, i32 0, i32 5
  %45 = getelementptr inbounds %struct.EFI_ARP_CONFIG_DATA, ptr %44, i32 0, i32 0
  %46 = load i16, ptr %45, align 8, !tbaa !18
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load i8, ptr %8, align 1, !tbaa !9
  %49 = call i64 @ArpDeleteCacheEntryInTable(ptr noundef %41, i8 noundef zeroext %42, i16 noundef zeroext %46, ptr noundef %47, i8 noundef zeroext %48)
  %50 = load i64, ptr %10, align 8, !tbaa !19
  %51 = add i64 %50, %49
  store i64 %51, ptr %10, align 8, !tbaa !19
  %52 = load i64, ptr %10, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret i64 %52
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"", !12, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 80, !15, i64 96, !7, i64 128, !7, i64 129}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_EFI_ARP_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"", !16, i64 0, !7, i64 2, !6, i64 8, !12, i64 16, !12, i64 20, !12, i64 24}
!16 = !{!"short", !7, i64 0}
!17 = !{!11, !6, i64 8}
!18 = !{!11, !16, i64 96}
!19 = !{!20, !20, i64 0}
!20 = !{!"long long", !7, i64 0}


; 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 [149 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [115 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

; Function Attrs: nounwind uwtable
declare dso_local i64 @ArpDeleteCacheEntryInTable(ptr noundef, i8 noundef zeroext, i16 noundef zeroext, ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @ArpDeleteCacheEntry(ptr noundef readonly %0, i8 noundef zeroext %1, ptr noundef %2, i8 noundef zeroext %3) local_unnamed_addr #1 {
  %5 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %11, label %6

6:                                                ; preds = %4
  %.not14 = icmp eq ptr %0, null
  br i1 %.not14, label %10, label %7

7:                                                ; preds = %6
  %8 = load i32, ptr %0, align 8, !tbaa !5
  %9 = icmp eq i32 %8, 1230000705
  br i1 %9, label %11, label %10

10:                                               ; preds = %7, %6
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 1324, ptr noundef nonnull @.str.2) #2
  br label %11

11:                                               ; preds = %7, %10, %4
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %13, i64 800
  %15 = getelementptr inbounds i8, ptr %0, i64 96
  %16 = load i16, ptr %15, align 8, !tbaa !16
  %17 = tail call i64 @ArpDeleteCacheEntryInTable(ptr noundef nonnull %14, i8 noundef zeroext %1, i16 noundef zeroext %16, ptr noundef %2, i8 noundef zeroext %3)
  %18 = getelementptr inbounds i8, ptr %13, i64 816
  %19 = load i16, ptr %15, align 8, !tbaa !16
  %20 = tail call i64 @ArpDeleteCacheEntryInTable(ptr noundef nonnull %18, i8 noundef zeroext %1, i16 noundef zeroext %19, ptr noundef %2, i8 noundef zeroext %3)
  %21 = add i64 %20, %17
  ret i64 %21
}

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, !10, i64 16, !11, i64 24, !12, i64 80, !13, i64 96, !8, i64 128, !8, i64 129}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_EFI_ARP_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!12 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}
!13 = !{!"", !14, i64 0, !8, i64 2, !10, i64 8, !7, i64 16, !7, i64 20, !7, i64 24}
!14 = !{!"short", !8, i64 0}
!15 = !{!6, !10, i64 8}
!16 = !{!6, !14, i64 96}


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