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

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

@.str = external hidden unnamed_addr constant [155 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [5 x i32], align 4

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

declare zeroext i8 @DebugAssertEnabled() #1

declare void @DebugAssert(ptr noundef, i64 noundef, 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 i64 @AppendCSDNum(ptr noundef, i64 noundef) #2

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

declare i64 @UnicodeSPrint(ptr noundef, i64 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @DevPathSerialInfiniBand(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca [64 x i16], align 16
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  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 128, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  br label %9

9:                                                ; preds = %2
  %10 = call zeroext i8 @DebugAssertEnabled()
  %11 = icmp ne i8 %10, 0
  br i1 %11, label %12, label %17

12:                                               ; preds = %9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @DebugAssert(ptr noundef @.str, i64 noundef 766, ptr noundef @.str.14)
  br label %16

16:                                               ; preds = %15, %12
  br label %17

17:                                               ; preds = %16, %9
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19
  %21 = call zeroext i8 @DebugAssertEnabled()
  %22 = icmp ne i8 %21, 0
  br i1 %22, label %23, label %28

23:                                               ; preds = %20
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  call void @DebugAssert(ptr noundef @.str, i64 noundef 767, ptr noundef @.str.15)
  br label %27

27:                                               ; preds = %26, %23
  br label %28

28:                                               ; preds = %27, %20
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %31, ptr %5, align 8, !tbaa !5
  store i64 0, ptr %6, align 8, !tbaa !9
  %32 = getelementptr inbounds [64 x i16], ptr %7, i64 0, i64 0
  store ptr %32, ptr %8, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %45, %30
  %34 = load i64, ptr %6, align 8, !tbaa !9
  %35 = icmp ult i64 %34, 16
  br i1 %35, label %36, label %50

36:                                               ; preds = %33
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.INFINIBAND_DEVICE_PATH, ptr %38, i32 0, i32 2
  %40 = load i64, ptr %6, align 8, !tbaa !9
  %41 = getelementptr inbounds [16 x i8], ptr %39, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !11
  %43 = zext i8 %42 to i64
  %44 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef %37, i64 noundef 0, ptr noundef @.str.16, i64 noundef %43)
  br label %45

45:                                               ; preds = %36
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = add i64 %46, 1
  store i64 %47, ptr %6, align 8, !tbaa !9
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds i16, ptr %48, i64 2
  store ptr %49, ptr %8, align 8, !tbaa !5
  br label %33, !llvm.loop !12

50:                                               ; preds = %33
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds [64 x i16], ptr %7, i64 0, i64 0
  %53 = call i64 @AppendCSDStr(ptr noundef %51, ptr noundef %52)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.INFINIBAND_DEVICE_PATH, ptr %55, i32 0, i32 3
  %57 = load i64, ptr %56, align 1, !tbaa !14
  %58 = call i64 @AppendCSDNum(ptr noundef %54, i64 noundef %57)
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.INFINIBAND_DEVICE_PATH, ptr %60, i32 0, i32 4
  %62 = load i64, ptr %61, align 1, !tbaa !18
  %63 = call i64 @AppendCSDNum(ptr noundef %59, i64 noundef %62)
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.INFINIBAND_DEVICE_PATH, ptr %65, i32 0, i32 5
  %67 = load i64, ptr %66, align 1, !tbaa !19
  %68 = call i64 @AppendCSDNum(ptr noundef %64, i64 noundef %67)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 128, 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
  ret void
}

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 = !{!"long long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !10, i64 24}
!15 = !{!"", !16, i64 0, !17, i64 4, !7, i64 8, !10, i64 24, !10, i64 32, !10, i64 40}
!16 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!17 = !{!"int", !7, i64 0}
!18 = !{!15, !10, i64 32}
!19 = !{!15, !10, i64 40}


; 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 = external hidden unnamed_addr constant [155 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [5 x i32], align 4

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

declare void @DebugAssert(ptr noundef, i64 noundef, 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 i64 @AppendCSDNum(ptr noundef, i64 noundef) local_unnamed_addr #2

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

declare i64 @UnicodeSPrint(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @DevPathSerialInfiniBand(ptr noundef readonly %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca [64 x i16], align 16
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #3
  %4 = tail call zeroext i8 @DebugAssertEnabled() #3
  %5 = icmp eq i8 %4, 0
  %6 = icmp ne ptr %0, null
  %or.cond = or i1 %6, %5
  br i1 %or.cond, label %8, label %7

7:                                                ; preds = %2
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 766, ptr noundef nonnull @.str.14) #3
  br label %8

8:                                                ; preds = %2, %7
  %9 = tail call zeroext i8 @DebugAssertEnabled() #3
  %10 = icmp eq i8 %9, 0
  %11 = icmp ne ptr %1, null
  %or.cond3 = or i1 %11, %10
  br i1 %or.cond3, label %13, label %12

12:                                               ; preds = %8
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 767, ptr noundef nonnull @.str.15) #3
  br label %13

13:                                               ; preds = %12, %8
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = zext i8 %15 to i64
  %17 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %3, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %16) #3
  %18 = getelementptr inbounds i8, ptr %3, i64 4
  %19 = getelementptr inbounds i8, ptr %0, i64 9
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %21 = zext i8 %20 to i64
  %22 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %18, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %21) #3
  %23 = getelementptr inbounds i8, ptr %3, i64 8
  %24 = getelementptr inbounds i8, ptr %0, i64 10
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %26 = zext i8 %25 to i64
  %27 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %23, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %26) #3
  %28 = getelementptr inbounds i8, ptr %3, i64 12
  %29 = getelementptr inbounds i8, ptr %0, i64 11
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = zext i8 %30 to i64
  %32 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %28, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %31) #3
  %33 = getelementptr inbounds i8, ptr %3, i64 16
  %34 = getelementptr inbounds i8, ptr %0, i64 12
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = zext i8 %35 to i64
  %37 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %33, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %36) #3
  %38 = getelementptr inbounds i8, ptr %3, i64 20
  %39 = getelementptr inbounds i8, ptr %0, i64 13
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = zext i8 %40 to i64
  %42 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %38, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %41) #3
  %43 = getelementptr inbounds i8, ptr %3, i64 24
  %44 = getelementptr inbounds i8, ptr %0, i64 14
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %46 = zext i8 %45 to i64
  %47 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %43, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %46) #3
  %48 = getelementptr inbounds i8, ptr %3, i64 28
  %49 = getelementptr inbounds i8, ptr %0, i64 15
  %50 = load i8, ptr %49, align 1, !tbaa !5
  %51 = zext i8 %50 to i64
  %52 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %48, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %51) #3
  %53 = getelementptr inbounds i8, ptr %3, i64 32
  %54 = getelementptr inbounds i8, ptr %0, i64 16
  %55 = load i8, ptr %54, align 1, !tbaa !5
  %56 = zext i8 %55 to i64
  %57 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %53, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %56) #3
  %58 = getelementptr inbounds i8, ptr %3, i64 36
  %59 = getelementptr inbounds i8, ptr %0, i64 17
  %60 = load i8, ptr %59, align 1, !tbaa !5
  %61 = zext i8 %60 to i64
  %62 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %58, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %61) #3
  %63 = getelementptr inbounds i8, ptr %3, i64 40
  %64 = getelementptr inbounds i8, ptr %0, i64 18
  %65 = load i8, ptr %64, align 1, !tbaa !5
  %66 = zext i8 %65 to i64
  %67 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %63, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %66) #3
  %68 = getelementptr inbounds i8, ptr %3, i64 44
  %69 = getelementptr inbounds i8, ptr %0, i64 19
  %70 = load i8, ptr %69, align 1, !tbaa !5
  %71 = zext i8 %70 to i64
  %72 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %68, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %71) #3
  %73 = getelementptr inbounds i8, ptr %3, i64 48
  %74 = getelementptr inbounds i8, ptr %0, i64 20
  %75 = load i8, ptr %74, align 1, !tbaa !5
  %76 = zext i8 %75 to i64
  %77 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %73, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %76) #3
  %78 = getelementptr inbounds i8, ptr %3, i64 52
  %79 = getelementptr inbounds i8, ptr %0, i64 21
  %80 = load i8, ptr %79, align 1, !tbaa !5
  %81 = zext i8 %80 to i64
  %82 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %78, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %81) #3
  %83 = getelementptr inbounds i8, ptr %3, i64 56
  %84 = getelementptr inbounds i8, ptr %0, i64 22
  %85 = load i8, ptr %84, align 1, !tbaa !5
  %86 = zext i8 %85 to i64
  %87 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %83, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %86) #3
  %88 = getelementptr inbounds i8, ptr %3, i64 60
  %89 = getelementptr inbounds i8, ptr %0, i64 23
  %90 = load i8, ptr %89, align 1, !tbaa !5
  %91 = zext i8 %90 to i64
  %92 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %88, i64 noundef 0, ptr noundef nonnull @.str.16, i64 noundef %91) #3
  %93 = call i64 @AppendCSDStr(ptr noundef %1, ptr noundef nonnull %3)
  %94 = getelementptr inbounds i8, ptr %0, i64 24
  %95 = load i64, ptr %94, align 1, !tbaa !8
  %96 = call i64 @AppendCSDNum(ptr noundef %1, i64 noundef %95)
  %97 = getelementptr inbounds i8, ptr %0, i64 32
  %98 = load i64, ptr %97, align 1, !tbaa !13
  %99 = call i64 @AppendCSDNum(ptr noundef %1, i64 noundef %98)
  %100 = getelementptr inbounds i8, ptr %0, i64 40
  %101 = load i64, ptr %100, align 1, !tbaa !14
  %102 = call i64 @AppendCSDNum(ptr noundef %1, i64 noundef %101)
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #3
  ret void
}

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


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