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

; 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_MTFTP6_TOKEN = type { i64, ptr, ptr, ptr, ptr, i32, ptr, i64, ptr, ptr, ptr, ptr, ptr }
%struct._MTFTP6_GETINFO_CONTEXT = type { ptr, ptr, i64 }
%struct.EFI_MTFTP6_OVERRIDE_DATA = type { %struct.EFI_IPv6_ADDRESS, i16, i16, i16 }
%struct.EFI_IPv6_ADDRESS = type { [16 x i8] }

; Function Attrs: nounwind uwtable
define dso_local i64 @EfiMtftp6GetInfo(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i8 noundef zeroext %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #0 {
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i8, align 1
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca %struct._EFI_MTFTP6_TOKEN, align 8
  %20 = alloca %struct._MTFTP6_GETINFO_CONTEXT, align 8
  %21 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store i8 %4, ptr %14, align 1, !tbaa !9
  store ptr %5, ptr %15, align 8, !tbaa !5
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 104, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %20) #3
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %45, label %24

24:                                               ; preds = %8
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  %26 = icmp eq ptr %25, null
  br i1 %26, label %45, label %27

27:                                               ; preds = %24
  %28 = load ptr, ptr %16, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %45, label %30

30:                                               ; preds = %27
  %31 = load i8, ptr %14, align 1, !tbaa !9
  %32 = zext i8 %31 to i32
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %30
  %35 = load ptr, ptr %15, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %45, label %37

37:                                               ; preds = %34, %30
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %46

40:                                               ; preds = %37
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.EFI_MTFTP6_OVERRIDE_DATA, ptr %41, i32 0, i32 0
  %43 = call zeroext i8 @NetIp6IsValidUnicast(ptr noundef %42)
  %44 = icmp ne i8 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %40, %34, %27, %24, %8
  store i64 -9223372036854775806, ptr %9, align 8
  store i32 1, ptr %21, align 4
  br label %86

46:                                               ; preds = %40, %37
  %47 = load ptr, ptr %17, align 8, !tbaa !5
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %51

49:                                               ; preds = %46
  %50 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr null, ptr %50, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %49, %46
  %52 = load ptr, ptr %16, align 8, !tbaa !5
  store i32 0, ptr %52, align 4, !tbaa !10
  %53 = load ptr, ptr %17, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._MTFTP6_GETINFO_CONTEXT, ptr %20, i32 0, i32 0
  store ptr %53, ptr %54, align 8, !tbaa !12
  %55 = load ptr, ptr %16, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._MTFTP6_GETINFO_CONTEXT, ptr %20, i32 0, i32 1
  store ptr %55, ptr %56, align 8, !tbaa !15
  %57 = getelementptr inbounds %struct._MTFTP6_GETINFO_CONTEXT, ptr %20, i32 0, i32 2
  store i64 0, ptr %57, align 8, !tbaa !16
  %58 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 0
  store i64 0, ptr %58, align 8, !tbaa !17
  %59 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 1
  store ptr null, ptr %59, align 8, !tbaa !19
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 2
  store ptr %60, ptr %61, align 8, !tbaa !20
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 3
  store ptr %62, ptr %63, align 8, !tbaa !21
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 4
  store ptr %64, ptr %65, align 8, !tbaa !22
  %66 = load i8, ptr %14, align 1, !tbaa !9
  %67 = zext i8 %66 to i32
  %68 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 5
  store i32 %67, ptr %68, align 8, !tbaa !23
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 6
  store ptr %69, ptr %70, align 8, !tbaa !24
  %71 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 7
  store i64 0, ptr %71, align 8, !tbaa !25
  %72 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 8
  store ptr null, ptr %72, align 8, !tbaa !26
  %73 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 9
  store ptr %20, ptr %73, align 8, !tbaa !27
  %74 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 10
  store ptr @Mtftp6CheckPacket, ptr %74, align 8, !tbaa !28
  %75 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 11
  store ptr null, ptr %75, align 8, !tbaa !29
  %76 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %19, i32 0, i32 12
  store ptr null, ptr %76, align 8, !tbaa !30
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  %78 = call i64 @Mtftp6OperationStart(ptr noundef %77, ptr noundef %19, i16 noundef zeroext 1)
  store i64 %78, ptr %18, align 8, !tbaa !31
  %79 = load i64, ptr %18, align 8, !tbaa !31
  %80 = icmp eq i64 %79, -9223372036854775787
  br i1 %80, label %81, label %84

81:                                               ; preds = %51
  %82 = getelementptr inbounds %struct._MTFTP6_GETINFO_CONTEXT, ptr %20, i32 0, i32 2
  %83 = load i64, ptr %82, align 8, !tbaa !16
  store i64 %83, ptr %9, align 8
  store i32 1, ptr %21, align 4
  br label %86

84:                                               ; preds = %51
  %85 = load i64, ptr %18, align 8, !tbaa !31
  store i64 %85, ptr %9, align 8
  store i32 1, ptr %21, align 4
  br label %86

86:                                               ; preds = %84, %81, %45
  call void @llvm.lifetime.end.p0(i64 24, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 104, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  %87 = load i64, ptr %9, align 8
  ret i64 %87
}

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

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

declare zeroext i8 @NetIp6IsValidUnicast(ptr noundef) #2

declare i64 @Mtftp6CheckPacket(ptr noundef, ptr noundef, i16 noundef zeroext, ptr noundef) #2

declare i64 @Mtftp6OperationStart(ptr noundef, ptr noundef, i16 noundef zeroext) #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"_MTFTP6_GETINFO_CONTEXT", !6, i64 0, !6, i64 8, !14, i64 16}
!14 = !{!"long long", !7, i64 0}
!15 = !{!13, !6, i64 8}
!16 = !{!13, !14, i64 16}
!17 = !{!18, !14, i64 0}
!18 = !{!"_EFI_MTFTP6_TOKEN", !14, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !6, i64 48, !14, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!19 = !{!18, !6, i64 8}
!20 = !{!18, !6, i64 16}
!21 = !{!18, !6, i64 24}
!22 = !{!18, !6, i64 32}
!23 = !{!18, !11, i64 40}
!24 = !{!18, !6, i64 48}
!25 = !{!18, !14, i64 56}
!26 = !{!18, !6, i64 64}
!27 = !{!18, !6, i64 72}
!28 = !{!18, !6, i64 80}
!29 = !{!18, !6, i64 88}
!30 = !{!18, !6, i64 96}
!31 = !{!14, !14, 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_MTFTP6_TOKEN = type { i64, ptr, ptr, ptr, ptr, i32, ptr, i64, ptr, ptr, ptr, ptr, ptr }
%struct._MTFTP6_GETINFO_CONTEXT = type { ptr, ptr, i64 }

; Function Attrs: nounwind uwtable
define dso_local i64 @EfiMtftp6GetInfo(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i8 noundef zeroext %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #0 {
  %9 = alloca %struct._EFI_MTFTP6_TOKEN, align 8
  %10 = alloca %struct._MTFTP6_GETINFO_CONTEXT, align 8
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #4
  %11 = icmp eq ptr %0, null
  %12 = icmp eq ptr %2, null
  %or.cond = or i1 %11, %12
  %13 = icmp eq ptr %6, null
  %or.cond3 = or i1 %or.cond, %13
  br i1 %or.cond3, label %38, label %14

14:                                               ; preds = %8
  %15 = zext i8 %4 to i32
  %16 = icmp ne i8 %4, 0
  %17 = icmp eq ptr %5, null
  %or.cond5 = and i1 %16, %17
  br i1 %or.cond5, label %38, label %18

18:                                               ; preds = %14
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %21, label %19

19:                                               ; preds = %18
  %20 = tail call zeroext i8 @NetIp6IsValidUnicast(ptr noundef nonnull %1) #4
  %.not31 = icmp eq i8 %20, 0
  br i1 %.not31, label %38, label %21

21:                                               ; preds = %19, %18
  %.not32 = icmp eq ptr %7, null
  br i1 %.not32, label %23, label %22

22:                                               ; preds = %21
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %22, %21
  store i32 0, ptr %6, align 4, !tbaa !9
  store ptr %7, ptr %10, align 8, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr %6, ptr %24, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %10, i64 16
  store i64 0, ptr %25, align 8, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %9, i64 16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %9, i8 0, i64 16, i1 false)
  store ptr %1, ptr %26, align 8, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %9, i64 24
  store ptr %2, ptr %27, align 8, !tbaa !18
  %28 = getelementptr inbounds i8, ptr %9, i64 32
  store ptr %3, ptr %28, align 8, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %9, i64 40
  store i32 %15, ptr %29, align 8, !tbaa !20
  %30 = getelementptr inbounds i8, ptr %9, i64 48
  store ptr %5, ptr %30, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %9, i64 56
  %32 = getelementptr inbounds i8, ptr %9, i64 72
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %31, i8 0, i64 16, i1 false)
  store ptr %10, ptr %32, align 8, !tbaa !22
  %33 = getelementptr inbounds i8, ptr %9, i64 80
  store ptr @Mtftp6CheckPacket, ptr %33, align 8, !tbaa !23
  %34 = getelementptr inbounds i8, ptr %9, i64 88
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %34, i8 0, i64 16, i1 false)
  %35 = call i64 @Mtftp6OperationStart(ptr noundef nonnull %0, ptr noundef nonnull %9, i16 noundef zeroext 1) #4
  %36 = icmp eq i64 %35, -9223372036854775787
  %37 = load i64, ptr %25, align 8
  %spec.select = select i1 %36, i64 %37, i64 %35
  br label %38

38:                                               ; preds = %23, %8, %19, %14
  %.0 = phi i64 [ -9223372036854775806, %14 ], [ -9223372036854775806, %19 ], [ -9223372036854775806, %8 ], [ %spec.select, %23 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %9) #4
  ret i64 %.0
}

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

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

declare zeroext i8 @NetIp6IsValidUnicast(ptr noundef) local_unnamed_addr #2

declare i64 @Mtftp6CheckPacket(ptr noundef, ptr noundef, i16 noundef zeroext, ptr noundef) #2

declare i64 @Mtftp6OperationStart(ptr noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_MTFTP6_GETINFO_CONTEXT", !6, i64 0, !6, i64 8, !13, i64 16}
!13 = !{!"long long", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !13, i64 16}
!16 = !{!17, !6, i64 16}
!17 = !{!"_EFI_MTFTP6_TOKEN", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !6, i64 48, !13, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!18 = !{!17, !6, i64 24}
!19 = !{!17, !6, i64 32}
!20 = !{!17, !10, i64 40}
!21 = !{!17, !6, i64 48}
!22 = !{!17, !6, i64 72}
!23 = !{!17, !6, i64 80}


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