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

; 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.GUID = type { i32, i16, i16, [8 x i8] }
%struct.IP6_CONFIG_DATA_RECORD = type { i16, i32, i32 }
%struct.EFI_RUNTIME_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }
%struct.IP6_CONFIG_VARIABLE = type { i32, i16, i16, [1 x %struct.IP6_CONFIG_DATA_RECORD] }
%struct._IP6_CONFIG_INSTANCE = type { i32, i8, %struct._LIST_ENTRY, i16, %struct.EFI_IP6_CONFIG_INTERFACE_INFO, %struct.EFI_IP6_CONFIG_INTERFACE_ID, i32, %struct.EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS, [7 x %struct.IP6_CONFIG_DATA_ITEM], %struct.NET_MAP, %struct.NET_MAP, %struct._EFI_IP6_CONFIG_PROTOCOL, ptr, ptr, ptr, ptr, i8, i32, ptr, i32, ptr, i32, %struct._IP6_FORM_CALLBACK_INFO, %struct.IP6_CONFIG_NVDATA }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_IP6_CONFIG_INTERFACE_INFO = type { [32 x i16], i8, i32, %struct.EFI_MAC_ADDRESS, i32, ptr, i32, ptr }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }
%struct.EFI_IP6_CONFIG_INTERFACE_ID = type { [8 x i8] }
%struct.EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS = type { i32 }
%struct.IP6_CONFIG_DATA_ITEM = type { ptr, ptr, i64, i8, %struct.NET_MAP, %union.IP6_CONFIG_DATA, i64 }
%union.IP6_CONFIG_DATA = type { ptr }
%struct.NET_MAP = type { %struct._LIST_ENTRY, %struct._LIST_ENTRY, i64 }
%struct._EFI_IP6_CONFIG_PROTOCOL = type { ptr, ptr, ptr, ptr }
%struct._IP6_FORM_CALLBACK_INFO = type { i32, ptr, %struct._EFI_HII_CONFIG_ACCESS_PROTOCOL, ptr, ptr }
%struct._EFI_HII_CONFIG_ACCESS_PROTOCOL = type { ptr, ptr, ptr }
%struct.IP6_CONFIG_NVDATA = type { i32, %struct.EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS, %struct.EFI_IP6_CONFIG_INTERFACE_ID, %struct._LIST_ENTRY, i32, %struct._LIST_ENTRY, i32, %struct._LIST_ENTRY, i32 }

@gRT = external global ptr, align 8
@gEfiIp6ConfigProtocolGuid = external global %struct.GUID, align 4

; 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
define dso_local i64 @Ip6ConfigReadConfigData(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca %struct.IP6_CONFIG_DATA_RECORD, align 4
  %12 = alloca ptr, align 8
  %13 = 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 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store i64 0, ptr %7, align 8, !tbaa !9
  %14 = load ptr, ptr @gRT, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.EFI_RUNTIME_SERVICES, ptr %14, i32 0, i32 7
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call i64 %16(ptr noundef %17, ptr noundef @gEfiIp6ConfigProtocolGuid, ptr noundef null, ptr noundef %7, ptr noundef null)
  store i64 %18, ptr %6, align 8, !tbaa !9
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = icmp eq i64 %19, -9223372036854775803
  br i1 %20, label %21, label %143

21:                                               ; preds = %2
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = call ptr @AllocatePool(i64 noundef %22)
  store ptr %23, ptr %8, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %21
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %145

27:                                               ; preds = %21
  %28 = load ptr, ptr @gRT, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.EFI_RUNTIME_SERVICES, ptr %28, i32 0, i32 7
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = call i64 %30(ptr noundef %31, ptr noundef @gEfiIp6ConfigProtocolGuid, ptr noundef null, ptr noundef %7, ptr noundef %32)
  store i64 %33, ptr %6, align 8, !tbaa !9
  %34 = load i64, ptr %6, align 8, !tbaa !9
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %46, label %36

36:                                               ; preds = %27
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load i64, ptr %7, align 8, !tbaa !9
  %39 = trunc i64 %38 to i32
  %40 = call zeroext i16 @NetblockChecksum(ptr noundef %37, i32 noundef %39)
  %41 = zext i16 %40 to i32
  %42 = xor i32 %41, -1
  %43 = trunc i32 %42 to i16
  %44 = zext i16 %43 to i32
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %53

46:                                               ; preds = %36, %27
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  call void @FreePool(ptr noundef %47)
  %48 = load ptr, ptr @gRT, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.EFI_RUNTIME_SERVICES, ptr %48, i32 0, i32 9
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = call i64 %50(ptr noundef %51, ptr noundef @gEfiIp6ConfigProtocolGuid, i32 noundef 3, i64 noundef 0, ptr noundef null)
  store i64 -9223372036854775794, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %145

53:                                               ; preds = %36
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.IP6_CONFIG_VARIABLE, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 1, !tbaa !16
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._IP6_CONFIG_INSTANCE, ptr %57, i32 0, i32 17
  store i32 %56, ptr %58, align 4, !tbaa !19
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %59

59:                                               ; preds = %138, %53
  %60 = load i64, ptr %10, align 8, !tbaa !9
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.IP6_CONFIG_VARIABLE, ptr %61, i32 0, i32 2
  %63 = load i16, ptr %62, align 1, !tbaa !30
  %64 = zext i16 %63 to i64
  %65 = icmp ult i64 %60, %64
  br i1 %65, label %66, label %141

66:                                               ; preds = %59
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.IP6_CONFIG_VARIABLE, ptr %67, i32 0, i32 3
  %69 = load i64, ptr %10, align 8, !tbaa !9
  %70 = getelementptr inbounds [1 x %struct.IP6_CONFIG_DATA_RECORD], ptr %68, i64 0, i64 %69
  %71 = call ptr @CopyMem(ptr noundef %11, ptr noundef %70, i64 noundef 12)
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._IP6_CONFIG_INSTANCE, ptr %72, i32 0, i32 8
  %74 = getelementptr inbounds %struct.IP6_CONFIG_DATA_RECORD, ptr %11, i32 0, i32 2
  %75 = load i32, ptr %74, align 4, !tbaa !31
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds [7 x %struct.IP6_CONFIG_DATA_ITEM], ptr %73, i64 0, i64 %76
  store ptr %77, ptr %9, align 8, !tbaa !5
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.IP6_CONFIG_DATA_ITEM, ptr %78, i32 0, i32 3
  %80 = load i8, ptr %79, align 8, !tbaa !33
  %81 = zext i8 %80 to i32
  %82 = and i32 %81, 1
  %83 = trunc i32 %82 to i8
  %84 = zext i8 %83 to i32
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %95

86:                                               ; preds = %66
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.IP6_CONFIG_DATA_ITEM, ptr %87, i32 0, i32 6
  %89 = load i64, ptr %88, align 8, !tbaa !35
  %90 = getelementptr inbounds %struct.IP6_CONFIG_DATA_RECORD, ptr %11, i32 0, i32 1
  %91 = load i32, ptr %90, align 4, !tbaa !36
  %92 = zext i32 %91 to i64
  %93 = icmp ne i64 %89, %92
  br i1 %93, label %94, label %95

94:                                               ; preds = %86
  br label %138

95:                                               ; preds = %86, %66
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.IP6_CONFIG_DATA_ITEM, ptr %96, i32 0, i32 3
  %98 = load i8, ptr %97, align 8, !tbaa !33
  %99 = zext i8 %98 to i32
  %100 = and i32 %99, 1
  %101 = trunc i32 %100 to i8
  %102 = icmp ne i8 %101, 0
  br i1 %102, label %116, label %103

103:                                              ; preds = %95
  %104 = getelementptr inbounds %struct.IP6_CONFIG_DATA_RECORD, ptr %11, i32 0, i32 1
  %105 = load i32, ptr %104, align 4, !tbaa !36
  %106 = zext i32 %105 to i64
  %107 = call ptr @AllocatePool(i64 noundef %106)
  %108 = load ptr, ptr %9, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.IP6_CONFIG_DATA_ITEM, ptr %108, i32 0, i32 5
  store ptr %107, ptr %109, align 8, !tbaa !37
  %110 = load ptr, ptr %9, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.IP6_CONFIG_DATA_ITEM, ptr %110, i32 0, i32 5
  %112 = load ptr, ptr %111, align 8, !tbaa !37
  %113 = icmp eq ptr %112, null
  br i1 %113, label %114, label %115

114:                                              ; preds = %103
  br label %138

115:                                              ; preds = %103
  br label %116

116:                                              ; preds = %115, %95
  %117 = load ptr, ptr %8, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.IP6_CONFIG_DATA_RECORD, ptr %11, i32 0, i32 0
  %119 = load i16, ptr %118, align 4, !tbaa !38
  %120 = zext i16 %119 to i32
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i8, ptr %117, i64 %121
  store ptr %122, ptr %12, align 8, !tbaa !5
  %123 = load ptr, ptr %9, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.IP6_CONFIG_DATA_ITEM, ptr %123, i32 0, i32 5
  %125 = load ptr, ptr %124, align 8, !tbaa !37
  %126 = load ptr, ptr %12, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.IP6_CONFIG_DATA_RECORD, ptr %11, i32 0, i32 1
  %128 = load i32, ptr %127, align 4, !tbaa !36
  %129 = zext i32 %128 to i64
  %130 = call ptr @CopyMem(ptr noundef %125, ptr noundef %126, i64 noundef %129)
  %131 = getelementptr inbounds %struct.IP6_CONFIG_DATA_RECORD, ptr %11, i32 0, i32 1
  %132 = load i32, ptr %131, align 4, !tbaa !36
  %133 = zext i32 %132 to i64
  %134 = load ptr, ptr %9, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.IP6_CONFIG_DATA_ITEM, ptr %134, i32 0, i32 6
  store i64 %133, ptr %135, align 8, !tbaa !35
  %136 = load ptr, ptr %9, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.IP6_CONFIG_DATA_ITEM, ptr %136, i32 0, i32 2
  store i64 0, ptr %137, align 8, !tbaa !39
  br label %138

138:                                              ; preds = %116, %114, %94
  %139 = load i64, ptr %10, align 8, !tbaa !9
  %140 = add i64 %139, 1
  store i64 %140, ptr %10, align 8, !tbaa !9
  br label %59, !llvm.loop !40

141:                                              ; preds = %59
  %142 = load ptr, ptr %8, align 8, !tbaa !5
  call void @FreePool(ptr noundef %142)
  store i64 0, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %145

143:                                              ; preds = %2
  %144 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %144, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %145

145:                                              ; preds = %143, %141, %46, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, 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
  %146 = load i64, ptr %3, align 8
  ret i64 %146
}

declare ptr @AllocatePool(i64 noundef) #2

declare zeroext i16 @NetblockChecksum(ptr noundef, i32 noundef) #2

declare void @FreePool(ptr 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 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 72}
!12 = !{!"", !13, i64 0, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!13 = !{!"", !10, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !6, i64 88}
!16 = !{!17, !14, i64 0}
!17 = !{!"", !14, i64 0, !18, i64 4, !18, i64 6, !7, i64 8}
!18 = !{!"short", !7, i64 0}
!19 = !{!20, !14, i64 948}
!20 = !{!"_IP6_CONFIG_INSTANCE", !14, i64 0, !7, i64 4, !21, i64 8, !18, i64 24, !22, i64 32, !23, i64 168, !14, i64 176, !24, i64 180, !7, i64 184, !25, i64 800, !25, i64 840, !26, i64 880, !6, i64 912, !6, i64 920, !6, i64 928, !6, i64 936, !7, i64 944, !14, i64 948, !6, i64 952, !14, i64 960, !6, i64 968, !14, i64 976, !27, i64 984, !29, i64 1040}
!21 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!22 = !{!"", !7, i64 0, !7, i64 64, !14, i64 68, !23, i64 72, !14, i64 104, !6, i64 112, !14, i64 120, !6, i64 128}
!23 = !{!"", !7, i64 0}
!24 = !{!"", !14, i64 0}
!25 = !{!"", !21, i64 0, !21, i64 16, !10, i64 32}
!26 = !{!"_EFI_IP6_CONFIG_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!27 = !{!"_IP6_FORM_CALLBACK_INFO", !14, i64 0, !6, i64 8, !28, i64 16, !6, i64 40, !6, i64 48}
!28 = !{!"_EFI_HII_CONFIG_ACCESS_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16}
!29 = !{!"", !14, i64 0, !24, i64 4, !23, i64 8, !21, i64 16, !14, i64 32, !21, i64 40, !14, i64 56, !21, i64 64, !14, i64 80}
!30 = !{!17, !18, i64 6}
!31 = !{!32, !14, i64 8}
!32 = !{!"", !18, i64 0, !14, i64 4, !14, i64 8}
!33 = !{!34, !7, i64 24}
!34 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16, !7, i64 24, !25, i64 32, !7, i64 72, !10, i64 80}
!35 = !{!34, !10, i64 80}
!36 = !{!32, !14, i64 4}
!37 = !{!7, !7, i64 0}
!38 = !{!32, !18, i64 0}
!39 = !{!34, !10, i64 16}
!40 = distinct !{!40, !41}
!41 = !{!"llvm.loop.mustprogress"}


; 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.GUID = type { i32, i16, i16, [8 x i8] }
%struct.IP6_CONFIG_DATA_RECORD = type { i16, i32, i32 }
%struct.IP6_CONFIG_DATA_ITEM = type { ptr, ptr, i64, i8, %struct.NET_MAP, %union.IP6_CONFIG_DATA, i64 }
%struct.NET_MAP = type { %struct._LIST_ENTRY, %struct._LIST_ENTRY, i64 }
%struct._LIST_ENTRY = type { ptr, ptr }
%union.IP6_CONFIG_DATA = type { ptr }

@gRT = external local_unnamed_addr global ptr, align 8
@gEfiIp6ConfigProtocolGuid = external global %struct.GUID, align 4

; 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

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775802, -9223372036854775803) i64 @Ip6ConfigReadConfigData(ptr noundef %0, ptr nocapture noundef %1) local_unnamed_addr #1 {
  %3 = alloca i64, align 8
  %4 = alloca %struct.IP6_CONFIG_DATA_RECORD, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #3
  store i64 0, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr @gRT, align 8, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %5, i64 72
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = call i64 %7(ptr noundef %0, ptr noundef nonnull @gEfiIp6ConfigProtocolGuid, ptr noundef null, ptr noundef nonnull %3, ptr noundef null) #3
  %9 = icmp eq i64 %8, -9223372036854775803
  br i1 %9, label %10, label %73

10:                                               ; preds = %2
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = call ptr @AllocatePool(i64 noundef %11) #3
  %13 = icmp eq ptr %12, null
  br i1 %13, label %73, label %14

14:                                               ; preds = %10
  %15 = load ptr, ptr @gRT, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %15, i64 72
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = call i64 %17(ptr noundef %0, ptr noundef nonnull @gEfiIp6ConfigProtocolGuid, ptr noundef null, ptr noundef nonnull %3, ptr noundef nonnull %12) #3
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %24, label %20

20:                                               ; preds = %14
  %21 = load i64, ptr %3, align 8, !tbaa !5
  %22 = trunc i64 %21 to i32
  %23 = call zeroext i16 @NetblockChecksum(ptr noundef nonnull %12, i32 noundef %22) #3
  %.not = icmp eq i16 %23, -1
  br i1 %.not, label %29, label %24

24:                                               ; preds = %20, %14
  call void @FreePool(ptr noundef nonnull %12) #3
  %25 = load ptr, ptr @gRT, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %25, i64 88
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = call i64 %27(ptr noundef %0, ptr noundef nonnull @gEfiIp6ConfigProtocolGuid, i32 noundef 3, i64 noundef 0, ptr noundef null) #3
  br label %73

29:                                               ; preds = %20
  %30 = load i32, ptr %12, align 1, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %1, i64 948
  store i32 %30, ptr %31, align 4, !tbaa !19
  %32 = getelementptr inbounds i8, ptr %12, i64 6
  %33 = load i16, ptr %32, align 1, !tbaa !30
  %.not36 = icmp eq i16 %33, 0
  br i1 %.not36, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %29
  %34 = getelementptr inbounds i8, ptr %12, i64 8
  %35 = getelementptr inbounds i8, ptr %1, i64 184
  %36 = getelementptr inbounds i8, ptr %4, i64 8
  %37 = getelementptr inbounds i8, ptr %4, i64 4
  br label %38

38:                                               ; preds = %.lr.ph, %68
  %.02935 = phi i64 [ 0, %.lr.ph ], [ %69, %68 ]
  %39 = getelementptr inbounds [1 x %struct.IP6_CONFIG_DATA_RECORD], ptr %34, i64 0, i64 %.02935
  %40 = call ptr @CopyMem(ptr noundef nonnull %4, ptr noundef nonnull %39, i64 noundef 12) #3
  %41 = load i32, ptr %36, align 4, !tbaa !31
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds [7 x %struct.IP6_CONFIG_DATA_ITEM], ptr %35, i64 0, i64 %42
  %44 = getelementptr inbounds i8, ptr %43, i64 24
  %45 = load i8, ptr %44, align 8, !tbaa !33
  %46 = and i8 %45, 1
  %.not32 = icmp eq i8 %46, 0
  br i1 %.not32, label %52, label %47

47:                                               ; preds = %38
  %48 = getelementptr inbounds i8, ptr %43, i64 80
  %49 = load i64, ptr %48, align 8, !tbaa !35
  %50 = load i32, ptr %37, align 4, !tbaa !36
  %51 = zext i32 %50 to i64
  %.not33 = icmp eq i64 %49, %51
  br i1 %.not33, label %._crit_edge37, label %68

._crit_edge37:                                    ; preds = %47
  %.phi.trans.insert = getelementptr inbounds i8, ptr %43, i64 72
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !37
  br label %58

52:                                               ; preds = %38
  %53 = load i32, ptr %37, align 4, !tbaa !36
  %54 = zext i32 %53 to i64
  %55 = call ptr @AllocatePool(i64 noundef %54) #3
  %56 = getelementptr inbounds i8, ptr %43, i64 72
  store ptr %55, ptr %56, align 8, !tbaa !37
  %57 = icmp eq ptr %55, null
  br i1 %57, label %68, label %._crit_edge38

._crit_edge38:                                    ; preds = %52
  %.pre39 = load i32, ptr %37, align 4, !tbaa !36
  %.pre40 = zext i32 %.pre39 to i64
  br label %58

58:                                               ; preds = %._crit_edge38, %._crit_edge37
  %.pre-phi = phi i64 [ %.pre40, %._crit_edge38 ], [ %51, %._crit_edge37 ]
  %59 = phi ptr [ %55, %._crit_edge38 ], [ %.pre, %._crit_edge37 ]
  %60 = load i16, ptr %4, align 4, !tbaa !38
  %61 = zext i16 %60 to i64
  %62 = getelementptr inbounds i8, ptr %12, i64 %61
  %63 = call ptr @CopyMem(ptr noundef %59, ptr noundef nonnull %62, i64 noundef %.pre-phi) #3
  %64 = load i32, ptr %37, align 4, !tbaa !36
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr %43, i64 80
  store i64 %65, ptr %66, align 8, !tbaa !35
  %67 = getelementptr inbounds i8, ptr %43, i64 16
  store i64 0, ptr %67, align 8, !tbaa !39
  br label %68

68:                                               ; preds = %52, %47, %58
  %69 = add nuw nsw i64 %.02935, 1
  %70 = load i16, ptr %32, align 1, !tbaa !30
  %71 = zext i16 %70 to i64
  %72 = icmp ult i64 %69, %71
  br i1 %72, label %38, label %._crit_edge, !llvm.loop !40

._crit_edge:                                      ; preds = %68, %29
  call void @FreePool(ptr noundef nonnull %12) #3
  br label %73

73:                                               ; preds = %2, %10, %._crit_edge, %24
  %.0 = phi i64 [ -9223372036854775794, %24 ], [ 0, %._crit_edge ], [ -9223372036854775799, %10 ], [ %8, %2 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i64 %.0
}

declare ptr @AllocatePool(i64 noundef) local_unnamed_addr #2

declare zeroext i16 @NetblockChecksum(ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @FreePool(ptr noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 72}
!12 = !{!"", !13, i64 0, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128}
!13 = !{!"", !6, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !10, i64 88}
!16 = !{!17, !14, i64 0}
!17 = !{!"", !14, i64 0, !18, i64 4, !18, i64 6, !7, i64 8}
!18 = !{!"short", !7, i64 0}
!19 = !{!20, !14, i64 948}
!20 = !{!"_IP6_CONFIG_INSTANCE", !14, i64 0, !7, i64 4, !21, i64 8, !18, i64 24, !22, i64 32, !23, i64 168, !14, i64 176, !24, i64 180, !7, i64 184, !25, i64 800, !25, i64 840, !26, i64 880, !10, i64 912, !10, i64 920, !10, i64 928, !10, i64 936, !7, i64 944, !14, i64 948, !10, i64 952, !14, i64 960, !10, i64 968, !14, i64 976, !27, i64 984, !29, i64 1040}
!21 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}
!22 = !{!"", !7, i64 0, !7, i64 64, !14, i64 68, !23, i64 72, !14, i64 104, !10, i64 112, !14, i64 120, !10, i64 128}
!23 = !{!"", !7, i64 0}
!24 = !{!"", !14, i64 0}
!25 = !{!"", !21, i64 0, !21, i64 16, !6, i64 32}
!26 = !{!"_EFI_IP6_CONFIG_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!27 = !{!"_IP6_FORM_CALLBACK_INFO", !14, i64 0, !10, i64 8, !28, i64 16, !10, i64 40, !10, i64 48}
!28 = !{!"_EFI_HII_CONFIG_ACCESS_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16}
!29 = !{!"", !14, i64 0, !24, i64 4, !23, i64 8, !21, i64 16, !14, i64 32, !21, i64 40, !14, i64 56, !21, i64 64, !14, i64 80}
!30 = !{!17, !18, i64 6}
!31 = !{!32, !14, i64 8}
!32 = !{!"", !18, i64 0, !14, i64 4, !14, i64 8}
!33 = !{!34, !7, i64 24}
!34 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16, !7, i64 24, !25, i64 32, !7, i64 72, !6, i64 80}
!35 = !{!34, !6, i64 80}
!36 = !{!32, !14, i64 4}
!37 = !{!7, !7, i64 0}
!38 = !{!32, !18, i64 0}
!39 = !{!34, !6, i64 16}
!40 = distinct !{!40, !41}
!41 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass