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

; 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.IPv4_DEVICE_PATH = type <{ %struct.EFI_DEVICE_PATH_PROTOCOL, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, i16, i16, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS }>
%struct.EFI_DEVICE_PATH_PROTOCOL = type { i8, i8, [2 x i8] }
%struct.EFI_IPv4_ADDRESS = type { [4 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.17 = external hidden unnamed_addr constant [17 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 @DevPathSerialIPv4(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [10 x i16], align 16
  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 20, ptr %6) #3
  br label %7

7:                                                ; preds = %2
  %8 = call zeroext i8 @DebugAssertEnabled()
  %9 = icmp ne i8 %8, 0
  br i1 %9, label %10, label %15

10:                                               ; preds = %7
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  call void @DebugAssert(ptr noundef @.str, i64 noundef 796, ptr noundef @.str.14)
  br label %14

14:                                               ; preds = %13, %10
  br label %15

15:                                               ; preds = %14, %7
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  %19 = call zeroext i8 @DebugAssertEnabled()
  %20 = icmp ne i8 %19, 0
  br i1 %20, label %21, label %26

21:                                               ; preds = %18
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  call void @DebugAssert(ptr noundef @.str, i64 noundef 797, ptr noundef @.str.15)
  br label %25

25:                                               ; preds = %24, %21
  br label %26

26:                                               ; preds = %25, %18
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %29, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds [10 x i16], ptr %6, i64 0, i64 0
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds %struct.EFI_IPv4_ADDRESS, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds [4 x i8], ptr %33, i64 0, i64 0
  %35 = load i8, ptr %34, align 1, !tbaa !9
  %36 = zext i8 %35 to i64
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %37, i32 0, i32 1
  %39 = getelementptr inbounds %struct.EFI_IPv4_ADDRESS, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 1
  %41 = load i8, ptr %40, align 1, !tbaa !9
  %42 = zext i8 %41 to i64
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %struct.EFI_IPv4_ADDRESS, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds [4 x i8], ptr %45, i64 0, i64 2
  %47 = load i8, ptr %46, align 1, !tbaa !9
  %48 = zext i8 %47 to i64
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.EFI_IPv4_ADDRESS, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds [4 x i8], ptr %51, i64 0, i64 3
  %53 = load i8, ptr %52, align 1, !tbaa !9
  %54 = zext i8 %53 to i64
  %55 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef %30, i64 noundef 0, ptr noundef @.str.17, i64 noundef %36, i64 noundef %42, i64 noundef %48, i64 noundef %54)
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds [10 x i16], ptr %6, i64 0, i64 0
  %58 = call i64 @AppendCSDStr(ptr noundef %56, ptr noundef %57)
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %60, i32 0, i32 3
  %62 = load i16, ptr %61, align 1, !tbaa !10
  %63 = zext i16 %62 to i64
  %64 = call i64 @AppendCSDNum(ptr noundef %59, i64 noundef %63)
  %65 = getelementptr inbounds [10 x i16], ptr %6, i64 0, i64 0
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %66, i32 0, i32 2
  %68 = getelementptr inbounds %struct.EFI_IPv4_ADDRESS, ptr %67, i32 0, i32 0
  %69 = getelementptr inbounds [4 x i8], ptr %68, i64 0, i64 0
  %70 = load i8, ptr %69, align 1, !tbaa !9
  %71 = zext i8 %70 to i64
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %72, i32 0, i32 2
  %74 = getelementptr inbounds %struct.EFI_IPv4_ADDRESS, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds [4 x i8], ptr %74, i64 0, i64 1
  %76 = load i8, ptr %75, align 1, !tbaa !9
  %77 = zext i8 %76 to i64
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %78, i32 0, i32 2
  %80 = getelementptr inbounds %struct.EFI_IPv4_ADDRESS, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds [4 x i8], ptr %80, i64 0, i64 2
  %82 = load i8, ptr %81, align 1, !tbaa !9
  %83 = zext i8 %82 to i64
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %84, i32 0, i32 2
  %86 = getelementptr inbounds %struct.EFI_IPv4_ADDRESS, ptr %85, i32 0, i32 0
  %87 = getelementptr inbounds [4 x i8], ptr %86, i64 0, i64 3
  %88 = load i8, ptr %87, align 1, !tbaa !9
  %89 = zext i8 %88 to i64
  %90 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef %65, i64 noundef 0, ptr noundef @.str.17, i64 noundef %71, i64 noundef %77, i64 noundef %83, i64 noundef %89)
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds [10 x i16], ptr %6, i64 0, i64 0
  %93 = call i64 @AppendCSDStr(ptr noundef %91, ptr noundef %92)
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %95, i32 0, i32 4
  %97 = load i16, ptr %96, align 1, !tbaa !15
  %98 = zext i16 %97 to i64
  %99 = call i64 @AppendCSDNum(ptr noundef %94, i64 noundef %98)
  call void @llvm.lifetime.end.p0(i64 20, 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 = !{!7, !7, i64 0}
!10 = !{!11, !14, i64 12}
!11 = !{!"", !12, i64 0, !13, i64 4, !13, i64 8, !14, i64 12, !14, i64 14, !14, i64 16, !7, i64 18, !13, i64 19, !13, i64 23}
!12 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!13 = !{!"", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!11, !14, i64 14}


; 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.17 = external hidden unnamed_addr constant [17 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 @DevPathSerialIPv4(ptr noundef readonly %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca [10 x i16], align 16
  call void @llvm.lifetime.start.p0(i64 20, 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 796, 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 797, ptr noundef nonnull @.str.15) #3
  br label %13

13:                                               ; preds = %12, %8
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = zext i8 %15 to i64
  %17 = getelementptr inbounds i8, ptr %0, i64 5
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = zext i8 %18 to i64
  %20 = getelementptr inbounds i8, ptr %0, i64 6
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = zext i8 %21 to i64
  %23 = getelementptr inbounds i8, ptr %0, i64 7
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = zext i8 %24 to i64
  %26 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %3, i64 noundef 0, ptr noundef nonnull @.str.17, i64 noundef %16, i64 noundef %19, i64 noundef %22, i64 noundef %25) #3
  %27 = call i64 @AppendCSDStr(ptr noundef %1, ptr noundef nonnull %3)
  %28 = getelementptr inbounds i8, ptr %0, i64 12
  %29 = load i16, ptr %28, align 1, !tbaa !8
  %30 = zext i16 %29 to i64
  %31 = call i64 @AppendCSDNum(ptr noundef %1, i64 noundef %30)
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = zext i8 %33 to i64
  %35 = getelementptr inbounds i8, ptr %0, i64 9
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = zext i8 %36 to i64
  %38 = getelementptr inbounds i8, ptr %0, i64 10
  %39 = load i8, ptr %38, align 1, !tbaa !5
  %40 = zext i8 %39 to i64
  %41 = getelementptr inbounds i8, ptr %0, i64 11
  %42 = load i8, ptr %41, align 1, !tbaa !5
  %43 = zext i8 %42 to i64
  %44 = call i64 (ptr, i64, ptr, ...) @UnicodeSPrint(ptr noundef nonnull %3, i64 noundef 0, ptr noundef nonnull @.str.17, i64 noundef %34, i64 noundef %37, i64 noundef %40, i64 noundef %43) #3
  %45 = call i64 @AppendCSDStr(ptr noundef %1, ptr noundef nonnull %3)
  %46 = getelementptr inbounds i8, ptr %0, i64 14
  %47 = load i16, ptr %46, align 1, !tbaa !13
  %48 = zext i16 %47 to i64
  %49 = call i64 @AppendCSDNum(ptr noundef %1, i64 noundef %48)
  call void @llvm.lifetime.end.p0(i64 20, 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 12}
!9 = !{!"", !10, i64 0, !11, i64 4, !11, i64 8, !12, i64 12, !12, i64 14, !12, i64 16, !6, i64 18, !11, i64 19, !11, i64 23}
!10 = !{!"", !6, i64 0, !6, i64 1, !6, i64 2}
!11 = !{!"", !6, i64 0}
!12 = !{!"short", !6, i64 0}
!13 = !{!9, !12, i64 14}


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