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

; 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_PARAMETER = type { i32, i32, i8, i8, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i64 @DhcpGetParameter(i8 noundef zeroext %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i64, align 8
  %6 = alloca i8, align 1
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store i8 %0, ptr %6, align 1, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !8
  store ptr %2, ptr %8, align 8, !tbaa !10
  store ptr %3, ptr %9, align 8, !tbaa !10
  %10 = load i8, ptr %6, align 1, !tbaa !5
  %11 = zext i8 %10 to i32
  switch i32 %11, label %78 [
    i32 1, label %12
    i32 3, label %17
    i32 51, label %22
    i32 52, label %27
    i32 53, label %45
    i32 54, label %63
    i32 58, label %68
    i32 59, label %73
  ]

12:                                               ; preds = %4
  %13 = load ptr, ptr %8, align 8, !tbaa !10
  %14 = call i32 @NetGetUint32(ptr noundef %13)
  %15 = load ptr, ptr %9, align 8, !tbaa !10
  %16 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %15, i32 0, i32 0
  store i32 %14, ptr %16, align 4, !tbaa !12
  br label %78

17:                                               ; preds = %4
  %18 = load ptr, ptr %8, align 8, !tbaa !10
  %19 = call i32 @NetGetUint32(ptr noundef %18)
  %20 = load ptr, ptr %9, align 8, !tbaa !10
  %21 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %20, i32 0, i32 1
  store i32 %19, ptr %21, align 4, !tbaa !15
  br label %78

22:                                               ; preds = %4
  %23 = load ptr, ptr %8, align 8, !tbaa !10
  %24 = call i32 @NetGetUint32(ptr noundef %23)
  %25 = load ptr, ptr %9, align 8, !tbaa !10
  %26 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %25, i32 0, i32 5
  store i32 %24, ptr %26, align 4, !tbaa !16
  br label %78

27:                                               ; preds = %4
  %28 = load ptr, ptr %8, align 8, !tbaa !10
  %29 = load i8, ptr %28, align 1, !tbaa !5
  %30 = load ptr, ptr %9, align 8, !tbaa !10
  %31 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %30, i32 0, i32 3
  store i8 %29, ptr %31, align 1, !tbaa !17
  %32 = load ptr, ptr %9, align 8, !tbaa !10
  %33 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %32, i32 0, i32 3
  %34 = load i8, ptr %33, align 1, !tbaa !17
  %35 = zext i8 %34 to i32
  %36 = icmp slt i32 %35, 1
  br i1 %36, label %43, label %37

37:                                               ; preds = %27
  %38 = load ptr, ptr %9, align 8, !tbaa !10
  %39 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %38, i32 0, i32 3
  %40 = load i8, ptr %39, align 1, !tbaa !17
  %41 = zext i8 %40 to i32
  %42 = icmp sgt i32 %41, 3
  br i1 %42, label %43, label %44

43:                                               ; preds = %37, %27
  store i64 -9223372036854775806, ptr %5, align 8
  br label %79

44:                                               ; preds = %37
  br label %78

45:                                               ; preds = %4
  %46 = load ptr, ptr %8, align 8, !tbaa !10
  %47 = load i8, ptr %46, align 1, !tbaa !5
  %48 = load ptr, ptr %9, align 8, !tbaa !10
  %49 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %48, i32 0, i32 2
  store i8 %47, ptr %49, align 4, !tbaa !18
  %50 = load ptr, ptr %9, align 8, !tbaa !10
  %51 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %50, i32 0, i32 2
  %52 = load i8, ptr %51, align 4, !tbaa !18
  %53 = zext i8 %52 to i32
  %54 = icmp slt i32 %53, 1
  br i1 %54, label %61, label %55

55:                                               ; preds = %45
  %56 = load ptr, ptr %9, align 8, !tbaa !10
  %57 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %56, i32 0, i32 2
  %58 = load i8, ptr %57, align 4, !tbaa !18
  %59 = zext i8 %58 to i32
  %60 = icmp sgt i32 %59, 9
  br i1 %60, label %61, label %62

61:                                               ; preds = %55, %45
  store i64 -9223372036854775806, ptr %5, align 8
  br label %79

62:                                               ; preds = %55
  br label %78

63:                                               ; preds = %4
  %64 = load ptr, ptr %8, align 8, !tbaa !10
  %65 = call i32 @NetGetUint32(ptr noundef %64)
  %66 = load ptr, ptr %9, align 8, !tbaa !10
  %67 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %66, i32 0, i32 4
  store i32 %65, ptr %67, align 4, !tbaa !19
  br label %78

68:                                               ; preds = %4
  %69 = load ptr, ptr %8, align 8, !tbaa !10
  %70 = call i32 @NetGetUint32(ptr noundef %69)
  %71 = load ptr, ptr %9, align 8, !tbaa !10
  %72 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %71, i32 0, i32 6
  store i32 %70, ptr %72, align 4, !tbaa !20
  br label %78

73:                                               ; preds = %4
  %74 = load ptr, ptr %8, align 8, !tbaa !10
  %75 = call i32 @NetGetUint32(ptr noundef %74)
  %76 = load ptr, ptr %9, align 8, !tbaa !10
  %77 = getelementptr inbounds %struct.DHCP_PARAMETER, ptr %76, i32 0, i32 7
  store i32 %75, ptr %77, align 4, !tbaa !21
  br label %78

78:                                               ; preds = %73, %68, %63, %62, %44, %22, %17, %12, %4
  store i64 0, ptr %5, align 8
  br label %79

79:                                               ; preds = %78, %61, %43
  %80 = load i64, ptr %5, align 8
  ret i64 %80
}

declare i32 @NetGetUint32(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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"", !14, i64 0, !14, i64 4, !6, i64 8, !6, i64 9, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24}
!14 = !{!"int", !6, i64 0}
!15 = !{!13, !14, i64 4}
!16 = !{!13, !14, i64 16}
!17 = !{!13, !6, i64 9}
!18 = !{!13, !6, i64 8}
!19 = !{!13, !14, i64 12}
!20 = !{!13, !14, i64 20}
!21 = !{!13, !14, i64 24}


; 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 range(i64 -9223372036854775806, 1) i64 @DhcpGetParameter(i8 noundef zeroext %0, i64 noundef %1, ptr noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  switch i8 %0, label %30 [
    i8 1, label %5
    i8 3, label %7
    i8 51, label %10
    i8 52, label %13
    i8 53, label %17
    i8 54, label %21
    i8 58, label %24
    i8 59, label %27
  ]

5:                                                ; preds = %4
  %6 = tail call i32 @NetGetUint32(ptr noundef %2) #2
  store i32 %6, ptr %3, align 4, !tbaa !5
  br label %30

7:                                                ; preds = %4
  %8 = tail call i32 @NetGetUint32(ptr noundef %2) #2
  %9 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %8, ptr %9, align 4, !tbaa !10
  br label %30

10:                                               ; preds = %4
  %11 = tail call i32 @NetGetUint32(ptr noundef %2) #2
  %12 = getelementptr inbounds i8, ptr %3, i64 16
  store i32 %11, ptr %12, align 4, !tbaa !11
  br label %30

13:                                               ; preds = %4
  %14 = load i8, ptr %2, align 1, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %3, i64 9
  store i8 %14, ptr %15, align 1, !tbaa !13
  %16 = add i8 %14, -4
  %or.cond = icmp ult i8 %16, -3
  br i1 %or.cond, label %31, label %30

17:                                               ; preds = %4
  %18 = load i8, ptr %2, align 1, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %3, i64 8
  store i8 %18, ptr %19, align 4, !tbaa !14
  %20 = add i8 %18, -10
  %or.cond23 = icmp ult i8 %20, -9
  br i1 %or.cond23, label %31, label %30

21:                                               ; preds = %4
  %22 = tail call i32 @NetGetUint32(ptr noundef %2) #2
  %23 = getelementptr inbounds i8, ptr %3, i64 12
  store i32 %22, ptr %23, align 4, !tbaa !15
  br label %30

24:                                               ; preds = %4
  %25 = tail call i32 @NetGetUint32(ptr noundef %2) #2
  %26 = getelementptr inbounds i8, ptr %3, i64 20
  store i32 %25, ptr %26, align 4, !tbaa !16
  br label %30

27:                                               ; preds = %4
  %28 = tail call i32 @NetGetUint32(ptr noundef %2) #2
  %29 = getelementptr inbounds i8, ptr %3, i64 24
  store i32 %28, ptr %29, align 4, !tbaa !17
  br label %30

30:                                               ; preds = %17, %13, %27, %24, %21, %10, %7, %5, %4
  br label %31

31:                                               ; preds = %17, %13, %30
  %.0 = phi i64 [ 0, %30 ], [ -9223372036854775806, %13 ], [ -9223372036854775806, %17 ]
  ret i64 %.0
}

declare i32 @NetGetUint32(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 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !8, i64 8, !8, i64 9, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!6, !7, i64 16}
!12 = !{!8, !8, i64 0}
!13 = !{!6, !8, i64 9}
!14 = !{!6, !8, i64 8}
!15 = !{!6, !7, i64 12}
!16 = !{!6, !7, i64 20}
!17 = !{!6, !7, i64 24}


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