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

; 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._LIST_ENTRY = type { ptr, ptr }
%struct._IP6_SERVICE = type { i32, %struct._EFI_SERVICE_BINDING_PROTOCOL, i64, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, ptr, ptr, %struct.IP6_LINK_RX_TOKEN, %struct.IP6_ASSEMBLE_TABLE, %struct.IP6_MLD_SERVICE_DATA, %struct.EFI_IPv6_ADDRESS, i8, i8, i8, i8, i8, i32, i32, i32, i32, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i8, ptr, i8, i8, i32, ptr, ptr, ptr, ptr, %struct.EFI_MANAGED_NETWORK_CONFIG_DATA, %struct.EFI_SIMPLE_NETWORK_MODE, ptr, ptr, %struct._IP6_CONFIG_INSTANCE, ptr, i32, i32 }
%struct._EFI_SERVICE_BINDING_PROTOCOL = type { ptr, ptr }
%struct.IP6_LINK_RX_TOKEN = type { i32, ptr, ptr, %struct.EFI_MANAGED_NETWORK_COMPLETION_TOKEN }
%struct.EFI_MANAGED_NETWORK_COMPLETION_TOKEN = type { ptr, i64, %union.anon }
%union.anon = type { ptr }
%struct.IP6_ASSEMBLE_TABLE = type { [127 x %struct._LIST_ENTRY] }
%struct.IP6_MLD_SERVICE_DATA = type { i64, %struct._LIST_ENTRY }
%struct.EFI_IPv6_ADDRESS = type { [16 x i8] }
%struct.EFI_MANAGED_NETWORK_CONFIG_DATA = type { i32, i32, i16, i8, i8, i8, i8, i8, i8, i8 }
%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._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.EFI_IP6_CONFIG_INTERFACE_INFO = type { [32 x i16], i8, i32, %struct.EFI_MAC_ADDRESS, i32, ptr, i32, ptr }
%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 }
%struct._IP6_PREFIX_LIST_ENTRY = type { %struct._LIST_ENTRY, i64, i32, i32, i8, %struct.EFI_IPv6_ADDRESS }
%struct._IP6_ADDRESS_INFO = type { i32, %struct._LIST_ENTRY, %struct.EFI_IPv6_ADDRESS, i8, i8, i32, i32 }

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @Ip6CommonPrefixLen(ptr noundef, ptr noundef) #0

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

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

22:                                               ; preds = %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %30

25:                                               ; preds = %22
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._IP6_SERVICE, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = icmp eq i32 %28, 1396068425
  br i1 %29, label %31, label %30

30:                                               ; preds = %25, %22
  call void @DebugAssert(ptr noundef @.str, i64 noundef 176, ptr noundef @.str.2)
  br label %31

31:                                               ; preds = %30, %25
  br label %32

32:                                               ; preds = %31, %19
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  store i64 0, ptr %8, align 8, !tbaa !30
  %35 = call ptr @InitializeListHead(ptr noundef %9)
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._IP6_SERVICE, ptr %36, i32 0, i32 12
  %38 = load i8, ptr %37, align 8, !tbaa !31
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %41, label %40

40:                                               ; preds = %34
  store i64 -9223372036854775791, ptr %4, align 8
  store i32 1, ptr %18, align 4
  br label %189

41:                                               ; preds = %34
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = call zeroext i8 @Ip6IsOneOfSetAddress(ptr noundef %42, ptr noundef %43, ptr noundef null, ptr noundef null)
  %45 = icmp ne i8 %44, 0
  br i1 %45, label %46, label %50

46:                                               ; preds = %41
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call ptr @CopyMem(ptr noundef %47, ptr noundef %48, i64 noundef 16)
  br label %186

50:                                               ; preds = %41
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds [16 x i8], ptr %52, i64 0, i64 0
  %54 = load i8, ptr %53, align 1, !tbaa !32
  %55 = zext i8 %54 to i32
  %56 = icmp eq i32 %55, 255
  br i1 %56, label %57, label %65

57:                                               ; preds = %50
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.EFI_IPv6_ADDRESS, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds [16 x i8], ptr %59, i64 0, i64 1
  %61 = load i8, ptr %60, align 1, !tbaa !32
  %62 = zext i8 %61 to i32
  %63 = ashr i32 %62, 4
  %64 = trunc i32 %63 to i8
  store i8 %64, ptr %11, align 1, !tbaa !32
  br label %72

65:                                               ; preds = %50
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = call zeroext i8 @NetIp6IsLinkLocalAddr(ptr noundef %66)
  %68 = icmp ne i8 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %65
  store i8 2, ptr %11, align 1, !tbaa !32
  br label %71

70:                                               ; preds = %65
  store i8 14, ptr %11, align 1, !tbaa !32
  br label %71

71:                                               ; preds = %70, %69
  br label %72

72:                                               ; preds = %71, %57
  %73 = load i8, ptr %11, align 1, !tbaa !32
  %74 = zext i8 %73 to i32
  %75 = icmp sle i32 %74, 2
  br i1 %75, label %76, label %81

76:                                               ; preds = %72
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._IP6_SERVICE, ptr %78, i32 0, i32 11
  %80 = call ptr @CopyMem(ptr noundef %77, ptr noundef %79, i64 noundef 16)
  br label %186

81:                                               ; preds = %72
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = call i64 @Ip6CandidateSource(ptr noundef %82, ptr noundef %9, ptr noundef %10)
  %84 = load i32, ptr %10, align 4, !tbaa !33
  %85 = icmp eq i32 %84, 0
  br i1 %85, label %86, label %87

86:                                               ; preds = %81
  store i64 -9223372036854775791, ptr %8, align 8, !tbaa !30
  br label %186

87:                                               ; preds = %81
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._IP6_SERVICE, ptr %89, i32 0, i32 11
  %91 = call ptr @CopyMem(ptr noundef %88, ptr noundef %90, i64 noundef 16)
  %92 = load i32, ptr %10, align 4, !tbaa !33
  %93 = icmp eq i32 %92, 1
  br i1 %93, label %94, label %95

94:                                               ; preds = %87
  br label %186

95:                                               ; preds = %87
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct._IP6_SERVICE, ptr %96, i32 0, i32 23
  %98 = getelementptr inbounds %struct._LIST_ENTRY, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !34
  store ptr %99, ptr %12, align 8, !tbaa !5
  br label %100

100:                                              ; preds = %126, %95
  %101 = load ptr, ptr %12, align 8, !tbaa !5
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct._IP6_SERVICE, ptr %102, i32 0, i32 23
  %104 = icmp ne ptr %101, %103
  br i1 %104, label %105, label %130

105:                                              ; preds = %100
  %106 = load ptr, ptr %12, align 8, !tbaa !5
  %107 = ptrtoint ptr %106 to i64
  %108 = sub i64 %107, 0
  %109 = inttoptr i64 %108 to ptr
  store ptr %109, ptr %14, align 8, !tbaa !5
  %110 = load ptr, ptr %14, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct._IP6_PREFIX_LIST_ENTRY, ptr %110, i32 0, i32 3
  %112 = load i32, ptr %111, align 4, !tbaa !35
  %113 = icmp eq i32 %112, 0
  br i1 %113, label %114, label %125

114:                                              ; preds = %105
  %115 = load ptr, ptr %14, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct._IP6_PREFIX_LIST_ENTRY, ptr %115, i32 0, i32 5
  %117 = load ptr, ptr %14, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct._IP6_PREFIX_LIST_ENTRY, ptr %117, i32 0, i32 4
  %119 = load i8, ptr %118, align 8, !tbaa !37
  %120 = call i64 @Ip6RemoveAddr(ptr noundef null, ptr noundef %9, ptr noundef %10, ptr noundef %116, i8 noundef zeroext %119)
  %121 = load i32, ptr %10, align 4, !tbaa !33
  %122 = icmp eq i32 %121, 1
  br i1 %122, label %123, label %124

123:                                              ; preds = %114
  br label %186

124:                                              ; preds = %114
  br label %125

125:                                              ; preds = %124, %105
  br label %126

126:                                              ; preds = %125
  %127 = load ptr, ptr %12, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct._LIST_ENTRY, ptr %127, i32 0, i32 0
  %129 = load ptr, ptr %128, align 8, !tbaa !38
  store ptr %129, ptr %12, align 8, !tbaa !5
  br label %100, !llvm.loop !39

130:                                              ; preds = %100
  %131 = load ptr, ptr %7, align 8, !tbaa !5
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = call zeroext i8 @Ip6CommonPrefixLen(ptr noundef %131, ptr noundef %132)
  store i8 %133, ptr %15, align 1, !tbaa !32
  store ptr null, ptr %17, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct._LIST_ENTRY, ptr %9, i32 0, i32 0
  %135 = load ptr, ptr %134, align 8, !tbaa !38
  store ptr %135, ptr %12, align 8, !tbaa !5
  br label %136

136:                                              ; preds = %174, %130
  %137 = load ptr, ptr %12, align 8, !tbaa !5
  %138 = icmp ne ptr %137, %9
  br i1 %138, label %139, label %178

139:                                              ; preds = %136
  %140 = call zeroext i8 @DebugAssertEnabled()
  %141 = zext i8 %140 to i32
  %142 = icmp ne i32 %141, 0
  br i1 %142, label %143, label %153

143:                                              ; preds = %139
  %144 = load ptr, ptr %12, align 8, !tbaa !5
  %145 = ptrtoint ptr %144 to i64
  %146 = sub i64 %145, ptrtoint (ptr getelementptr inbounds (%struct._IP6_ADDRESS_INFO, ptr null, i32 0, i32 1) to i64)
  %147 = inttoptr i64 %146 to ptr
  %148 = getelementptr inbounds %struct._IP6_ADDRESS_INFO, ptr %147, i32 0, i32 0
  %149 = load i32, ptr %148, align 8, !tbaa !41
  %150 = icmp ne i32 %149, 1229017161
  br i1 %150, label %151, label %153

151:                                              ; preds = %143
  call void @DebugAssert(ptr noundef @.str, i64 noundef 258, ptr noundef @.str.1)
  %152 = load ptr, ptr %12, align 8, !tbaa !5
  br label %158

153:                                              ; preds = %143, %139
  %154 = load ptr, ptr %12, align 8, !tbaa !5
  %155 = ptrtoint ptr %154 to i64
  %156 = sub i64 %155, ptrtoint (ptr getelementptr inbounds (%struct._IP6_ADDRESS_INFO, ptr null, i32 0, i32 1) to i64)
  %157 = inttoptr i64 %156 to ptr
  br label %158

158:                                              ; preds = %153, %151
  %159 = phi ptr [ %152, %151 ], [ %157, %153 ]
  store ptr %159, ptr %13, align 8, !tbaa !5
  %160 = load ptr, ptr %13, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct._IP6_ADDRESS_INFO, ptr %160, i32 0, i32 2
  %162 = load ptr, ptr %6, align 8, !tbaa !5
  %163 = call zeroext i8 @Ip6CommonPrefixLen(ptr noundef %161, ptr noundef %162)
  store i8 %163, ptr %16, align 1, !tbaa !32
  %164 = load i8, ptr %16, align 1, !tbaa !32
  %165 = zext i8 %164 to i32
  %166 = load i8, ptr %15, align 1, !tbaa !32
  %167 = zext i8 %166 to i32
  %168 = icmp sgt i32 %165, %167
  br i1 %168, label %169, label %173

169:                                              ; preds = %158
  %170 = load i8, ptr %16, align 1, !tbaa !32
  store i8 %170, ptr %15, align 1, !tbaa !32
  %171 = load ptr, ptr %13, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct._IP6_ADDRESS_INFO, ptr %171, i32 0, i32 2
  store ptr %172, ptr %17, align 8, !tbaa !5
  br label %173

173:                                              ; preds = %169, %158
  br label %174

174:                                              ; preds = %173
  %175 = load ptr, ptr %12, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct._LIST_ENTRY, ptr %175, i32 0, i32 0
  %177 = load ptr, ptr %176, align 8, !tbaa !38
  store ptr %177, ptr %12, align 8, !tbaa !5
  br label %136, !llvm.loop !43

178:                                              ; preds = %136
  %179 = load ptr, ptr %17, align 8, !tbaa !5
  %180 = icmp ne ptr %179, null
  br i1 %180, label %181, label %185

181:                                              ; preds = %178
  %182 = load ptr, ptr %7, align 8, !tbaa !5
  %183 = load ptr, ptr %17, align 8, !tbaa !5
  %184 = call ptr @CopyMem(ptr noundef %182, ptr noundef %183, i64 noundef 16)
  br label %185

185:                                              ; preds = %181, %178
  br label %186

186:                                              ; preds = %185, %123, %94, %86, %76, %46
  %187 = call i64 @Ip6RemoveAddr(ptr noundef null, ptr noundef %9, ptr noundef %10, ptr noundef null, i8 noundef zeroext 0)
  %188 = load i64, ptr %8, align 8, !tbaa !30
  store i64 %188, ptr %4, align 8
  store i32 1, ptr %18, align 4
  br label %189

189:                                              ; preds = %186, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  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
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, 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
  %190 = load i64, ptr %4, align 8
  ret i64 %190
}

declare ptr @InitializeListHead(ptr noundef) #2

declare zeroext i8 @Ip6IsOneOfSetAddress(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare zeroext i8 @NetIp6IsLinkLocalAddr(ptr noundef) #2

declare i64 @Ip6RemoveAddr(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 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 = !{!10, !11, i64 0}
!10 = !{!"_IP6_SERVICE", !11, i64 0, !12, i64 8, !13, i64 24, !13, i64 32, !14, i64 40, !14, i64 56, !6, i64 72, !6, i64 80, !15, i64 88, !17, i64 136, !18, i64 2168, !17, i64 2192, !7, i64 2208, !7, i64 2209, !7, i64 2210, !7, i64 2211, !7, i64 2212, !11, i64 2216, !11, i64 2220, !11, i64 2224, !11, i64 2228, !14, i64 2232, !14, i64 2248, !14, i64 2264, !14, i64 2280, !11, i64 2296, !7, i64 2300, !6, i64 2304, !7, i64 2312, !7, i64 2313, !11, i64 2316, !6, i64 2320, !6, i64 2328, !6, i64 2336, !6, i64 2344, !19, i64 2352, !21, i64 2372, !6, i64 3032, !6, i64 3040, !22, i64 3048, !6, i64 4176, !11, i64 4184, !11, i64 4188}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"", !11, i64 0, !6, i64 8, !6, i64 16, !16, i64 24}
!16 = !{!"", !6, i64 0, !13, i64 8, !7, i64 16}
!17 = !{!"", !7, i64 0}
!18 = !{!"", !13, i64 0, !14, i64 8}
!19 = !{!"", !11, i64 0, !11, i64 4, !20, i64 8, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16}
!20 = !{!"short", !7, i64 0}
!21 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !17, i64 552, !17, i64 584, !17, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!22 = !{!"_IP6_CONFIG_INSTANCE", !11, i64 0, !7, i64 4, !14, i64 8, !20, i64 24, !23, i64 32, !17, i64 168, !11, 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, !11, i64 948, !6, i64 952, !11, i64 960, !6, i64 968, !11, i64 976, !27, i64 984, !29, i64 1040}
!23 = !{!"", !7, i64 0, !7, i64 64, !11, i64 68, !17, i64 72, !11, i64 104, !6, i64 112, !11, i64 120, !6, i64 128}
!24 = !{!"", !11, i64 0}
!25 = !{!"", !14, i64 0, !14, i64 16, !13, i64 32}
!26 = !{!"_EFI_IP6_CONFIG_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!27 = !{!"_IP6_FORM_CALLBACK_INFO", !11, 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 = !{!"", !11, i64 0, !24, i64 4, !17, i64 8, !14, i64 16, !11, i64 32, !14, i64 40, !11, i64 56, !14, i64 64, !11, i64 80}
!30 = !{!13, !13, i64 0}
!31 = !{!10, !7, i64 2208}
!32 = !{!7, !7, i64 0}
!33 = !{!11, !11, i64 0}
!34 = !{!10, !6, i64 2264}
!35 = !{!36, !11, i64 28}
!36 = !{!"_IP6_PREFIX_LIST_ENTRY", !14, i64 0, !13, i64 16, !11, i64 24, !11, i64 28, !7, i64 32, !17, i64 33}
!37 = !{!36, !7, i64 32}
!38 = !{!14, !6, i64 0}
!39 = distinct !{!39, !40}
!40 = !{!"llvm.loop.mustprogress"}
!41 = !{!42, !11, i64 0}
!42 = !{!"_IP6_ADDRESS_INFO", !11, i64 0, !14, i64 8, !17, i64 24, !7, i64 40, !7, i64 41, !11, i64 44, !11, i64 48}
!43 = distinct !{!43, !40}


; 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._LIST_ENTRY = type { ptr, ptr }

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

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

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

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @Ip6CommonPrefixLen(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775791, 1) i64 @Ip6SelectSourceAddress(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct._LIST_ENTRY, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %6 = tail call zeroext i8 @DebugAssertEnabled() #4
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %12, label %7

7:                                                ; preds = %3
  %.not49 = icmp eq ptr %0, null
  br i1 %.not49, label %11, label %8

8:                                                ; preds = %7
  %9 = load i32, ptr %0, align 8, !tbaa !5
  %10 = icmp eq i32 %9, 1396068425
  br i1 %10, label %12, label %11

11:                                               ; preds = %8, %7
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 176, ptr noundef nonnull @.str.2) #4
  br label %12

12:                                               ; preds = %8, %11, %3
  %13 = call ptr @InitializeListHead(ptr noundef nonnull %4) #4
  %14 = getelementptr inbounds i8, ptr %0, i64 2208
  %15 = load i8, ptr %14, align 8, !tbaa !29
  %.not50 = icmp eq i8 %15, 0
  br i1 %.not50, label %66, label %16

16:                                               ; preds = %12
  %17 = call zeroext i8 @Ip6IsOneOfSetAddress(ptr noundef nonnull %0, ptr noundef %1, ptr noundef null, ptr noundef null) #4
  %.not51 = icmp eq i8 %17, 0
  br i1 %.not51, label %20, label %18

18:                                               ; preds = %16
  %19 = call ptr @CopyMem(ptr noundef %2, ptr noundef %1, i64 noundef 16) #4
  br label %.loopexit

20:                                               ; preds = %16
  %21 = load i8, ptr %1, align 1, !tbaa !30
  %22 = icmp eq i8 %21, -1
  br i1 %22, label %23, label %27

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %1, i64 1
  %25 = load i8, ptr %24, align 1, !tbaa !30
  %26 = icmp ult i8 %25, 48
  br i1 %26, label %29, label %32

27:                                               ; preds = %20
  %28 = call zeroext i8 @NetIp6IsLinkLocalAddr(ptr noundef nonnull %1) #4
  %.not52.not = icmp eq i8 %28, 0
  br i1 %.not52.not, label %32, label %29

29:                                               ; preds = %23, %27
  %30 = getelementptr inbounds i8, ptr %0, i64 2192
  %31 = call ptr @CopyMem(ptr noundef %2, ptr noundef nonnull %30, i64 noundef 16) #4
  br label %.loopexit

32:                                               ; preds = %23, %27
  %33 = call i64 @Ip6CandidateSource(ptr noundef nonnull %0, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %34 = load i32, ptr %5, align 4, !tbaa !31
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %.loopexit, label %36

36:                                               ; preds = %32
  %37 = getelementptr inbounds i8, ptr %0, i64 2192
  %38 = call ptr @CopyMem(ptr noundef %2, ptr noundef nonnull %37, i64 noundef 16) #4
  %39 = load i32, ptr %5, align 4, !tbaa !31
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %.loopexit, label %41

41:                                               ; preds = %36
  %42 = getelementptr inbounds i8, ptr %0, i64 2264
  %.04659 = load ptr, ptr %42, align 8, !tbaa !32
  %.not5360 = icmp eq ptr %.04659, %42
  br i1 %.not5360, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %41, %53
  %.04661 = phi ptr [ %.046, %53 ], [ %.04659, %41 ]
  %43 = getelementptr inbounds i8, ptr %.04661, i64 28
  %44 = load i32, ptr %43, align 4, !tbaa !33
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %53

46:                                               ; preds = %.lr.ph
  %47 = getelementptr inbounds i8, ptr %.04661, i64 33
  %48 = getelementptr inbounds i8, ptr %.04661, i64 32
  %49 = load i8, ptr %48, align 8, !tbaa !35
  %50 = call i64 @Ip6RemoveAddr(ptr noundef null, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %47, i8 noundef zeroext %49) #4
  %51 = load i32, ptr %5, align 4, !tbaa !31
  %52 = icmp eq i32 %51, 1
  br i1 %52, label %.loopexit, label %53

53:                                               ; preds = %.lr.ph, %46
  %.046 = load ptr, ptr %.04661, align 8, !tbaa !32
  %.not53 = icmp eq ptr %.046, %42
  br i1 %.not53, label %._crit_edge, label %.lr.ph, !llvm.loop !36

._crit_edge:                                      ; preds = %53, %41
  %54 = call zeroext i8 @Ip6CommonPrefixLen(ptr noundef %2, ptr noundef nonnull %1)
  %.14762 = load ptr, ptr %4, align 8, !tbaa !32
  %.not5463 = icmp eq ptr %.14762, %4
  br i1 %.not5463, label %.loopexit, label %.lr.ph68

.lr.ph68:                                         ; preds = %._crit_edge, %.lr.ph68._crit_edge
  %.14766 = phi ptr [ %.147, %.lr.ph68._crit_edge ], [ %.14762, %._crit_edge ]
  %.065 = phi ptr [ %spec.select58, %.lr.ph68._crit_edge ], [ null, %._crit_edge ]
  %.04264 = phi i8 [ %spec.select, %.lr.ph68._crit_edge ], [ %54, %._crit_edge ]
  %55 = call zeroext i8 @DebugAssertEnabled() #4
  %.not56 = icmp eq i8 %55, 0
  %.pre = ptrtoint ptr %.14766 to i64
  %.pre70 = add i64 %.pre, -8
  %.pre72 = inttoptr i64 %.pre70 to ptr
  br i1 %.not56, label %.lr.ph68._crit_edge, label %56

56:                                               ; preds = %.lr.ph68
  %57 = load i32, ptr %.pre72, align 8, !tbaa !38
  %.not57 = icmp eq i32 %57, 1229017161
  br i1 %.not57, label %.lr.ph68._crit_edge, label %58

58:                                               ; preds = %56
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 258, ptr noundef nonnull @.str.1) #4
  br label %.lr.ph68._crit_edge

.lr.ph68._crit_edge:                              ; preds = %.lr.ph68, %56, %58
  %59 = phi ptr [ %.14766, %58 ], [ %.pre72, %56 ], [ %.pre72, %.lr.ph68 ]
  %60 = getelementptr inbounds i8, ptr %59, i64 24
  %61 = call zeroext i8 @Ip6CommonPrefixLen(ptr noundef nonnull %60, ptr noundef nonnull %1)
  %62 = icmp ugt i8 %61, %.04264
  %spec.select = call i8 @llvm.umax.i8(i8 %61, i8 %.04264)
  %spec.select58 = select i1 %62, ptr %60, ptr %.065
  %.147 = load ptr, ptr %.14766, align 8, !tbaa !32
  %.not54 = icmp eq ptr %.147, %4
  br i1 %.not54, label %._crit_edge69, label %.lr.ph68, !llvm.loop !40

._crit_edge69:                                    ; preds = %.lr.ph68._crit_edge
  %.not55 = icmp eq ptr %spec.select58, null
  br i1 %.not55, label %.loopexit, label %63

63:                                               ; preds = %._crit_edge69
  %64 = call ptr @CopyMem(ptr noundef %2, ptr noundef nonnull %spec.select58, i64 noundef 16) #4
  br label %.loopexit

.loopexit:                                        ; preds = %46, %._crit_edge, %32, %._crit_edge69, %63, %36, %29, %18
  %.044 = phi i64 [ 0, %18 ], [ 0, %29 ], [ 0, %36 ], [ 0, %63 ], [ 0, %._crit_edge69 ], [ -9223372036854775791, %32 ], [ 0, %._crit_edge ], [ 0, %46 ]
  %65 = call i64 @Ip6RemoveAddr(ptr noundef null, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef null, i8 noundef zeroext 0) #4
  br label %66

66:                                               ; preds = %12, %.loopexit
  %.041 = phi i64 [ %.044, %.loopexit ], [ -9223372036854775791, %12 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  ret i64 %.041
}

declare ptr @InitializeListHead(ptr noundef) local_unnamed_addr #2

declare zeroext i8 @Ip6IsOneOfSetAddress(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i64 @Ip6RemoveAddr(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i8 @llvm.umax.i8(i8, i8) #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 nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"_IP6_SERVICE", !7, i64 0, !10, i64 8, !12, i64 24, !12, i64 32, !13, i64 40, !13, i64 56, !11, i64 72, !11, i64 80, !14, i64 88, !16, i64 136, !17, i64 2168, !16, i64 2192, !8, i64 2208, !8, i64 2209, !8, i64 2210, !8, i64 2211, !8, i64 2212, !7, i64 2216, !7, i64 2220, !7, i64 2224, !7, i64 2228, !13, i64 2232, !13, i64 2248, !13, i64 2264, !13, i64 2280, !7, i64 2296, !8, i64 2300, !11, i64 2304, !8, i64 2312, !8, i64 2313, !7, i64 2316, !11, i64 2320, !11, i64 2328, !11, i64 2336, !11, i64 2344, !18, i64 2352, !20, i64 2372, !11, i64 3032, !11, i64 3040, !21, i64 3048, !11, i64 4176, !7, i64 4184, !7, i64 4188}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!14 = !{!"", !7, i64 0, !11, i64 8, !11, i64 16, !15, i64 24}
!15 = !{!"", !11, i64 0, !12, i64 8, !8, i64 16}
!16 = !{!"", !8, i64 0}
!17 = !{!"", !12, i64 0, !13, i64 8}
!18 = !{!"", !7, i64 0, !7, i64 4, !19, i64 8, !8, i64 10, !8, i64 11, !8, i64 12, !8, i64 13, !8, i64 14, !8, i64 15, !8, i64 16}
!19 = !{!"short", !8, i64 0}
!20 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !8, i64 40, !16, i64 552, !16, i64 584, !16, i64 616, !8, i64 648, !8, i64 649, !8, i64 650, !8, i64 651, !8, i64 652}
!21 = !{!"_IP6_CONFIG_INSTANCE", !7, i64 0, !8, i64 4, !13, i64 8, !19, i64 24, !22, i64 32, !16, i64 168, !7, i64 176, !23, i64 180, !8, i64 184, !24, i64 800, !24, i64 840, !25, i64 880, !11, i64 912, !11, i64 920, !11, i64 928, !11, i64 936, !8, i64 944, !7, i64 948, !11, i64 952, !7, i64 960, !11, i64 968, !7, i64 976, !26, i64 984, !28, i64 1040}
!22 = !{!"", !8, i64 0, !8, i64 64, !7, i64 68, !16, i64 72, !7, i64 104, !11, i64 112, !7, i64 120, !11, i64 128}
!23 = !{!"", !7, i64 0}
!24 = !{!"", !13, i64 0, !13, i64 16, !12, i64 32}
!25 = !{!"_EFI_IP6_CONFIG_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!26 = !{!"_IP6_FORM_CALLBACK_INFO", !7, i64 0, !11, i64 8, !27, i64 16, !11, i64 40, !11, i64 48}
!27 = !{!"_EFI_HII_CONFIG_ACCESS_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16}
!28 = !{!"", !7, i64 0, !23, i64 4, !16, i64 8, !13, i64 16, !7, i64 32, !13, i64 40, !7, i64 56, !13, i64 64, !7, i64 80}
!29 = !{!6, !8, i64 2208}
!30 = !{!8, !8, i64 0}
!31 = !{!7, !7, i64 0}
!32 = !{!13, !11, i64 0}
!33 = !{!34, !7, i64 28}
!34 = !{!"_IP6_PREFIX_LIST_ENTRY", !13, i64 0, !12, i64 16, !7, i64 24, !7, i64 28, !8, i64 32, !16, i64 33}
!35 = !{!34, !8, i64 32}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!39, !7, i64 0}
!39 = !{!"_IP6_ADDRESS_INFO", !7, i64 0, !13, i64 8, !16, i64 24, !8, i64 40, !8, i64 41, !7, i64 44, !7, i64 48}
!40 = distinct !{!40, !37}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass