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

; 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_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] }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.NET_ARP_ADDRESS = type { i16, i8, ptr, %union.NET_ARP_ADDRESS_UNION }
%union.NET_ARP_ADDRESS_UNION = type { [32 x i8] }

@.str = external hidden unnamed_addr constant [149 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [119 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [71 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: nounwind uwtable
define dso_local ptr @ArpFindDeniedCacheEntry(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  br label %10

10:                                               ; preds = %3
  %11 = call zeroext i8 @DebugAssertEnabled()
  %12 = icmp ne i8 %11, 0
  br i1 %12, label %13, label %21

13:                                               ; preds = %10
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %20, label %16

16:                                               ; preds = %13
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @DebugAssert(ptr noundef @.str, i64 noundef 654, ptr noundef @.str.9)
  br label %20

20:                                               ; preds = %19, %16, %13
  br label %21

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

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = call zeroext i8 @DebugAssertEnabled()
  %26 = icmp ne i8 %25, 0
  br i1 %26, label %27, label %37

27:                                               ; preds = %24
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %35

30:                                               ; preds = %27
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._ARP_SERVICE_DATA, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = icmp eq i32 %33, 1397772865
  br i1 %34, label %36, label %35

35:                                               ; preds = %30, %27
  call void @DebugAssert(ptr noundef @.str, i64 noundef 655, ptr noundef @.str.1)
  br label %36

36:                                               ; preds = %35, %30
  br label %37

37:                                               ; preds = %36, %24
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  store ptr null, ptr %8, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %57

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

47:                                               ; preds = %42
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._ARP_SERVICE_DATA, ptr %48, i32 0, i32 12
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = call ptr @ArpFindNextCacheEntryInTable(ptr noundef %49, ptr noundef null, i32 noundef 1, ptr noundef %50, ptr noundef null)
  store ptr %51, ptr %8, align 8, !tbaa !5
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %56

54:                                               ; preds = %47
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %55, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %72

56:                                               ; preds = %47
  br label %57

57:                                               ; preds = %56, %42, %39
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %70

60:                                               ; preds = %57
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.NET_ARP_ADDRESS, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !20
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %70

65:                                               ; preds = %60
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._ARP_SERVICE_DATA, ptr %66, i32 0, i32 12
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = call ptr @ArpFindNextCacheEntryInTable(ptr noundef %67, ptr noundef null, i32 noundef 2, ptr noundef null, ptr noundef %68)
  store ptr %69, ptr %8, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %65, %60, %57
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %71, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %72

72:                                               ; preds = %70, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %73 = load ptr, ptr %4, align 8
  ret ptr %73
}

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

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

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 = !{!10, !11, i64 0}
!10 = !{!"_ARP_SERVICE_DATA", !11, i64 0, !12, i64 8, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !15, i64 80, !17, i64 104, !16, i64 760, !19, i64 768, !19, i64 784, !19, i64 800, !19, i64 816, !6, i64 832}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!13 = !{!"", !11, i64 0, !11, i64 4, !14, i64 8, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !6, i64 0, !16, i64 8, !7, i64 16}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !18, i64 552, !18, i64 584, !18, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!18 = !{!"", !7, i64 0}
!19 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!20 = !{!21, !6, i64 8}
!21 = !{!"", !14, i64 0, !7, i64 2, !6, i64 8, !7, i64 16}


; 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.1 = external hidden unnamed_addr constant [119 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [71 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
define dso_local ptr @ArpFindDeniedCacheEntry(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %9, label %5

5:                                                ; preds = %3
  %6 = icmp ne ptr %1, null
  %7 = icmp ne ptr %2, null
  %or.cond = or i1 %6, %7
  br i1 %or.cond, label %9, label %8

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

9:                                                ; preds = %3, %8, %5
  %10 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not23 = icmp eq i8 %10, 0
  br i1 %.not23, label %16, label %11

11:                                               ; preds = %9
  %.not24 = icmp eq ptr %0, null
  br i1 %.not24, label %15, label %12

12:                                               ; preds = %11
  %13 = load i32, ptr %0, align 8, !tbaa !5
  %14 = icmp eq i32 %13, 1397772865
  br i1 %14, label %16, label %15

15:                                               ; preds = %12, %11
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 655, ptr noundef nonnull @.str.1) #2
  br label %16

16:                                               ; preds = %12, %15, %9
  %.not25 = icmp eq ptr %1, null
  br i1 %.not25, label %23, label %17

17:                                               ; preds = %16
  %18 = getelementptr inbounds i8, ptr %1, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %.not26 = icmp eq ptr %19, null
  br i1 %.not26, label %23, label %20

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %0, i64 800
  %22 = tail call ptr @ArpFindNextCacheEntryInTable(ptr noundef nonnull %21, ptr noundef null, i32 noundef 1, ptr noundef nonnull %1, ptr noundef null)
  %.not27 = icmp eq ptr %22, null
  br i1 %.not27, label %23, label %30

23:                                               ; preds = %20, %17, %16
  %.not28 = icmp eq ptr %2, null
  br i1 %.not28, label %30, label %24

24:                                               ; preds = %23
  %25 = getelementptr inbounds i8, ptr %2, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !19
  %.not29 = icmp eq ptr %26, null
  br i1 %.not29, label %30, label %27

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %0, i64 800
  %29 = tail call ptr @ArpFindNextCacheEntryInTable(ptr noundef nonnull %28, ptr noundef null, i32 noundef 2, ptr noundef null, ptr noundef nonnull %2)
  br label %30

30:                                               ; preds = %23, %24, %27, %20
  %.017 = phi ptr [ %22, %20 ], [ %29, %27 ], [ null, %24 ], [ null, %23 ]
  ret ptr %.017
}

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

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 = !{!"_ARP_SERVICE_DATA", !7, i64 0, !10, i64 8, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !12, i64 56, !14, i64 80, !16, i64 104, !15, i64 760, !18, i64 768, !18, i64 784, !18, i64 800, !18, i64 816, !11, i64 832}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"", !7, i64 0, !7, i64 4, !13, i64 8, !8, i64 10, !8, i64 11, !8, i64 12, !8, i64 13, !8, i64 14, !8, i64 15, !8, i64 16}
!13 = !{!"short", !8, i64 0}
!14 = !{!"", !11, i64 0, !15, i64 8, !8, i64 16}
!15 = !{!"long long", !8, i64 0}
!16 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !8, i64 40, !17, i64 552, !17, i64 584, !17, i64 616, !8, i64 648, !8, i64 649, !8, i64 650, !8, i64 651, !8, i64 652}
!17 = !{!"", !8, i64 0}
!18 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!19 = !{!20, !11, i64 8}
!20 = !{!"", !13, i64 0, !8, i64 2, !11, i64 8, !8, i64 16}


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