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

; 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] }

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) #0

declare ptr @ZeroMem(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @NetLibDefaultAddressIsStatic(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @NetLibCreateIPv4DPathNode(ptr noundef %0, ptr noundef %1, i32 noundef %2, i16 noundef zeroext %3, i32 noundef %4, i16 noundef zeroext %5, i16 noundef zeroext %6, i8 noundef zeroext %7) #1 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i16, align 2
  %13 = alloca i32, align 4
  %14 = alloca i16, align 2
  %15 = alloca i16, align 2
  %16 = alloca i8, align 1
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i16 %3, ptr %12, align 2, !tbaa !11
  store i32 %4, ptr %13, align 4, !tbaa !9
  store i16 %5, ptr %14, align 2, !tbaa !11
  store i16 %6, ptr %15, align 2, !tbaa !11
  store i8 %7, ptr %16, align 1, !tbaa !13
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.EFI_DEVICE_PATH_PROTOCOL, ptr %18, i32 0, i32 0
  store i8 3, ptr %19, align 1, !tbaa !14
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %struct.EFI_DEVICE_PATH_PROTOCOL, ptr %21, i32 0, i32 1
  store i8 12, ptr %22, align 1, !tbaa !18
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %23, i32 0, i32 0
  %25 = call zeroext i16 @SetDevicePathNodeLength(ptr noundef %24, i64 noundef 27)
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %26, i32 0, i32 1
  %28 = call ptr @CopyMem(ptr noundef %27, ptr noundef %11, i64 noundef 4)
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %29, i32 0, i32 2
  %31 = call ptr @CopyMem(ptr noundef %30, ptr noundef %13, i64 noundef 4)
  %32 = load i16, ptr %12, align 2, !tbaa !11
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %33, i32 0, i32 3
  store i16 %32, ptr %34, align 1, !tbaa !19
  %35 = load i16, ptr %14, align 2, !tbaa !11
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %36, i32 0, i32 4
  store i16 %35, ptr %37, align 1, !tbaa !20
  %38 = load i16, ptr %15, align 2, !tbaa !11
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %39, i32 0, i32 5
  store i16 %38, ptr %40, align 1, !tbaa !21
  %41 = load i8, ptr %16, align 1, !tbaa !13
  %42 = icmp ne i8 %41, 0
  br i1 %42, label %46, label %43

43:                                               ; preds = %8
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %44, i32 0, i32 6
  store i8 1, ptr %45, align 1, !tbaa !22
  br label %51

46:                                               ; preds = %8
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = call zeroext i8 @NetLibDefaultAddressIsStatic(ptr noundef %47)
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %49, i32 0, i32 6
  store i8 %48, ptr %50, align 1, !tbaa !22
  br label %51

51:                                               ; preds = %46, %43
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %52, i32 0, i32 7
  %54 = call ptr @ZeroMem(ptr noundef %53, i64 noundef 4)
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %55, i32 0, i32 8
  %57 = call ptr @SetMem(ptr noundef %56, i64 noundef 4, i8 noundef zeroext -1)
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.IPv4_DEVICE_PATH, ptr %58, i32 0, i32 8
  %60 = getelementptr inbounds %struct.EFI_IPv4_ADDRESS, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds [4 x i8], ptr %60, i64 0, i64 3
  store i8 0, ptr %61, align 1, !tbaa !13
  ret void
}

declare zeroext i16 @SetDevicePathNodeLength(ptr noundef, i64 noundef) #0

declare ptr @SetMem(ptr noundef, i64 noundef, i8 noundef zeroext) #0

attributes #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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"", !16, i64 0, !17, i64 4, !17, i64 8, !12, i64 12, !12, i64 14, !12, i64 16, !7, i64 18, !17, i64 19, !17, i64 23}
!16 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!17 = !{!"", !7, i64 0}
!18 = !{!15, !7, i64 1}
!19 = !{!15, !12, i64 12}
!20 = !{!15, !12, i64 14}
!21 = !{!15, !12, i64 16}
!22 = !{!15, !7, i64 18}


; 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"

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

declare ptr @ZeroMem(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @NetLibDefaultAddressIsStatic(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @NetLibCreateIPv4DPathNode(ptr noundef %0, ptr noundef %1, i32 noundef %2, i16 noundef zeroext %3, i32 noundef %4, i16 noundef zeroext %5, i16 noundef zeroext %6, i8 noundef zeroext %7) local_unnamed_addr #1 {
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 %2, ptr %9, align 4, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !5
  store i8 3, ptr %0, align 1, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 12, ptr %11, align 1, !tbaa !14
  %12 = tail call zeroext i16 @SetDevicePathNodeLength(ptr noundef nonnull %0, i64 noundef 27) #2
  %13 = getelementptr inbounds i8, ptr %0, i64 4
  %14 = call ptr @CopyMem(ptr noundef nonnull %13, ptr noundef nonnull %9, i64 noundef 4) #2
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = call ptr @CopyMem(ptr noundef nonnull %15, ptr noundef nonnull %10, i64 noundef 4) #2
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  store i16 %3, ptr %17, align 1, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %0, i64 14
  store i16 %5, ptr %18, align 1, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  store i16 %6, ptr %19, align 1, !tbaa !17
  %.not = icmp eq i8 %7, 0
  br i1 %.not, label %22, label %20

20:                                               ; preds = %8
  %21 = call zeroext i8 @NetLibDefaultAddressIsStatic(ptr noundef %1)
  br label %22

22:                                               ; preds = %8, %20
  %.sink = phi i8 [ %21, %20 ], [ 1, %8 ]
  %23 = getelementptr inbounds i8, ptr %0, i64 18
  store i8 %.sink, ptr %23, align 1
  %24 = getelementptr inbounds i8, ptr %0, i64 19
  %25 = call ptr @ZeroMem(ptr noundef nonnull %24, i64 noundef 4) #2
  %26 = getelementptr inbounds i8, ptr %0, i64 23
  %27 = call ptr @SetMem(ptr noundef nonnull %26, i64 noundef 4, i8 noundef zeroext -1) #2
  %28 = getelementptr inbounds i8, ptr %0, i64 26
  store i8 0, ptr %28, align 1, !tbaa !18
  ret void
}

declare zeroext i16 @SetDevicePathNodeLength(ptr noundef, i64 noundef) local_unnamed_addr #0

declare ptr @SetMem(ptr noundef, i64 noundef, i8 noundef zeroext) local_unnamed_addr #0

attributes #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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 0}
!10 = !{!"", !11, i64 0, !12, i64 4, !12, i64 8, !13, i64 12, !13, i64 14, !13, i64 16, !7, i64 18, !12, i64 19, !12, i64 23}
!11 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!12 = !{!"", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !7, i64 1}
!15 = !{!10, !13, i64 12}
!16 = !{!10, !13, i64 14}
!17 = !{!10, !13, i64 16}
!18 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,SROAPass,TailCallElimPass