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

; 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._UDP4_INSTANCE_DATA_ = type { i32, %struct._LIST_ENTRY, ptr, %struct._EFI_UDP4_PROTOCOL, %struct.EFI_UDP4_CONFIG_DATA, ptr, i8, i8, %struct.NET_MAP, %struct.NET_MAP, %struct.NET_MAP, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i16, i64, ptr, i8 }
%struct._EFI_UDP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%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_IPv4_ADDRESS = type { [4 x i8] }
%struct.NET_MAP = type { %struct._LIST_ENTRY, %struct._LIST_ENTRY, i64 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct._IP_IO_IP_INFO = type { %union.EFI_IP_ADDRESS, %union.IP_IO_IP_MASK, %struct._LIST_ENTRY, ptr, %union.IP_IO_IP_PROTOCOL, %union.IP_IO_IP_COMPLETION_TOKEN, i64, i8 }
%union.EFI_IP_ADDRESS = type { [4 x i32] }
%union.IP_IO_IP_MASK = type { i32 }
%union.IP_IO_IP_PROTOCOL = type { ptr }
%union.IP_IO_IP_COMPLETION_TOKEN = type { %struct.EFI_IP4_COMPLETION_TOKEN }
%struct.EFI_IP4_COMPLETION_TOKEN = type { ptr, i64, %union.anon }
%union.anon = type { ptr }
%struct._EFI_IP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [151 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @Udp4Routes(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i8 %1, ptr %8, align 1, !tbaa !9
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %5
  store i64 -9223372036854775806, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %65

18:                                               ; preds = %5
  %19 = call zeroext i8 @DebugAssertEnabled()
  %20 = zext i8 %19 to i32
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %32

22:                                               ; preds = %18
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = ptrtoint ptr %23 to i64
  %25 = sub i64 %24, ptrtoint (ptr getelementptr inbounds (%struct._UDP4_INSTANCE_DATA_, ptr null, i32 0, i32 3) to i64)
  %26 = inttoptr i64 %25 to ptr
  %27 = getelementptr inbounds %struct._UDP4_INSTANCE_DATA_, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !10
  %29 = icmp ne i32 %28, 1232102485
  br i1 %29, label %30, label %32

30:                                               ; preds = %22
  call void @DebugAssert(ptr noundef @.str, i64 noundef 448, ptr noundef @.str.1)
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  br label %37

32:                                               ; preds = %22, %18
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = ptrtoint ptr %33 to i64
  %35 = sub i64 %34, ptrtoint (ptr getelementptr inbounds (%struct._UDP4_INSTANCE_DATA_, ptr null, i32 0, i32 3) to i64)
  %36 = inttoptr i64 %35 to ptr
  br label %37

37:                                               ; preds = %32, %30
  %38 = phi ptr [ %31, %30 ], [ %36, %32 ]
  store ptr %38, ptr %12, align 8, !tbaa !5
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._UDP4_INSTANCE_DATA_, ptr %39, i32 0, i32 7
  %41 = load i8, ptr %40, align 1, !tbaa !20
  %42 = icmp ne i8 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %37
  store i64 -9223372036854775791, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %65

44:                                               ; preds = %37
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._UDP4_INSTANCE_DATA_, ptr %45, i32 0, i32 6
  %47 = load i8, ptr %46, align 8, !tbaa !21
  %48 = icmp ne i8 %47, 0
  br i1 %48, label %50, label %49

49:                                               ; preds = %44
  store i64 -9223372036854775789, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %65

50:                                               ; preds = %44
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._UDP4_INSTANCE_DATA_, ptr %51, i32 0, i32 15
  %53 = load ptr, ptr %52, align 8, !tbaa !22
  %54 = getelementptr inbounds %struct._IP_IO_IP_INFO, ptr %53, i32 0, i32 4
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  store ptr %55, ptr %13, align 8, !tbaa !5
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._EFI_IP4_PROTOCOL, ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !23
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load i8, ptr %8, align 1, !tbaa !9
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = call i64 %58(ptr noundef %59, i8 noundef zeroext %60, ptr noundef %61, ptr noundef %62, ptr noundef %63)
  store i64 %64, ptr %6, align 8
  store i32 1, ptr %14, align 4
  br label %65

65:                                               ; preds = %50, %49, %43, %17
  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
}

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

declare zeroext i8 @DebugAssertEnabled() #2

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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, !12, i64 0}
!11 = !{!"_UDP4_INSTANCE_DATA_", !12, i64 0, !13, i64 8, !6, i64 24, !14, i64 32, !15, i64 96, !6, i64 136, !7, i64 144, !7, i64 145, !18, i64 152, !18, i64 192, !18, i64 232, !13, i64 272, !13, i64 288, !17, i64 304, !19, i64 312, !6, i64 320, !7, i64 328}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!"_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}
!15 = !{!"", !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, !16, i64 17, !16, i64 21, !17, i64 26, !16, i64 28, !17, i64 32}
!16 = !{!"", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!"", !13, i64 0, !13, i64 16, !19, i64 32}
!19 = !{!"long long", !7, i64 0}
!20 = !{!11, !7, i64 145}
!21 = !{!11, !7, i64 144}
!22 = !{!11, !6, i64 320}
!23 = !{!24, !6, i64 24}
!24 = !{!"_EFI_IP4_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}


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

@.str = external hidden unnamed_addr constant [151 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @Udp4Routes(ptr noundef %0, i8 noundef zeroext %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = icmp eq ptr %0, null
  br i1 %6, label %26, label %7

7:                                                ; preds = %5
  %8 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %8, 0
  %.pre = ptrtoint ptr %0 to i64
  %.pre17 = add i64 %.pre, -32
  %.pre19 = inttoptr i64 %.pre17 to ptr
  br i1 %.not, label %._crit_edge, label %9

9:                                                ; preds = %7
  %10 = load i32, ptr %.pre19, align 8, !tbaa !5
  %.not14 = icmp eq i32 %10, 1232102485
  br i1 %.not14, label %._crit_edge, label %11

11:                                               ; preds = %9
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 448, ptr noundef nonnull @.str.1) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %7, %9, %11
  %12 = phi ptr [ %0, %11 ], [ %.pre19, %9 ], [ %.pre19, %7 ]
  %13 = getelementptr inbounds i8, ptr %12, i64 145
  %14 = load i8, ptr %13, align 1, !tbaa !18
  %.not15 = icmp eq i8 %14, 0
  br i1 %.not15, label %15, label %26

15:                                               ; preds = %._crit_edge
  %16 = getelementptr inbounds i8, ptr %12, i64 144
  %17 = load i8, ptr %16, align 8, !tbaa !19
  %.not16 = icmp eq i8 %17, 0
  br i1 %.not16, label %26, label %18

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %12, i64 320
  %20 = load ptr, ptr %19, align 8, !tbaa !20
  %21 = getelementptr inbounds i8, ptr %20, i64 48
  %22 = load ptr, ptr %21, align 8, !tbaa !21
  %23 = getelementptr inbounds i8, ptr %22, i64 24
  %24 = load ptr, ptr %23, align 8, !tbaa !22
  %25 = tail call i64 %24(ptr noundef %22, i8 noundef zeroext %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2
  br label %26

26:                                               ; preds = %15, %._crit_edge, %5, %18
  %.0 = phi i64 [ %25, %18 ], [ -9223372036854775806, %5 ], [ -9223372036854775791, %._crit_edge ], [ -9223372036854775789, %15 ]
  ret i64 %.0
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

declare void @DebugAssert(ptr noundef, i64 noundef, ptr 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, !7, i64 0}
!6 = !{!"_UDP4_INSTANCE_DATA_", !7, i64 0, !10, i64 8, !11, i64 24, !12, i64 32, !13, i64 96, !11, i64 136, !8, i64 144, !8, i64 145, !16, i64 152, !16, i64 192, !16, i64 232, !10, i64 272, !10, i64 288, !15, i64 304, !17, i64 312, !11, i64 320, !8, i64 328}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_EFI_UDP4_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!13 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6, !7, i64 8, !7, i64 12, !8, i64 16, !14, i64 17, !14, i64 21, !15, i64 26, !14, i64 28, !15, i64 32}
!14 = !{!"", !8, i64 0}
!15 = !{!"short", !8, i64 0}
!16 = !{!"", !10, i64 0, !10, i64 16, !17, i64 32}
!17 = !{!"long long", !8, i64 0}
!18 = !{!6, !8, i64 145}
!19 = !{!6, !8, i64 144}
!20 = !{!6, !11, i64 320}
!21 = !{!8, !8, i64 0}
!22 = !{!23, !11, i64 24}
!23 = !{!"_EFI_IP4_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass