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

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

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

declare i64 @StrLen(ptr noundef) #1

; 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
declare dso_local ptr @GetNextParamStr(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @StrToAscii(ptr noundef, ptr noundef) #2

declare ptr @CreateDeviceNode(i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @EisaIdFromText(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @DevPathFromTextAcpiExp(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  %8 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %9, ptr %3, align 8, !tbaa !5
  %10 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %10, ptr %4, align 8, !tbaa !5
  %11 = call ptr @GetNextParamStr(ptr noundef %2)
  store ptr %11, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call i64 @StrLen(ptr noundef %12)
  %14 = add i64 16, %13
  %15 = add i64 %14, 3
  %16 = trunc i64 %15 to i16
  store i16 %16, ptr %7, align 2, !tbaa !9
  %17 = load i16, ptr %7, align 2, !tbaa !9
  %18 = call ptr @CreateDeviceNode(i8 noundef zeroext 2, i8 noundef zeroext 2, i16 noundef zeroext %17)
  store ptr %18, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i32 @EisaIdFromText(ptr noundef %19)
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ACPI_EXTENDED_HID_DEVICE_PATH, ptr %21, i32 0, i32 1
  store i32 %20, ptr %22, align 1, !tbaa !11
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call i32 @EisaIdFromText(ptr noundef %23)
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ACPI_EXTENDED_HID_DEVICE_PATH, ptr %25, i32 0, i32 3
  store i32 %24, ptr %26, align 1, !tbaa !15
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ACPI_EXTENDED_HID_DEVICE_PATH, ptr %27, i32 0, i32 2
  store i32 0, ptr %28, align 1, !tbaa !16
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  store ptr %30, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 0, ptr %31, align 1, !tbaa !17
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i32 1
  store ptr %33, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  call void @StrToAscii(ptr noundef %34, ptr noundef %6)
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 0, ptr %35, align 1, !tbaa !17
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %36
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !14, i64 4}
!12 = !{!"", !13, i64 0, !14, i64 4, !14, i64 8, !14, i64 12}
!13 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !14, i64 12}
!16 = !{!12, !14, i64 8}
!17 = !{!7, !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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i64 @StrLen(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @GetNextParamStr(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @StrToAscii(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @CreateDeviceNode(i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @EisaIdFromText(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @DevPathFromTextAcpiExp(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  %5 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  %6 = call ptr @GetNextParamStr(ptr noundef nonnull %2)
  %7 = call i64 @StrLen(ptr noundef %6) #3
  %8 = trunc i64 %7 to i16
  %9 = add i16 %8, 19
  %10 = call ptr @CreateDeviceNode(i8 noundef zeroext 2, i8 noundef zeroext 2, i16 noundef zeroext %9) #3
  %11 = call i32 @EisaIdFromText(ptr noundef %4)
  %12 = getelementptr inbounds i8, ptr %10, i64 4
  store i32 %11, ptr %12, align 1, !tbaa !9
  %13 = call i32 @EisaIdFromText(ptr noundef %5)
  %14 = getelementptr inbounds i8, ptr %10, i64 12
  store i32 %13, ptr %14, align 1, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %10, i64 8
  store i32 0, ptr %15, align 1, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %10, i64 16
  store i8 0, ptr %16, align 1, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %10, i64 17
  store ptr %17, ptr %3, align 8, !tbaa !5
  call void @StrToAscii(ptr noundef %6, ptr noundef nonnull %3)
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  store i8 0, ptr %18, align 1, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret ptr %10
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !12, i64 4}
!10 = !{!"", !11, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!11 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 12}
!14 = !{!10, !12, i64 8}
!15 = !{!7, !7, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass