; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe_ (PxeBcConfigUdp4Write)

; 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.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct.EFI_UDP4_CONFIG_DATA = type { i8, i8, i8, i8, i8, i8, i8, i32, i32, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, %struct.EFI_IPv4_ADDRESS, i16 }
%struct._EFI_UDP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@mZeroIp4Addr = external global %struct.EFI_IPv4_ADDRESS, align 1

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

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

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

declare i64 @CompareMem(ptr noundef, ptr noundef, i64 noundef) #1

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

44:                                               ; preds = %6
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = call i64 @CompareMem(ptr noundef %45, ptr noundef @mZeroIp4Addr, i64 noundef 4)
  %47 = icmp eq i64 %46, 0
  br i1 %47, label %64, label %48

48:                                               ; preds = %44
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._EFI_UDP4_PROTOCOL, ptr %49, i32 0, i32 3
  %51 = load ptr, ptr %50, align 8, !tbaa !26
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = call i64 %51(ptr noundef %52, i8 noundef zeroext 0, ptr noundef @mZeroIp4Addr, ptr noundef @mZeroIp4Addr, ptr noundef %53)
  store i64 %54, ptr %14, align 8, !tbaa !24
  %55 = load i64, ptr %14, align 8, !tbaa !24
  %56 = icmp slt i64 %55, 0
  br i1 %56, label %57, label %63

57:                                               ; preds = %48
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._EFI_UDP4_PROTOCOL, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !22
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = call i64 %60(ptr noundef %61, ptr noundef null)
  br label %63

63:                                               ; preds = %57, %48
  br label %64

64:                                               ; preds = %63, %44, %6
  %65 = load i64, ptr %14, align 8, !tbaa !24
  %66 = icmp slt i64 %65, 0
  br i1 %66, label %81, label %67

67:                                               ; preds = %64
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = load i16, ptr %68, align 2, !tbaa !20
  %70 = zext i16 %69 to i32
  %71 = icmp eq i32 %70, 0
  br i1 %71, label %72, label %81

72:                                               ; preds = %67
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._EFI_UDP4_PROTOCOL, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !27
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = call i64 %75(ptr noundef %76, ptr noundef %13, ptr noundef null, ptr noundef null, ptr noundef null)
  %78 = getelementptr inbounds %struct.EFI_UDP4_CONFIG_DATA, ptr %13, i32 0, i32 12
  %79 = load i16, ptr %78, align 2, !tbaa !21
  %80 = load ptr, ptr %11, align 8, !tbaa !5
  store i16 %79, ptr %80, align 2, !tbaa !20
  br label %81

81:                                               ; preds = %72, %67, %64
  %82 = load i64, ptr %14, align 8, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 36, ptr %13) #3
  ret i64 %82
}

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

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, !12, i64 12}
!11 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !12, i64 8, !12, i64 12, !7, i64 16, !13, i64 17, !13, i64 21, !14, i64 26, !13, i64 28, !14, i64 32}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!11, !12, i64 8}
!16 = !{!11, !7, i64 4}
!17 = !{!11, !7, i64 5}
!18 = !{!11, !7, i64 3}
!19 = !{!11, !7, i64 6}
!20 = !{!14, !14, i64 0}
!21 = !{!11, !14, i64 26}
!22 = !{!23, !6, i64 8}
!23 = !{!"_EFI_UDP4_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!24 = !{!25, !25, i64 0}
!25 = !{!"long long", !7, i64 0}
!26 = !{!23, !6, i64 24}
!27 = !{!23, !6, 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"

%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct.EFI_UDP4_CONFIG_DATA = type { i8, i8, i8, i8, i8, i8, i8, i32, i32, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, %struct.EFI_IPv4_ADDRESS, i16 }

@mZeroIp4Addr = external global %struct.EFI_IPv4_ADDRESS, align 1

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

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 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

declare i64 @CompareMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @PxeBcConfigUdp4Write(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef %4, i8 noundef zeroext %5) local_unnamed_addr #2 {
  %7 = alloca %struct.EFI_UDP4_CONFIG_DATA, align 4
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %7) #3
  %8 = call ptr @ZeroMem(ptr noundef nonnull %7, i64 noundef 36) #3
  %9 = getelementptr inbounds i8, ptr %7, i64 12
  store i32 50000, ptr %9, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 50000, ptr %10, align 4, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %7, i64 4
  store i8 0, ptr %11, align 4, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %7, i64 5
  store i8 16, ptr %12, align 1, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %7, i64 3
  store i8 1, ptr %13, align 1, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %7, i64 6
  store i8 %5, ptr %14, align 2, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %7, i64 17
  %16 = call ptr @CopyMem(ptr noundef nonnull %15, ptr noundef %1, i64 noundef 4) #3
  %17 = getelementptr inbounds i8, ptr %7, i64 21
  %18 = call ptr @CopyMem(ptr noundef nonnull %17, ptr noundef %2, i64 noundef 4) #3
  %19 = load i16, ptr %4, align 2, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %7, i64 26
  store i16 %19, ptr %20, align 2, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = call i64 %22(ptr noundef %0, ptr noundef null) #3
  %24 = load ptr, ptr %21, align 8, !tbaa !19
  %25 = call i64 %24(ptr noundef %0, ptr noundef nonnull %7) #3
  %26 = icmp slt i64 %25, 0
  br i1 %26, label %.thread, label %27

27:                                               ; preds = %6
  %28 = call i64 @CompareMem(ptr noundef %3, ptr noundef nonnull @mZeroIp4Addr, i64 noundef 4) #3
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %38, label %30

30:                                               ; preds = %27
  %31 = getelementptr inbounds i8, ptr %0, i64 24
  %32 = load ptr, ptr %31, align 8, !tbaa !22
  %33 = call i64 %32(ptr noundef nonnull %0, i8 noundef zeroext 0, ptr noundef nonnull @mZeroIp4Addr, ptr noundef nonnull @mZeroIp4Addr, ptr noundef %3) #3
  %34 = icmp slt i64 %33, 0
  br i1 %34, label %35, label %38

35:                                               ; preds = %30
  %36 = load ptr, ptr %21, align 8, !tbaa !19
  %37 = call i64 %36(ptr noundef nonnull %0, ptr noundef null) #3
  br label %.thread

38:                                               ; preds = %27, %30
  %.0 = phi i64 [ %25, %27 ], [ %33, %30 ]
  %39 = load i16, ptr %4, align 2, !tbaa !17
  %40 = icmp eq i16 %39, 0
  br i1 %40, label %41, label %.thread

41:                                               ; preds = %38
  %42 = load ptr, ptr %0, align 8, !tbaa !23
  %43 = call i64 %42(ptr noundef nonnull %0, ptr noundef nonnull %7, ptr noundef null, ptr noundef null, ptr noundef null) #3
  %44 = load i16, ptr %20, align 2, !tbaa !18
  store i16 %44, ptr %4, align 2, !tbaa !17
  br label %.thread

.thread:                                          ; preds = %35, %6, %41, %38
  %.025 = phi i64 [ %.0, %41 ], [ %.0, %38 ], [ %33, %35 ], [ %25, %6 ]
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %7) #3
  ret i64 %.025
}

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

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, !9, i64 12}
!6 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !9, i64 8, !9, i64 12, !7, i64 16, !10, i64 17, !10, i64 21, !11, i64 26, !10, i64 28, !11, i64 32}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"", !7, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = !{!6, !9, i64 8}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !7, i64 5}
!15 = !{!6, !7, i64 3}
!16 = !{!6, !7, i64 6}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !11, i64 26}
!19 = !{!20, !21, i64 8}
!20 = !{!"_EFI_UDP4_PROTOCOL", !21, i64 0, !21, i64 8, !21, i64 16, !21, i64 24, !21, i64 32, !21, i64 40, !21, i64 48, !21, i64 56}
!21 = !{!"any pointer", !7, i64 0}
!22 = !{!20, !21, i64 24}
!23 = !{!20, !21, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass