; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdePkg/Library (DevPathToTextAcpi)

; 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.ACPI_HID_DEVICE_PATH = type { %struct.EFI_DEVICE_PATH_PROTOCOL, i32, i32 }
%struct.EFI_DEVICE_PATH_PROTOCOL = type { i8, i8, [2 x i8] }

@.str.36 = external hidden unnamed_addr constant [14 x i32], align 4
@.str.37 = external hidden unnamed_addr constant [15 x i32], align 4
@.str.38 = external hidden unnamed_addr constant [13 x i32], align 4
@.str.39 = external hidden unnamed_addr constant [15 x i32], align 4
@.str.40 = external hidden unnamed_addr constant [13 x i32], align 4
@.str.41 = external hidden unnamed_addr constant [19 x i32], align 4
@.str.42 = external hidden unnamed_addr constant [19 x i32], align 4
@.str.43 = external hidden unnamed_addr constant [18 x i32], align 4

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

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

; 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
define dso_local void @DevPathToTextAcpi(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2, i8 noundef zeroext %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i8 %2, ptr %7, align 1, !tbaa !9
  store i8 %3, ptr %8, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %10, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr %9, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 1, !tbaa !10
  %14 = and i32 %13, 65535
  %15 = icmp eq i32 %14, 16848
  br i1 %15, label %16, label %68

16:                                               ; preds = %4
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 1, !tbaa !10
  %20 = lshr i32 %19, 16
  switch i32 %20, label %57 [
    i32 2563, label %21
    i32 2568, label %27
    i32 1540, label %33
    i32 769, label %39
    i32 1281, label %45
    i32 1025, label %51
  ]

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %24, align 1, !tbaa !14
  %26 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %22, ptr noundef @.str.36, i32 noundef %25)
  br label %67

27:                                               ; preds = %16
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %29, i32 0, i32 2
  %31 = load i32, ptr %30, align 1, !tbaa !14
  %32 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %28, ptr noundef @.str.37, i32 noundef %31)
  br label %67

33:                                               ; preds = %16
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 1, !tbaa !14
  %38 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %34, ptr noundef @.str.38, i32 noundef %37)
  br label %67

39:                                               ; preds = %16
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %41, i32 0, i32 2
  %43 = load i32, ptr %42, align 1, !tbaa !14
  %44 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %40, ptr noundef @.str.39, i32 noundef %43)
  br label %67

45:                                               ; preds = %16
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 1, !tbaa !14
  %50 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %46, ptr noundef @.str.40, i32 noundef %49)
  br label %67

51:                                               ; preds = %16
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 1, !tbaa !14
  %56 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %52, ptr noundef @.str.41, i32 noundef %55)
  br label %67

57:                                               ; preds = %16
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 1, !tbaa !10
  %62 = lshr i32 %61, 16
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 1, !tbaa !14
  %66 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %58, ptr noundef @.str.42, i32 noundef %62, i32 noundef %65)
  br label %67

67:                                               ; preds = %57, %51, %45, %39, %33, %27, %21
  br label %77

68:                                               ; preds = %4
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 1, !tbaa !10
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ACPI_HID_DEVICE_PATH, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 1, !tbaa !14
  %76 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %69, ptr noundef @.str.43, i32 noundef %72, i32 noundef %75)
  br label %77

77:                                               ; preds = %68, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!7, !7, i64 0}
!10 = !{!11, !13, i64 4}
!11 = !{!"", !12, i64 0, !13, i64 4, !13, i64 8}
!12 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!13 = !{!"int", !7, i64 0}
!14 = !{!11, !13, i64 8}


; 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.36 = external hidden unnamed_addr constant [14 x i32], align 4
@.str.37 = external hidden unnamed_addr constant [15 x i32], align 4
@.str.38 = external hidden unnamed_addr constant [13 x i32], align 4
@.str.39 = external hidden unnamed_addr constant [15 x i32], align 4
@.str.40 = external hidden unnamed_addr constant [13 x i32], align 4
@.str.41 = external hidden unnamed_addr constant [19 x i32], align 4
@.str.42 = external hidden unnamed_addr constant [19 x i32], align 4
@.str.43 = external hidden unnamed_addr constant [18 x i32], align 4

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

; Function Attrs: nounwind uwtable
define dso_local void @DevPathToTextAcpi(ptr noundef %0, ptr nocapture noundef readonly %1, i8 noundef zeroext %2, i8 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = load i32, ptr %5, align 1, !tbaa !5
  %7 = and i32 %6, 65535
  %8 = icmp eq i32 %7, 16848
  br i1 %8, label %9, label %27

9:                                                ; preds = %4
  %10 = lshr i32 %6, 16
  %trunc = trunc nuw i32 %10 to i16
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load i32, ptr %11, align 1, !tbaa !11
  switch i16 %trunc, label %25 [
    i16 2563, label %13
    i16 2568, label %15
    i16 1540, label %17
    i16 769, label %19
    i16 1281, label %21
    i16 1025, label %23
  ]

13:                                               ; preds = %9
  %14 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.36, i32 noundef %12)
  br label %31

15:                                               ; preds = %9
  %16 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.37, i32 noundef %12)
  br label %31

17:                                               ; preds = %9
  %18 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.38, i32 noundef %12)
  br label %31

19:                                               ; preds = %9
  %20 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.39, i32 noundef %12)
  br label %31

21:                                               ; preds = %9
  %22 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.40, i32 noundef %12)
  br label %31

23:                                               ; preds = %9
  %24 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.41, i32 noundef %12)
  br label %31

25:                                               ; preds = %9
  %26 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.42, i32 noundef %10, i32 noundef %12)
  br label %31

27:                                               ; preds = %4
  %28 = getelementptr inbounds i8, ptr %1, i64 8
  %29 = load i32, ptr %28, align 1, !tbaa !11
  %30 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.43, i32 noundef %6, i32 noundef %29)
  br label %31

31:                                               ; preds = %13, %15, %17, %19, %21, %23, %25, %27
  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" }

!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, !10, i64 4}
!6 = !{!"", !7, i64 0, !10, i64 4, !10, i64 8}
!7 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}


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