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

; 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_IPv6_ADDRESS = type { [16 x i8] }
%struct._UDP_IO = type { i32, %struct._LIST_ENTRY, i64, i8, ptr, ptr, ptr, %struct.EFI_SIMPLE_NETWORK_MODE, %struct._LIST_ENTRY, ptr, %union.anon, %union.anon.0 }
%struct.EFI_SIMPLE_NETWORK_MODE = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x %struct.EFI_MAC_ADDRESS], %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, %struct.EFI_MAC_ADDRESS, i8, i8, i8, i8, i8 }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }
%struct._LIST_ENTRY = type { ptr, ptr }
%union.anon = type { ptr }
%union.anon.0 = type { %struct.EFI_UDP6_CONFIG_DATA }
%struct.EFI_UDP6_CONFIG_DATA = type { i8, i8, i8, i8, i8, i32, i32, %struct.EFI_IPv6_ADDRESS, i16, %struct.EFI_IPv6_ADDRESS, i16 }
%struct._MTFTP6_INSTANCE = type { i32, ptr, %struct._LIST_ENTRY, %struct._EFI_MTFTP6_PROTOCOL, ptr, ptr, ptr, %struct.MTFTP6_EXT_OPTION_INFO, i16, i16, %struct._LIST_ENTRY, %struct.EFI_IPv6_ADDRESS, i16, i16, ptr, %struct.EFI_IPv6_ADDRESS, i16, ptr, ptr, i32, i32, i32, i32, i64, i8, i8, i8 }
%struct._EFI_MTFTP6_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.MTFTP6_EXT_OPTION_INFO = type { i16, i8, i32, %struct.EFI_IPv6_ADDRESS, i16, i8, i32 }
%struct._EFI_UDP6_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @Mtftp6RrqConfigMcastUdpIo(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.EFI_IPv6_ADDRESS, align 1
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._UDP_IO, ptr %12, i32 0, i32 10
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  store ptr %14, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._UDP_IO, ptr %15, i32 0, i32 11
  store ptr %16, ptr %8, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %17, ptr %10, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = call ptr @ZeroMem(ptr noundef %18, i64 noundef 52)
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %20, i32 0, i32 0
  store i8 0, ptr %21, align 4, !tbaa !10
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %22, i32 0, i32 1
  store i8 0, ptr %23, align 1, !tbaa !15
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %24, i32 0, i32 2
  store i8 0, ptr %25, align 2, !tbaa !16
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %26, i32 0, i32 3
  store i8 0, ptr %27, align 1, !tbaa !17
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %28, i32 0, i32 4
  store i8 -128, ptr %29, align 4, !tbaa !18
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %30, i32 0, i32 5
  store i32 0, ptr %31, align 4, !tbaa !19
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %32, i32 0, i32 6
  store i32 0, ptr %33, align 4, !tbaa !20
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %34, i32 0, i32 16
  %36 = load i16, ptr %35, align 8, !tbaa !21
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %37, i32 0, i32 8
  store i16 %36, ptr %38, align 4, !tbaa !27
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %39, i32 0, i32 10
  store i16 0, ptr %40, align 2, !tbaa !28
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.EFI_UDP6_CONFIG_DATA, ptr %41, i32 0, i32 9
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %43, i32 0, i32 11
  %45 = call ptr @CopyMem(ptr noundef %42, ptr noundef %44, i64 noundef 16)
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._EFI_UDP6_PROTOCOL, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !29
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = call i64 %48(ptr noundef %49, ptr noundef %50)
  store i64 %51, ptr %6, align 8, !tbaa !31
  %52 = load i64, ptr %6, align 8, !tbaa !31
  %53 = icmp slt i64 %52, 0
  br i1 %53, label %54, label %56

54:                                               ; preds = %2
  %55 = load i64, ptr %6, align 8, !tbaa !31
  store i64 %55, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %65

56:                                               ; preds = %2
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %57, i32 0, i32 15
  %59 = call ptr @CopyMem(ptr noundef %9, ptr noundef %58, i64 noundef 16)
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._EFI_UDP6_PROTOCOL, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %61, align 8, !tbaa !32
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = call i64 %62(ptr noundef %63, i8 noundef zeroext 1, ptr noundef %9)
  store i64 %64, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %65

65:                                               ; preds = %56, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %66 = load i64, ptr %3, align 8
  ret i64 %66
}

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, !7, i64 0}
!11 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !12, i64 8, !12, i64 12, !13, i64 16, !14, i64 32, !13, i64 34, !14, i64 50}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!11, !7, i64 1}
!16 = !{!11, !7, i64 2}
!17 = !{!11, !7, i64 3}
!18 = !{!11, !7, i64 4}
!19 = !{!11, !12, i64 8}
!20 = !{!11, !12, i64 12}
!21 = !{!22, !14, i64 224}
!22 = !{!"_MTFTP6_INSTANCE", !12, i64 0, !6, i64 8, !23, i64 16, !24, i64 32, !6, i64 96, !6, i64 104, !6, i64 112, !25, i64 120, !14, i64 152, !14, i64 154, !23, i64 160, !13, i64 176, !14, i64 192, !14, i64 194, !6, i64 200, !13, i64 208, !14, i64 224, !6, i64 232, !6, i64 240, !12, i64 248, !12, i64 252, !12, i64 256, !12, i64 260, !26, i64 264, !7, i64 272, !7, i64 273, !7, i64 274}
!23 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!24 = !{!"_EFI_MTFTP6_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}
!25 = !{!"", !14, i64 0, !7, i64 2, !12, i64 4, !13, i64 8, !14, i64 24, !7, i64 26, !12, i64 28}
!26 = !{!"long long", !7, i64 0}
!27 = !{!11, !14, i64 32}
!28 = !{!11, !14, i64 50}
!29 = !{!30, !6, i64 8}
!30 = !{!"_EFI_UDP6_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!31 = !{!26, !26, i64 0}
!32 = !{!30, !6, i64 16}


; 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_IPv6_ADDRESS = type { [16 x i8] }

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @Mtftp6RrqConfigMcastUdpIo(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca %struct.EFI_IPv6_ADDRESS, align 1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 744
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 752
  %7 = tail call ptr @ZeroMem(ptr noundef nonnull %6, i64 noundef 52) #3
  %8 = getelementptr inbounds i8, ptr %0, i64 756
  store i32 0, ptr %6, align 4
  store i8 -128, ptr %8, align 4, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %0, i64 760
  store i32 0, ptr %9, align 4, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 764
  store i32 0, ptr %10, align 4, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %1, i64 224
  %12 = load i16, ptr %11, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 784
  store i16 %12, ptr %13, align 4, !tbaa !22
  %14 = getelementptr inbounds i8, ptr %0, i64 802
  store i16 0, ptr %14, align 2, !tbaa !23
  %15 = getelementptr inbounds i8, ptr %0, i64 786
  %16 = getelementptr inbounds i8, ptr %1, i64 176
  %17 = tail call ptr @CopyMem(ptr noundef nonnull %15, ptr noundef nonnull %16, i64 noundef 16) #3
  %18 = getelementptr inbounds i8, ptr %5, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !24
  %20 = tail call i64 %19(ptr noundef %5, ptr noundef nonnull %6) #3
  %21 = icmp slt i64 %20, 0
  br i1 %21, label %28, label %22

22:                                               ; preds = %2
  %23 = getelementptr inbounds i8, ptr %1, i64 208
  %24 = call ptr @CopyMem(ptr noundef nonnull %3, ptr noundef nonnull %23, i64 noundef 16) #3
  %25 = getelementptr inbounds i8, ptr %5, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !26
  %27 = call i64 %26(ptr noundef nonnull %5, i8 noundef zeroext 1, ptr noundef nonnull %3) #3
  br label %28

28:                                               ; preds = %2, %22
  %.0 = phi i64 [ %27, %22 ], [ %20, %2 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  ret i64 %.0
}

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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !6, i64 4}
!9 = !{!"", !6, i64 0, !6, i64 1, !6, i64 2, !6, i64 3, !6, i64 4, !10, i64 8, !10, i64 12, !11, i64 16, !12, i64 32, !11, i64 34, !12, i64 50}
!10 = !{!"int", !6, i64 0}
!11 = !{!"", !6, i64 0}
!12 = !{!"short", !6, i64 0}
!13 = !{!9, !10, i64 8}
!14 = !{!9, !10, i64 12}
!15 = !{!16, !12, i64 224}
!16 = !{!"_MTFTP6_INSTANCE", !10, i64 0, !17, i64 8, !18, i64 16, !19, i64 32, !17, i64 96, !17, i64 104, !17, i64 112, !20, i64 120, !12, i64 152, !12, i64 154, !18, i64 160, !11, i64 176, !12, i64 192, !12, i64 194, !17, i64 200, !11, i64 208, !12, i64 224, !17, i64 232, !17, i64 240, !10, i64 248, !10, i64 252, !10, i64 256, !10, i64 260, !21, i64 264, !6, i64 272, !6, i64 273, !6, i64 274}
!17 = !{!"any pointer", !6, i64 0}
!18 = !{!"_LIST_ENTRY", !17, i64 0, !17, i64 8}
!19 = !{!"_EFI_MTFTP6_PROTOCOL", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !17, i64 48, !17, i64 56}
!20 = !{!"", !12, i64 0, !6, i64 2, !10, i64 4, !11, i64 8, !12, i64 24, !6, i64 26, !10, i64 28}
!21 = !{!"long long", !6, i64 0}
!22 = !{!9, !12, i64 32}
!23 = !{!9, !12, i64 50}
!24 = !{!25, !17, i64 8}
!25 = !{!"_EFI_UDP6_PROTOCOL", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !17, i64 48}
!26 = !{!25, !17, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass