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

; 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_SERVICE = type { i32, %struct._EFI_SERVICE_BINDING_PROTOCOL, i64, ptr, ptr, %struct._LIST_ENTRY, i64, i64, i64, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i64, ptr, ptr, ptr, %struct.EFI_MAC_ADDRESS, i8, i8, [16 x i8], ptr, %struct.EFI_DHCP4_CONFIG_DATA, i32, ptr, i32, i32, i64, i64, i32 }
%struct._EFI_SERVICE_BINDING_PROTOCOL = type { ptr, ptr }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }
%struct.EFI_DHCP4_CONFIG_DATA = type { i32, ptr, i32, ptr, %struct.EFI_IPv4_ADDRESS, ptr, ptr, i32, ptr }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%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.NET_BUF_QUEUE = type { i32, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32 }
%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 }

@gBS = external global ptr, align 8

; 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

; Function Attrs: nounwind uwtable
define dso_local void @DhcpNotifyUser(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %7, i32 0, i32 27
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  store ptr %9, ptr %5, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  store i32 1, ptr %6, align 4
  br label %55

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %13, i32 0, i32 6
  %15 = load ptr, ptr %14, align 8, !tbaa !18
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %33

17:                                               ; preds = %12
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = icmp eq i64 %18, 1
  br i1 %19, label %23, label %20

20:                                               ; preds = %17
  %21 = load i64, ptr %4, align 8, !tbaa !9
  %22 = icmp eq i64 %21, 3
  br i1 %22, label %23, label %33

23:                                               ; preds = %20, %17
  %24 = load ptr, ptr @gBS, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %24, i32 0, i32 11
  %26 = load ptr, ptr %25, align 8, !tbaa !23
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %27, i32 0, i32 6
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  %30 = call i64 %26(ptr noundef %29)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %31, i32 0, i32 6
  store ptr null, ptr %32, align 8, !tbaa !18
  br label %33

33:                                               ; preds = %23, %20, %12
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %34, i32 0, i32 7
  %36 = load ptr, ptr %35, align 8, !tbaa !26
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %54

38:                                               ; preds = %33
  %39 = load i64, ptr %4, align 8, !tbaa !9
  %40 = icmp eq i64 %39, 2
  br i1 %40, label %44, label %41

41:                                               ; preds = %38
  %42 = load i64, ptr %4, align 8, !tbaa !9
  %43 = icmp eq i64 %42, 3
  br i1 %43, label %44, label %54

44:                                               ; preds = %41, %38
  %45 = load ptr, ptr @gBS, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %45, i32 0, i32 11
  %47 = load ptr, ptr %46, align 8, !tbaa !23
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %48, i32 0, i32 7
  %50 = load ptr, ptr %49, align 8, !tbaa !26
  %51 = call i64 %47(ptr noundef %50)
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %52, i32 0, i32 7
  store ptr null, ptr %53, align 8, !tbaa !26
  br label %54

54:                                               ; preds = %44, %41, %33
  store i32 0, ptr %6, align 4
  br label %55

55:                                               ; preds = %54, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  %56 = load i32, ptr %6, align 4
  switch i32 %56, label %58 [
    i32 0, label %57
    i32 1, label %57
  ]

57:                                               ; preds = %55, %55
  ret void

58:                                               ; preds = %55
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 232}
!12 = !{!"_DHCP_SERVICE", !13, i64 0, !14, i64 8, !10, i64 24, !6, i64 32, !6, i64 40, !15, i64 48, !10, i64 64, !10, i64 72, !10, i64 80, !13, i64 88, !13, i64 92, !13, i64 96, !13, i64 100, !6, i64 104, !6, i64 112, !6, i64 120, !13, i64 128, !13, i64 132, !13, i64 136, !10, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !16, i64 176, !7, i64 208, !7, i64 209, !7, i64 210, !6, i64 232, !17, i64 240, !13, i64 312, !6, i64 320, !13, i64 328, !13, i64 332, !10, i64 336, !10, i64 344, !13, i64 352}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!15 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!16 = !{!"", !7, i64 0}
!17 = !{!"", !13, i64 0, !6, i64 8, !13, i64 16, !6, i64 24, !16, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !6, i64 64}
!18 = !{!19, !6, i64 120}
!19 = !{!"_DHCP_PROTOCOL", !13, i64 0, !20, i64 8, !15, i64 80, !6, i64 96, !6, i64 104, !7, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !13, i64 152, !21, i64 156, !22, i64 160}
!20 = !{!"_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}
!21 = !{!"short", !7, i64 0}
!22 = !{!"", !13, i64 0, !10, i64 8, !15, i64 16, !15, i64 32, !13, i64 48, !13, i64 52}
!23 = !{!24, !6, i64 104}
!24 = !{!"", !25, 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}
!25 = !{!"", !10, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20}
!26 = !{!19, !6, i64 128}


; 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

; Function Attrs: nounwind uwtable
define dso_local void @DhcpNotifyUser(ptr nocapture noundef readonly %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 232
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %24, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %4, i64 120
  %8 = load ptr, ptr %7, align 8, !tbaa !16
  %.not = icmp ne ptr %8, null
  %9 = and i64 %1, -3
  %or.cond = icmp eq i64 %9, 1
  %or.cond16 = and i1 %or.cond, %.not
  br i1 %or.cond16, label %10, label %15

10:                                               ; preds = %6
  %11 = load ptr, ptr @gBS, align 8, !tbaa !21
  %12 = getelementptr inbounds i8, ptr %11, i64 104
  %13 = load ptr, ptr %12, align 8, !tbaa !22
  %14 = tail call i64 %13(ptr noundef nonnull %8) #1
  store ptr null, ptr %7, align 8, !tbaa !16
  br label %15

15:                                               ; preds = %10, %6
  %16 = getelementptr inbounds i8, ptr %4, i64 128
  %17 = load ptr, ptr %16, align 8, !tbaa !25
  %.not15 = icmp ne ptr %17, null
  %18 = and i64 %1, -2
  %or.cond3 = icmp eq i64 %18, 2
  %or.cond17 = and i1 %or.cond3, %.not15
  br i1 %or.cond17, label %19, label %24

19:                                               ; preds = %15
  %20 = load ptr, ptr @gBS, align 8, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %20, i64 104
  %22 = load ptr, ptr %21, align 8, !tbaa !22
  %23 = tail call i64 %22(ptr noundef nonnull %17) #1
  store ptr null, ptr %16, align 8, !tbaa !25
  br label %24

24:                                               ; preds = %15, %19, %2
  ret void
}

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 = { 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, !11, i64 232}
!6 = !{!"_DHCP_SERVICE", !7, i64 0, !10, i64 8, !12, i64 24, !11, i64 32, !11, i64 40, !13, i64 48, !12, i64 64, !12, i64 72, !12, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !11, i64 104, !11, i64 112, !11, i64 120, !7, i64 128, !7, i64 132, !7, i64 136, !12, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !14, i64 176, !8, i64 208, !8, i64 209, !8, i64 210, !11, i64 232, !15, i64 240, !7, i64 312, !11, i64 320, !7, i64 328, !7, i64 332, !12, i64 336, !12, i64 344, !7, i64 352}
!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 = !{!"long long", !8, i64 0}
!13 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!14 = !{!"", !8, i64 0}
!15 = !{!"", !7, i64 0, !11, i64 8, !7, i64 16, !11, i64 24, !14, i64 32, !11, i64 40, !11, i64 48, !7, i64 56, !11, i64 64}
!16 = !{!17, !11, i64 120}
!17 = !{!"_DHCP_PROTOCOL", !7, i64 0, !18, i64 8, !13, 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, !19, i64 156, !20, i64 160}
!18 = !{!"_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}
!19 = !{!"short", !8, i64 0}
!20 = !{!"", !7, i64 0, !12, i64 8, !13, i64 16, !13, i64 32, !7, i64 48, !7, i64 52}
!21 = !{!11, !11, i64 0}
!22 = !{!23, !11, i64 104}
!23 = !{!"", !24, 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}
!24 = !{!"", !12, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!25 = !{!17, !11, i64 128}


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