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

; 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._DHCP_PROTOCOL = type { i32, %struct._EFI_DHCP4_PROTOCOL, %struct._LIST_ENTRY, ptr, ptr, i8, ptr, ptr, ptr, ptr, i32, i16, %struct.NET_BUF_QUEUE }
%struct._EFI_DHCP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.NET_BUF_QUEUE = type { i32, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32 }
%struct._EFI_SERVICE_BINDING_PROTOCOL = type { ptr, ptr }

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

declare zeroext i8 @DebugAssertEnabled() #1

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

; Function Attrs: nounwind uwtable
define dso_local i64 @Dhcp4DestroyChildEntry(ptr noundef %0, ptr noundef %1) #2 {
  %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 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
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %14, label %11

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %11, %2
  store i64 -9223372036854775806, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %45

15:                                               ; preds = %11
  %16 = call zeroext i8 @DebugAssertEnabled()
  %17 = zext i8 %16 to i32
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %29

19:                                               ; preds = %15
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = ptrtoint ptr %20 to i64
  %22 = sub i64 %21, ptrtoint (ptr getelementptr inbounds (%struct._DHCP_PROTOCOL, ptr null, i32 0, i32 2) to i64)
  %23 = inttoptr i64 %22 to ptr
  %24 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !9
  %26 = icmp ne i32 %25, 1885562980
  br i1 %26, label %27, label %29

27:                                               ; preds = %19
  call void @DebugAssert(ptr noundef @.str, i64 noundef 380, ptr noundef @.str.2)
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  br label %34

29:                                               ; preds = %19, %15
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = ptrtoint ptr %30 to i64
  %32 = sub i64 %31, ptrtoint (ptr getelementptr inbounds (%struct._DHCP_PROTOCOL, ptr null, i32 0, i32 2) to i64)
  %33 = inttoptr i64 %32 to ptr
  br label %34

34:                                               ; preds = %29, %27
  %35 = phi ptr [ %28, %27 ], [ %33, %29 ]
  store ptr %35, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %36, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._EFI_SERVICE_BINDING_PROTOCOL, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %41, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !19
  %44 = call i64 %39(ptr noundef %40, ptr noundef %43)
  store i64 %44, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %45

45:                                               ; preds = %34, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %46 = load i64, ptr %3, align 8
  ret i64 %46
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = !{!"_DHCP_PROTOCOL", !11, i64 0, !12, i64 8, !13, i64 80, !6, i64 96, !6, i64 104, !7, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !11, i64 152, !14, i64 156, !15, i64 160}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_DHCP4_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !11, i64 0, !16, i64 8, !13, i64 16, !13, i64 32, !11, i64 48, !11, i64 52}
!16 = !{!"long long", !7, i64 0}
!17 = !{!18, !6, i64 8}
!18 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!19 = !{!10, !6, i64 96}


; 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 [155 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 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 i64 @Dhcp4DestroyChildEntry(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %16, label %5

5:                                                ; preds = %2
  %6 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %6, 0
  %.pre = ptrtoint ptr %0 to i64
  %.pre13 = add i64 %.pre, -80
  %.pre15 = inttoptr i64 %.pre13 to ptr
  br i1 %.not, label %._crit_edge, label %7

7:                                                ; preds = %5
  %8 = load i32, ptr %.pre15, align 8, !tbaa !5
  %.not12 = icmp eq i32 %8, 1885562980
  br i1 %.not12, label %._crit_edge, label %9

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

._crit_edge:                                      ; preds = %5, %7, %9
  %10 = phi ptr [ %0, %9 ], [ %.pre15, %7 ], [ %.pre15, %5 ]
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %10, i64 96
  %14 = load ptr, ptr %13, align 8, !tbaa !18
  %15 = tail call i64 %12(ptr noundef nonnull %1, ptr noundef %14) #2
  br label %16

16:                                               ; preds = %2, %._crit_edge
  %.0 = phi i64 [ %15, %._crit_edge ], [ -9223372036854775806, %2 ]
  ret i64 %.0
}

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 = !{!"_DHCP_PROTOCOL", !7, i64 0, !10, i64 8, !12, i64 80, !11, i64 96, !11, i64 104, !8, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !7, i64 152, !13, i64 156, !14, i64 160}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_EFI_DHCP4_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!13 = !{!"short", !8, i64 0}
!14 = !{!"", !7, i64 0, !15, i64 8, !12, i64 16, !12, i64 32, !7, i64 48, !7, i64 52}
!15 = !{!"long long", !8, i64 0}
!16 = !{!17, !11, i64 8}
!17 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !11, i64 0, !11, i64 8}
!18 = !{!6, !11, i64 96}


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