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

; 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.EFI_DHCP4_PACKET = type <{ i32, i32, %struct.anon }>
%struct.anon = type <{ %struct.EFI_DHCP4_HEADER, i32, [1 x i8] }>
%struct.EFI_DHCP4_HEADER = type { i8, i8, i8, i8, i32, i16, i16, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, [16 x i8], [64 x i8], [128 x i8] }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }

; Function Attrs: nounwind uwtable
define dso_local i64 @EfiDhcp4Build(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store ptr %3, ptr %12, align 8, !tbaa !5
  store i32 %4, ptr %13, align 4, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %21, label %18

18:                                               ; preds = %7
  %19 = load ptr, ptr %15, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %18, %7
  store i64 -9223372036854775806, ptr %8, align 8
  br label %63

22:                                               ; preds = %18
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %35, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.EFI_DHCP4_PACKET, ptr %26, i32 0, i32 2
  %28 = getelementptr inbounds %struct.anon, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 1, !tbaa !11
  %30 = icmp ne i32 %29, 1666417251
  br i1 %30, label %35, label %31

31:                                               ; preds = %25
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = call i64 @DhcpValidateOptions(ptr noundef %32, ptr noundef null)
  %34 = icmp slt i64 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %31, %25, %22
  store i64 -9223372036854775806, ptr %8, align 8
  br label %63

36:                                               ; preds = %31
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = load i32, ptr %13, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %54, label %42

42:                                               ; preds = %39, %36
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %48

45:                                               ; preds = %42
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = icmp eq ptr %46, null
  br i1 %47, label %54, label %48

48:                                               ; preds = %45, %42
  %49 = load i32, ptr %13, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %55

51:                                               ; preds = %48
  %52 = load ptr, ptr %14, align 8, !tbaa !5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %51, %45, %39
  store i64 -9223372036854775806, ptr %8, align 8
  br label %63

55:                                               ; preds = %51, %48
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = load i32, ptr %13, align 4, !tbaa !9
  %60 = load ptr, ptr %14, align 8, !tbaa !5
  %61 = load ptr, ptr %15, align 8, !tbaa !5
  %62 = call i64 @DhcpBuild(ptr noundef %56, i32 noundef %57, ptr noundef %58, i32 noundef %59, ptr noundef %60, ptr noundef %61)
  store i64 %62, ptr %8, align 8
  br label %63

63:                                               ; preds = %55, %54, %35, %21
  %64 = load i64, ptr %8, align 8
  ret i64 %64
}

declare i64 @DhcpValidateOptions(ptr noundef, ptr noundef) #1

declare i64 @DhcpBuild(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #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 = { "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" }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 244}
!12 = !{!"", !10, i64 0, !10, i64 4, !13, i64 8}
!13 = !{!"", !14, i64 0, !10, i64 236, !7, i64 240}
!14 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !10, i64 4, !15, i64 8, !15, i64 10, !16, i64 12, !16, i64 16, !16, i64 20, !16, i64 24, !7, i64 28, !7, i64 44, !7, i64 108}
!15 = !{!"short", !7, i64 0}
!16 = !{!"", !7, 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"

; Function Attrs: nounwind uwtable
define dso_local i64 @EfiDhcp4Build(ptr noundef readnone %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #0 {
  %8 = icmp eq ptr %0, null
  %9 = icmp eq ptr %6, null
  %or.cond = or i1 %8, %9
  %10 = icmp eq ptr %1, null
  %or.cond26 = or i1 %10, %or.cond
  br i1 %or.cond26, label %26, label %11

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %1, i64 244
  %13 = load i32, ptr %12, align 1, !tbaa !5
  %.not = icmp eq i32 %13, 1666417251
  br i1 %.not, label %14, label %26

14:                                               ; preds = %11
  %15 = tail call i64 @DhcpValidateOptions(ptr noundef nonnull %1, ptr noundef null) #2
  %16 = icmp slt i64 %15, 0
  %17 = or i32 %4, %2
  %or.cond3 = icmp eq i32 %17, 0
  %or.cond27 = or i1 %or.cond3, %16
  br i1 %or.cond27, label %26, label %18

18:                                               ; preds = %14
  %19 = icmp ne i32 %2, 0
  %20 = icmp eq ptr %3, null
  %or.cond5 = and i1 %19, %20
  br i1 %or.cond5, label %26, label %21

21:                                               ; preds = %18
  %22 = icmp ne i32 %4, 0
  %23 = icmp eq ptr %5, null
  %or.cond7 = and i1 %22, %23
  br i1 %or.cond7, label %26, label %24

24:                                               ; preds = %21
  %25 = tail call i64 @DhcpBuild(ptr noundef nonnull %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef %5, ptr noundef nonnull %6) #2
  br label %26

26:                                               ; preds = %18, %21, %11, %14, %7, %24
  %.0 = phi i64 [ %25, %24 ], [ -9223372036854775806, %7 ], [ -9223372036854775806, %14 ], [ -9223372036854775806, %11 ], [ -9223372036854775806, %21 ], [ -9223372036854775806, %18 ]
  ret i64 %.0
}

declare i64 @DhcpValidateOptions(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i64 @DhcpBuild(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { "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 244}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !7, i64 236, !8, i64 240}
!11 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !7, i64 4, !12, i64 8, !12, i64 10, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !8, i64 28, !8, i64 44, !8, i64 108}
!12 = !{!"short", !8, i64 0}
!13 = !{!"", !8, i64 0}


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