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

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

@.str = external hidden unnamed_addr constant [151 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @DhcpInitRequest(ptr noundef %0) #0 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  br label %6

6:                                                ; preds = %1
  %7 = call zeroext i8 @DebugAssertEnabled()
  %8 = icmp ne i8 %7, 0
  br i1 %8, label %9, label %21

9:                                                ; preds = %6
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %10, i32 0, i32 7
  %12 = load i64, ptr %11, align 8, !tbaa !9
  %13 = icmp eq i64 %12, 1
  br i1 %13, label %20, label %14

14:                                               ; preds = %9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %15, i32 0, i32 7
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = icmp eq i64 %17, 7
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  call void @DebugAssert(ptr noundef @.str, i64 noundef 38, ptr noundef @.str.1)
  br label %20

20:                                               ; preds = %19, %14, %9
  br label %21

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

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %24, i32 0, i32 27
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = getelementptr inbounds %struct._DHCP_PROTOCOL, ptr %26, i32 0, i32 11
  store i16 0, ptr %27, align 4, !tbaa !18
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %28, i32 0, i32 7
  %30 = load i64, ptr %29, align 8, !tbaa !9
  %31 = icmp eq i64 %30, 1
  br i1 %31, label %32, label %44

32:                                               ; preds = %23
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = call i64 @DhcpSetState(ptr noundef %33, i64 noundef 2, i8 noundef zeroext 0)
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = call i64 @DhcpSendMessage(ptr noundef %35, ptr noundef null, ptr noundef null, i8 noundef zeroext 1, ptr noundef null)
  store i64 %36, ptr %4, align 8, !tbaa !23
  %37 = load i64, ptr %4, align 8, !tbaa !23
  %38 = icmp slt i64 %37, 0
  br i1 %38, label %39, label %43

39:                                               ; preds = %32
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %40, i32 0, i32 7
  store i64 1, ptr %41, align 8, !tbaa !9
  %42 = load i64, ptr %4, align 8, !tbaa !23
  store i64 %42, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %57

43:                                               ; preds = %32
  br label %56

44:                                               ; preds = %23
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = call i64 @DhcpSetState(ptr noundef %45, i64 noundef 8, i8 noundef zeroext 0)
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = call i64 @DhcpSendMessage(ptr noundef %47, ptr noundef null, ptr noundef null, i8 noundef zeroext 3, ptr noundef null)
  store i64 %48, ptr %4, align 8, !tbaa !23
  %49 = load i64, ptr %4, align 8, !tbaa !23
  %50 = icmp slt i64 %49, 0
  br i1 %50, label %51, label %55

51:                                               ; preds = %44
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._DHCP_SERVICE, ptr %52, i32 0, i32 7
  store i64 7, ptr %53, align 8, !tbaa !9
  %54 = load i64, ptr %4, align 8, !tbaa !23
  store i64 %54, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %57

55:                                               ; preds = %44
  br label %56

56:                                               ; preds = %55, %43
  store i64 0, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %57

57:                                               ; preds = %56, %51, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %58 = load i64, ptr %2, align 8
  ret i64 %58
}

; 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: nounwind uwtable
declare dso_local i64 @DhcpSetState(ptr noundef, i64 noundef, i8 noundef zeroext) #0

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

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

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, !13, i64 72}
!10 = !{!"_DHCP_SERVICE", !11, i64 0, !12, i64 8, !13, i64 24, !6, i64 32, !6, i64 40, !14, i64 48, !13, i64 64, !13, i64 72, !13, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !6, i64 104, !6, i64 112, !6, i64 120, !11, i64 128, !11, i64 132, !11, i64 136, !13, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !15, i64 176, !7, i64 208, !7, i64 209, !7, i64 210, !6, i64 232, !16, i64 240, !11, i64 312, !6, i64 320, !11, i64 328, !11, i64 332, !13, i64 336, !13, i64 344, !11, i64 352}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"", !7, i64 0}
!16 = !{!"", !11, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !15, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !6, i64 64}
!17 = !{!10, !6, i64 232}
!18 = !{!19, !21, i64 156}
!19 = !{!"_DHCP_PROTOCOL", !11, i64 0, !20, i64 8, !14, 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, !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 = !{!"", !11, i64 0, !13, i64 8, !14, i64 16, !14, i64 32, !11, i64 48, !11, i64 52}
!23 = !{!13, !13, 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 [151 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775808, 1) i64 @DhcpInitRequest(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %2, 0
  br i1 %.not, label %7, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 72
  %5 = load i64, ptr %4, align 8, !tbaa !5
  switch i64 %5, label %6 [
    i64 1, label %7
    i64 7, label %7
  ]

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

7:                                                ; preds = %3, %3, %6, %1
  %8 = getelementptr inbounds i8, ptr %0, i64 232
  %9 = load ptr, ptr %8, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %9, i64 156
  store i16 0, ptr %10, align 4, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 72
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = icmp eq i64 %12, 1
  br i1 %13, label %14, label %18

14:                                               ; preds = %7
  %15 = tail call i64 @DhcpSetState(ptr noundef nonnull %0, i64 noundef 2, i8 noundef zeroext 0)
  %16 = tail call i64 @DhcpSendMessage(ptr noundef nonnull %0, ptr noundef null, ptr noundef null, i8 noundef zeroext 1, ptr noundef null)
  %17 = icmp slt i64 %16, 0
  br i1 %17, label %.sink.split, label %22

18:                                               ; preds = %7
  %19 = tail call i64 @DhcpSetState(ptr noundef nonnull %0, i64 noundef 8, i8 noundef zeroext 0)
  %20 = tail call i64 @DhcpSendMessage(ptr noundef nonnull %0, ptr noundef null, ptr noundef null, i8 noundef zeroext 3, ptr noundef null)
  %21 = icmp slt i64 %20, 0
  br i1 %21, label %.sink.split, label %22

.sink.split:                                      ; preds = %18, %14
  %.sink = phi i64 [ 1, %14 ], [ 7, %18 ]
  %.0.ph = phi i64 [ %16, %14 ], [ %20, %18 ]
  store i64 %.sink, ptr %11, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %.sink.split, %14, %18
  %.0 = phi i64 [ 0, %18 ], [ 0, %14 ], [ %.0.ph, %.sink.split ]
  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 @DhcpSetState(ptr noundef, i64 noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @DhcpSendMessage(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext, 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, !12, i64 72}
!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 = !{!6, !11, i64 232}
!17 = !{!18, !20, i64 156}
!18 = !{!"_DHCP_PROTOCOL", !7, i64 0, !19, 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, !20, i64 156, !21, i64 160}
!19 = !{!"_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}
!20 = !{!"short", !8, i64 0}
!21 = !{!"", !7, i64 0, !12, i64 8, !13, i64 16, !13, i64 32, !7, i64 48, !7, i64 52}


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