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

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

@.str.33 = external hidden unnamed_addr constant [5 x i32], align 4
@.str.34 = external hidden unnamed_addr constant [2 x i32], align 4
@.str.62 = external hidden unnamed_addr constant [11 x i32], align 4
@.str.63 = external hidden unnamed_addr constant [4 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 @DevPathToTextFibreEx(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
  %10 = alloca i64, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %11, ptr %9, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %12, ptr noundef @.str.62)
  store i64 0, ptr %10, align 8, !tbaa !10
  br label %14

14:                                               ; preds = %26, %4
  %15 = load i64, ptr %10, align 8, !tbaa !10
  %16 = icmp ult i64 %15, 8
  br i1 %16, label %17, label %29

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.FIBRECHANNELEX_DEVICE_PATH, ptr %19, i32 0, i32 2
  %21 = load i64, ptr %10, align 8, !tbaa !10
  %22 = getelementptr inbounds [8 x i8], ptr %20, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %18, ptr noundef @.str.33, i32 noundef %24)
  br label %26

26:                                               ; preds = %17
  %27 = load i64, ptr %10, align 8, !tbaa !10
  %28 = add i64 %27, 1
  store i64 %28, ptr %10, align 8, !tbaa !10
  br label %14, !llvm.loop !12

29:                                               ; preds = %14
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %30, ptr noundef @.str.63)
  store i64 0, ptr %10, align 8, !tbaa !10
  br label %32

32:                                               ; preds = %44, %29
  %33 = load i64, ptr %10, align 8, !tbaa !10
  %34 = icmp ult i64 %33, 8
  br i1 %34, label %35, label %47

35:                                               ; preds = %32
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.FIBRECHANNELEX_DEVICE_PATH, ptr %37, i32 0, i32 3
  %39 = load i64, ptr %10, align 8, !tbaa !10
  %40 = getelementptr inbounds [8 x i8], ptr %38, i64 0, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !9
  %42 = zext i8 %41 to i32
  %43 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %36, ptr noundef @.str.33, i32 noundef %42)
  br label %44

44:                                               ; preds = %35
  %45 = load i64, ptr %10, align 8, !tbaa !10
  %46 = add i64 %45, 1
  store i64 %46, ptr %10, align 8, !tbaa !10
  br label %32, !llvm.loop !14

47:                                               ; preds = %32
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %48, ptr noundef @.str.34)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  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, !11, i64 0}
!11 = !{!"long long", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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.33 = external hidden unnamed_addr constant [5 x i32], align 4
@.str.34 = external hidden unnamed_addr constant [2 x i32], align 4
@.str.62 = external hidden unnamed_addr constant [11 x i32], align 4
@.str.63 = external hidden unnamed_addr constant [4 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 @DevPathToTextFibreEx(ptr noundef %0, ptr nocapture noundef readonly %1, i8 noundef zeroext %2, i8 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.62)
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = zext i8 %7 to i32
  %9 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %8)
  %10 = getelementptr inbounds i8, ptr %1, i64 9
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = zext i8 %11 to i32
  %13 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %12)
  %14 = getelementptr inbounds i8, ptr %1, i64 10
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = zext i8 %15 to i32
  %17 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %16)
  %18 = getelementptr inbounds i8, ptr %1, i64 11
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = zext i8 %19 to i32
  %21 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %20)
  %22 = getelementptr inbounds i8, ptr %1, i64 12
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = zext i8 %23 to i32
  %25 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %24)
  %26 = getelementptr inbounds i8, ptr %1, i64 13
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = zext i8 %27 to i32
  %29 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %28)
  %30 = getelementptr inbounds i8, ptr %1, i64 14
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %32 = zext i8 %31 to i32
  %33 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %32)
  %34 = getelementptr inbounds i8, ptr %1, i64 15
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = zext i8 %35 to i32
  %37 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %36)
  %38 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.63)
  %39 = getelementptr inbounds i8, ptr %1, i64 16
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = zext i8 %40 to i32
  %42 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %41)
  %43 = getelementptr inbounds i8, ptr %1, i64 17
  %44 = load i8, ptr %43, align 1, !tbaa !5
  %45 = zext i8 %44 to i32
  %46 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %45)
  %47 = getelementptr inbounds i8, ptr %1, i64 18
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = zext i8 %48 to i32
  %50 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %49)
  %51 = getelementptr inbounds i8, ptr %1, i64 19
  %52 = load i8, ptr %51, align 1, !tbaa !5
  %53 = zext i8 %52 to i32
  %54 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %53)
  %55 = getelementptr inbounds i8, ptr %1, i64 20
  %56 = load i8, ptr %55, align 1, !tbaa !5
  %57 = zext i8 %56 to i32
  %58 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %57)
  %59 = getelementptr inbounds i8, ptr %1, i64 21
  %60 = load i8, ptr %59, align 1, !tbaa !5
  %61 = zext i8 %60 to i32
  %62 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %61)
  %63 = getelementptr inbounds i8, ptr %1, i64 22
  %64 = load i8, ptr %63, align 1, !tbaa !5
  %65 = zext i8 %64 to i32
  %66 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %65)
  %67 = getelementptr inbounds i8, ptr %1, i64 23
  %68 = load i8, ptr %67, align 1, !tbaa !5
  %69 = zext i8 %68 to i32
  %70 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.33, i32 noundef %69)
  %71 = tail call ptr (ptr, ptr, ...) @UefiDevicePathLibCatPrint(ptr noundef %0, ptr noundef nonnull @.str.34)
  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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass