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

; 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._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.EFI_IPv6_ADDRESS = type { [16 x i8] }
%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

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

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

59:                                               ; preds = %5
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = call i64 @Mtftp6GetMapping(ptr noundef %60, ptr noundef %61)
  store i64 %62, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %65

63:                                               ; preds = %5
  %64 = load i64, ptr %12, align 8, !tbaa !26
  store i64 %64, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %65

65:                                               ; preds = %63, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %66 = load i64, ptr %6, align 8
  ret i64 %66
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"short", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !14, i64 8, !14, i64 12, !15, i64 16, !10, i64 32, !15, i64 34, !10, i64 50}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !7, i64 0}
!16 = !{!13, !7, i64 1}
!17 = !{!13, !7, i64 2}
!18 = !{!13, !7, i64 3}
!19 = !{!13, !7, i64 4}
!20 = !{!13, !14, i64 8}
!21 = !{!13, !14, i64 12}
!22 = !{!13, !10, i64 32}
!23 = !{!13, !10, i64 50}
!24 = !{!25, !6, i64 8}
!25 = !{!"_EFI_UDP6_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!26 = !{!27, !27, i64 0}
!27 = !{!"long long", !7, 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"

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

; Function Attrs: nounwind uwtable
define dso_local i64 @Mtftp6ConfigUdpIo(ptr noundef %0, ptr noundef %1, i16 noundef zeroext %2, ptr noundef %3, i16 noundef zeroext %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 744
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 752
  %9 = tail call ptr @ZeroMem(ptr noundef nonnull %8, i64 noundef 52) #2
  %10 = getelementptr inbounds i8, ptr %0, i64 756
  store i32 0, ptr %8, align 4
  store i8 -128, ptr %10, align 4, !tbaa !8
  %11 = getelementptr inbounds i8, ptr %0, i64 760
  store i32 0, ptr %11, align 4, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %0, i64 764
  store i32 0, ptr %12, align 4, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %0, i64 784
  store i16 %4, ptr %13, align 4, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 802
  store i16 %2, ptr %14, align 2, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %0, i64 768
  %16 = tail call ptr @CopyMem(ptr noundef nonnull %15, ptr noundef %3, i64 noundef 16) #2
  %17 = getelementptr inbounds i8, ptr %0, i64 786
  %18 = tail call ptr @CopyMem(ptr noundef nonnull %17, ptr noundef %1, i64 noundef 16) #2
  %19 = getelementptr inbounds i8, ptr %7, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = tail call i64 %20(ptr noundef %7, ptr noundef nonnull %8) #2
  %22 = icmp eq i64 %21, -9223372036854775791
  br i1 %22, label %23, label %25

23:                                               ; preds = %5
  %24 = tail call i64 @Mtftp6GetMapping(ptr noundef nonnull %0, ptr noundef nonnull %8)
  br label %25

25:                                               ; preds = %5, %23
  %.0 = phi i64 [ %24, %23 ], [ %21, %5 ]
  ret i64 %.0
}

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

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

attributes #0 = { 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 #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 }

!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 = !{!9, !12, i64 32}
!16 = !{!9, !12, i64 50}
!17 = !{!18, !19, i64 8}
!18 = !{!"_EFI_UDP6_PROTOCOL", !19, i64 0, !19, i64 8, !19, i64 16, !19, i64 24, !19, i64 32, !19, i64 40, !19, i64 48}
!19 = !{!"any pointer", !6, i64 0}


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