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

; 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._IP4_PROTOCOL = type { i32, %struct._EFI_IP4_PROTOCOL, ptr, i64, ptr, %struct._LIST_ENTRY, %struct.NET_MAP, %struct.NET_MAP, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct.EFI_LOCK, ptr, %struct._LIST_ENTRY, ptr, ptr, i32, ptr, i32, %struct.EFI_IP4_CONFIG_DATA }
%struct._EFI_IP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.NET_MAP = type { %struct._LIST_ENTRY, %struct._LIST_ENTRY, i64 }
%struct.EFI_LOCK = type { i64, i64, i32 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_IP4_CONFIG_DATA = type { i8, i8, i8, i8, i8, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i8, i8, i8, i8, i32, i32 }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct.EFI_BOOT_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }
%struct._IP4_INTERFACE = type { i32, %struct._LIST_ENTRY, i64, i32, i32, i32, i32, i8, ptr, ptr, ptr, ptr, ptr, %struct._LIST_ENTRY, %struct._LIST_ENTRY, ptr, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, i32, %struct._LIST_ENTRY, i8 }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }

@gBS = external global ptr, align 8
@.str = external hidden unnamed_addr constant [149 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @EfiIp4Cancel(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  store i64 -9223372036854775806, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %68

13:                                               ; preds = %2
  %14 = call zeroext i8 @DebugAssertEnabled()
  %15 = zext i8 %14 to i32
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %27

17:                                               ; preds = %13
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = ptrtoint ptr %18 to i64
  %20 = sub i64 %19, ptrtoint (ptr getelementptr inbounds (%struct._IP4_PROTOCOL, ptr null, i32 0, i32 1) to i64)
  %21 = inttoptr i64 %20 to ptr
  %22 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = icmp ne i32 %23, 1345605705
  br i1 %24, label %25, label %27

25:                                               ; preds = %17
  call void @DebugAssert(ptr noundef @.str, i64 noundef 2481, ptr noundef @.str.1)
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  br label %32

27:                                               ; preds = %17, %13
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = ptrtoint ptr %28 to i64
  %30 = sub i64 %29, ptrtoint (ptr getelementptr inbounds (%struct._IP4_PROTOCOL, ptr null, i32 0, i32 1) to i64)
  %31 = inttoptr i64 %30 to ptr
  br label %32

32:                                               ; preds = %27, %25
  %33 = phi ptr [ %26, %25 ], [ %31, %27 ]
  store ptr %33, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr @gBS, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !19
  %37 = call i64 %36(i64 noundef 8)
  store i64 %37, ptr %8, align 8, !tbaa !22
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %38, i32 0, i32 3
  %40 = load i64, ptr %39, align 8, !tbaa !23
  %41 = icmp ne i64 %40, 1
  br i1 %41, label %42, label %43

42:                                               ; preds = %32
  store i64 -9223372036854775789, ptr %7, align 8, !tbaa !22
  br label %62

43:                                               ; preds = %32
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %44, i32 0, i32 18
  %46 = getelementptr inbounds %struct.EFI_IP4_CONFIG_DATA, ptr %45, i32 0, i32 5
  %47 = load i8, ptr %46, align 1, !tbaa !24
  %48 = zext i8 %47 to i32
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %58

50:                                               ; preds = %43
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._IP4_PROTOCOL, ptr %51, i32 0, i32 11
  %53 = load ptr, ptr %52, align 8, !tbaa !25
  %54 = getelementptr inbounds %struct._IP4_INTERFACE, ptr %53, i32 0, i32 7
  %55 = load i8, ptr %54, align 8, !tbaa !26
  %56 = icmp ne i8 %55, 0
  br i1 %56, label %58, label %57

57:                                               ; preds = %50
  store i64 -9223372036854775791, ptr %7, align 8, !tbaa !22
  br label %62

58:                                               ; preds = %50, %43
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = call i64 @Ip4Cancel(ptr noundef %59, ptr noundef %60)
  store i64 %61, ptr %7, align 8, !tbaa !22
  br label %62

62:                                               ; preds = %58, %57, %42
  %63 = load ptr, ptr @gBS, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !28
  %66 = load i64, ptr %8, align 8, !tbaa !22
  call void %65(i64 noundef %66)
  %67 = load i64, ptr %7, align 8, !tbaa !22
  store i64 %67, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %68

68:                                               ; preds = %62, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %69 = load i64, ptr %3, align 8
  ret i64 %69
}

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

declare zeroext i8 @DebugAssertEnabled() #2

declare void @DebugAssert(ptr noundef, i64 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

; Function Attrs: nounwind uwtable
declare dso_local i64 @Ip4Cancel(ptr noundef, ptr noundef) #0

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"_IP4_PROTOCOL", !11, i64 0, !12, i64 8, !6, i64 72, !13, i64 80, !6, i64 88, !14, i64 96, !15, i64 112, !15, i64 152, !14, i64 192, !14, i64 208, !16, i64 224, !6, i64 248, !14, i64 256, !6, i64 272, !6, i64 280, !11, i64 288, !6, i64 296, !11, i64 304, !17, i64 308}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_IP4_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}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"", !14, i64 0, !14, i64 16, !13, i64 32}
!16 = !{!"", !13, i64 0, !13, i64 8, !11, i64 16}
!17 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !18, i64 6, !18, i64 10, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 17, !11, i64 20, !11, i64 24}
!18 = !{!"", !7, i64 0}
!19 = !{!20, !6, i64 24}
!20 = !{!"", !21, i64 0, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!21 = !{!"", !13, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!22 = !{!13, !13, i64 0}
!23 = !{!10, !13, i64 80}
!24 = !{!10, !7, i64 313}
!25 = !{!10, !6, i64 248}
!26 = !{!27, !7, i64 48}
!27 = !{!"_IP4_INTERFACE", !11, i64 0, !14, i64 8, !13, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !7, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !14, i64 96, !14, i64 112, !6, i64 128, !18, i64 136, !18, i64 168, !11, i64 200, !14, i64 208, !7, i64 224}
!28 = !{!20, !6, i64 32}


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

@gBS = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [149 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @EfiIp4Cancel(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %30, label %4

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

6:                                                ; preds = %4
  %7 = load i32, ptr %.pre19, align 8, !tbaa !5
  %.not13 = icmp eq i32 %7, 1345605705
  br i1 %.not13, label %._crit_edge, label %8

8:                                                ; preds = %6
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 2481, ptr noundef nonnull @.str.1) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %4, %6, %8
  %9 = phi ptr [ %0, %8 ], [ %.pre19, %6 ], [ %.pre19, %4 ]
  %10 = load ptr, ptr @gBS, align 8, !tbaa !18
  %11 = getelementptr inbounds i8, ptr %10, i64 24
  %12 = load ptr, ptr %11, align 8, !tbaa !19
  %13 = tail call i64 %12(i64 noundef 8) #2
  %14 = getelementptr inbounds i8, ptr %9, i64 80
  %15 = load i64, ptr %14, align 8, !tbaa !22
  %.not14 = icmp eq i64 %15, 1
  br i1 %.not14, label %16, label %26

16:                                               ; preds = %._crit_edge
  %17 = getelementptr inbounds i8, ptr %9, i64 313
  %18 = load i8, ptr %17, align 1, !tbaa !23
  %.not15 = icmp eq i8 %18, 0
  br i1 %.not15, label %24, label %19

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %9, i64 248
  %21 = load ptr, ptr %20, align 8, !tbaa !24
  %22 = getelementptr inbounds i8, ptr %21, i64 48
  %23 = load i8, ptr %22, align 8, !tbaa !25
  %.not16 = icmp eq i8 %23, 0
  br i1 %.not16, label %26, label %24

24:                                               ; preds = %19, %16
  %25 = tail call i64 @Ip4Cancel(ptr noundef nonnull %9, ptr noundef %1)
  br label %26

26:                                               ; preds = %19, %._crit_edge, %24
  %.011 = phi i64 [ %25, %24 ], [ -9223372036854775789, %._crit_edge ], [ -9223372036854775791, %19 ]
  %27 = load ptr, ptr @gBS, align 8, !tbaa !18
  %28 = getelementptr inbounds i8, ptr %27, i64 32
  %29 = load ptr, ptr %28, align 8, !tbaa !27
  tail call void %29(i64 noundef %13) #2
  br label %30

30:                                               ; preds = %2, %26
  %.0 = phi i64 [ %.011, %26 ], [ -9223372036854775806, %2 ]
  ret i64 %.0
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @Ip4Cancel(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 #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 }

!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 = !{!"_IP4_PROTOCOL", !7, i64 0, !10, i64 8, !11, i64 72, !12, i64 80, !11, i64 88, !13, i64 96, !14, i64 112, !14, i64 152, !13, i64 192, !13, i64 208, !15, i64 224, !11, i64 248, !13, i64 256, !11, i64 272, !11, i64 280, !7, i64 288, !11, i64 296, !7, i64 304, !16, i64 308}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_EFI_IP4_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 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!14 = !{!"", !13, i64 0, !13, i64 16, !12, i64 32}
!15 = !{!"", !12, i64 0, !12, i64 8, !7, i64 16}
!16 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !17, i64 6, !17, i64 10, !8, i64 14, !8, i64 15, !8, i64 16, !8, i64 17, !7, i64 20, !7, i64 24}
!17 = !{!"", !8, i64 0}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !11, i64 24}
!20 = !{!"", !21, i64 0, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !11, i64 184, !11, i64 192, !11, i64 200, !11, i64 208, !11, i64 216, !11, i64 224, !11, i64 232, !11, i64 240, !11, i64 248, !11, i64 256, !11, i64 264, !11, i64 272, !11, i64 280, !11, i64 288, !11, i64 296, !11, i64 304, !11, i64 312, !11, i64 320, !11, i64 328, !11, i64 336, !11, i64 344, !11, i64 352, !11, i64 360, !11, i64 368}
!21 = !{!"", !12, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!22 = !{!6, !12, i64 80}
!23 = !{!6, !8, i64 313}
!24 = !{!6, !11, i64 248}
!25 = !{!26, !8, i64 48}
!26 = !{!"_IP4_INTERFACE", !7, i64 0, !13, i64 8, !12, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !8, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !13, i64 96, !13, i64 112, !11, i64 128, !17, i64 136, !17, i64 168, !7, i64 200, !13, i64 208, !8, i64 224}
!27 = !{!20, !11, i64 32}


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