; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/IntelFrameworkModulePkg (Undi16SimpleNetworkReceiveFilters)

; 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.PXENV_UNDI_CLOSE_T = type { i16 }
%struct.PXENV_UNDI_OPEN_T = type { i16, i16, i16, %struct.PXENV_UNDI_MCAST_ADDR_T }
%struct.PXENV_UNDI_MCAST_ADDR_T = type { i16, [8 x [16 x i8]] }
%struct.EFI_SIMPLE_NETWORK_DEV = type { i64, ptr, %struct._EFI_SIMPLE_NETWORK_PROTOCOL, %struct.EFI_SIMPLE_NETWORK_MODE, %struct._EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL, ptr, ptr, ptr, i8, ptr, ptr, i16, i16, %struct.EFI_SIMPLE_NETWORK_DEV_FIFO, ptr, ptr, %struct.PXENV_UNDI_GET_INFORMATION_T, %struct.PXENV_UNDI_GET_NIC_TYPE_T, %struct.PXENV_UNDI_GET_NDIS_INFO_T, i8, %struct.PXENV_UNDI_ISR_T, ptr, ptr, ptr, ptr, i8, i64, i64, i64, i64, ptr, ptr, ptr, ptr }
%struct._EFI_SIMPLE_NETWORK_PROTOCOL = type { i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%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._EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL = type { i64, i64, i64, i32, [4 x i8], i8, i8, i8, i8, i16 }
%struct.EFI_SIMPLE_NETWORK_DEV_FIFO = type { i32, i32, [64 x ptr] }
%struct.PXENV_UNDI_GET_INFORMATION_T = type { i16, i16, i16, i16, i16, i16, [16 x i8], [16 x i8], i16, i16, i16 }
%struct.PXENV_UNDI_GET_NIC_TYPE_T = type <{ i16, i8, %union.PCI_PNP_INFO_T }>
%union.PCI_PNP_INFO_T = type { %struct.PCI_INFO_T }
%struct.PCI_INFO_T = type { i16, i16, i8, i8, i8, i8, i16, i16, i16 }
%struct.PXENV_UNDI_GET_NDIS_INFO_T = type <{ i16, [16 x i8], i32, i32, [4 x i32] }>
%struct.PXENV_UNDI_ISR_T = type { i16, i16, i16, i16, i16, i16, i16, i8, i8 }

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

; 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

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

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

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

23:                                               ; preds = %6
  store i64 -9223372036854775806, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

24:                                               ; preds = %6
  store i64 0, ptr %14, align 8, !tbaa !12
  %25 = call zeroext i8 @DebugAssertEnabled()
  %26 = zext i8 %25 to i32
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %38

28:                                               ; preds = %24
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = ptrtoint ptr %29 to i64
  %31 = sub i64 %30, ptrtoint (ptr getelementptr inbounds (%struct.EFI_SIMPLE_NETWORK_DEV, ptr null, i32 0, i32 2) to i64)
  %32 = inttoptr i64 %31 to ptr
  %33 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %32, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !14
  %35 = icmp ne i64 %34, 909209203
  br i1 %35, label %36, label %38

36:                                               ; preds = %28
  call void @DebugAssert(ptr noundef @.str.29, i64 noundef 2374, ptr noundef @.str.30)
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  br label %43

38:                                               ; preds = %28, %24
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = ptrtoint ptr %39 to i64
  %41 = sub i64 %40, ptrtoint (ptr getelementptr inbounds (%struct.EFI_SIMPLE_NETWORK_DEV, ptr null, i32 0, i32 2) to i64)
  %42 = inttoptr i64 %41 to ptr
  br label %43

43:                                               ; preds = %38, %36
  %44 = phi ptr [ %37, %36 ], [ %42, %38 ]
  store ptr %44, ptr %17, align 8, !tbaa !5
  %45 = load ptr, ptr %17, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %48

47:                                               ; preds = %43
  store i64 -9223372036854775801, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

48:                                               ; preds = %43
  %49 = load ptr, ptr %17, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %49, i32 0, i32 3
  %51 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !26
  switch i32 %52, label %55 [
    i32 0, label %53
    i32 2, label %56
    i32 1, label %54
  ]

53:                                               ; preds = %48
  store i64 -9223372036854775789, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

54:                                               ; preds = %48
  br label %55

55:                                               ; preds = %54, %48
  store i64 -9223372036854775801, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

56:                                               ; preds = %48
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = icmp eq i32 %57, 0
  br i1 %58, label %59, label %66

59:                                               ; preds = %56
  %60 = load i32, ptr %10, align 4, !tbaa !9
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %66

62:                                               ; preds = %59
  %63 = load i8, ptr %11, align 1, !tbaa !11
  %64 = icmp ne i8 %63, 0
  br i1 %64, label %66, label %65

65:                                               ; preds = %62
  store i64 0, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

66:                                               ; preds = %62, %59, %56
  %67 = load ptr, ptr %17, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %67, i32 0, i32 3
  %69 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %68, i32 0, i32 7
  %70 = load i32, ptr %69, align 4, !tbaa !27
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = or i32 %70, %71
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = xor i32 %73, -1
  %75 = and i32 %72, %74
  store i32 %75, ptr %16, align 4, !tbaa !9
  %76 = load i32, ptr %16, align 4, !tbaa !9
  %77 = and i32 %76, 2
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %95

79:                                               ; preds = %66
  %80 = load i64, ptr %12, align 8, !tbaa !12
  %81 = icmp eq i64 %80, 0
  br i1 %81, label %93, label %82

82:                                               ; preds = %79
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = icmp eq ptr %83, null
  br i1 %84, label %93, label %85

85:                                               ; preds = %82
  %86 = load i64, ptr %12, align 8, !tbaa !12
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %87, i32 0, i32 3
  %89 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %88, i32 0, i32 8
  %90 = load i32, ptr %89, align 8, !tbaa !28
  %91 = zext i32 %90 to i64
  %92 = icmp ugt i64 %86, %91
  br i1 %92, label %93, label %94

93:                                               ; preds = %85, %82, %79
  store i64 -9223372036854775806, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

94:                                               ; preds = %85
  br label %95

95:                                               ; preds = %94, %66
  %96 = getelementptr inbounds %struct.PXENV_UNDI_CLOSE_T, ptr %18, i32 0, i32 0
  store i16 -21555, ptr %96, align 1, !tbaa !29
  %97 = load ptr, ptr %17, align 8, !tbaa !5
  %98 = call i64 @PxeUndiClose(ptr noundef %97, ptr noundef %18)
  store i64 %98, ptr %14, align 8, !tbaa !12
  %99 = load i64, ptr %14, align 8, !tbaa !12
  %100 = icmp slt i64 %99, 0
  br i1 %100, label %101, label %103

101:                                              ; preds = %95
  %102 = load i64, ptr %14, align 8, !tbaa !12
  store i64 %102, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

103:                                              ; preds = %95
  %104 = getelementptr inbounds %struct.PXENV_UNDI_CLOSE_T, ptr %18, i32 0, i32 0
  %105 = load i16, ptr %104, align 1, !tbaa !29
  %106 = zext i16 %105 to i32
  %107 = icmp ne i32 %106, 0
  br i1 %107, label %108, label %109

108:                                              ; preds = %103
  store i64 -9223372036854775801, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

109:                                              ; preds = %103
  %110 = load ptr, ptr %17, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %110, i32 0, i32 13
  %112 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV_FIFO, ptr %111, i32 0, i32 0
  store i32 0, ptr %112, align 8, !tbaa !31
  %113 = load ptr, ptr %17, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %113, i32 0, i32 13
  %115 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV_FIFO, ptr %114, i32 0, i32 1
  store i32 0, ptr %115, align 4, !tbaa !32
  %116 = call ptr @ZeroMem(ptr noundef %19, i64 noundef 136)
  %117 = getelementptr inbounds %struct.PXENV_UNDI_OPEN_T, ptr %19, i32 0, i32 0
  store i16 -21555, ptr %117, align 1, !tbaa !33
  %118 = load i32, ptr %16, align 4, !tbaa !9
  %119 = zext i32 %118 to i64
  %120 = call zeroext i16 @Undi16GetPacketFilterSetting(i64 noundef %119)
  %121 = getelementptr inbounds %struct.PXENV_UNDI_OPEN_T, ptr %19, i32 0, i32 2
  store i16 %120, ptr %121, align 1, !tbaa !36
  %122 = load i32, ptr %16, align 4, !tbaa !9
  %123 = and i32 %122, 2
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %125, label %148

125:                                              ; preds = %109
  %126 = load i64, ptr %12, align 8, !tbaa !12
  %127 = trunc i64 %126 to i16
  %128 = getelementptr inbounds %struct.PXENV_UNDI_OPEN_T, ptr %19, i32 0, i32 3
  %129 = getelementptr inbounds %struct.PXENV_UNDI_MCAST_ADDR_T, ptr %128, i32 0, i32 0
  store i16 %127, ptr %129, align 1, !tbaa !37
  store i64 0, ptr %15, align 8, !tbaa !12
  br label %130

130:                                              ; preds = %144, %125
  %131 = load i64, ptr %15, align 8, !tbaa !12
  %132 = load i64, ptr %12, align 8, !tbaa !12
  %133 = icmp ult i64 %131, %132
  br i1 %133, label %134, label %147

134:                                              ; preds = %130
  %135 = getelementptr inbounds %struct.PXENV_UNDI_OPEN_T, ptr %19, i32 0, i32 3
  %136 = getelementptr inbounds %struct.PXENV_UNDI_MCAST_ADDR_T, ptr %135, i32 0, i32 1
  %137 = load i64, ptr %15, align 8, !tbaa !12
  %138 = getelementptr inbounds [8 x [16 x i8]], ptr %136, i64 0, i64 %137
  %139 = getelementptr inbounds [16 x i8], ptr %138, i64 0, i64 0
  %140 = load ptr, ptr %13, align 8, !tbaa !5
  %141 = load i64, ptr %15, align 8, !tbaa !12
  %142 = getelementptr inbounds %struct.EFI_MAC_ADDRESS, ptr %140, i64 %141
  %143 = call ptr @CopyMem(ptr noundef %139, ptr noundef %142, i64 noundef 16)
  br label %144

144:                                              ; preds = %134
  %145 = load i64, ptr %15, align 8, !tbaa !12
  %146 = add i64 %145, 1
  store i64 %146, ptr %15, align 8, !tbaa !12
  br label %130, !llvm.loop !38

147:                                              ; preds = %130
  br label %177

148:                                              ; preds = %109
  %149 = load i8, ptr %11, align 1, !tbaa !11
  %150 = icmp ne i8 %149, 0
  br i1 %150, label %176, label %151

151:                                              ; preds = %148
  store i64 0, ptr %15, align 8, !tbaa !12
  br label %152

152:                                              ; preds = %172, %151
  %153 = load i64, ptr %15, align 8, !tbaa !12
  %154 = load ptr, ptr %17, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %154, i32 0, i32 3
  %156 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %155, i32 0, i32 9
  %157 = load i32, ptr %156, align 4, !tbaa !40
  %158 = zext i32 %157 to i64
  %159 = icmp ult i64 %153, %158
  br i1 %159, label %160, label %175

160:                                              ; preds = %152
  %161 = getelementptr inbounds %struct.PXENV_UNDI_OPEN_T, ptr %19, i32 0, i32 3
  %162 = getelementptr inbounds %struct.PXENV_UNDI_MCAST_ADDR_T, ptr %161, i32 0, i32 1
  %163 = load i64, ptr %15, align 8, !tbaa !12
  %164 = getelementptr inbounds [8 x [16 x i8]], ptr %162, i64 0, i64 %163
  %165 = getelementptr inbounds [16 x i8], ptr %164, i64 0, i64 0
  %166 = load ptr, ptr %17, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %166, i32 0, i32 3
  %168 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %167, i32 0, i32 10
  %169 = load i64, ptr %15, align 8, !tbaa !12
  %170 = getelementptr inbounds [16 x %struct.EFI_MAC_ADDRESS], ptr %168, i64 0, i64 %169
  %171 = call ptr @CopyMem(ptr noundef %165, ptr noundef %170, i64 noundef 16)
  br label %172

172:                                              ; preds = %160
  %173 = load i64, ptr %15, align 8, !tbaa !12
  %174 = add i64 %173, 1
  store i64 %174, ptr %15, align 8, !tbaa !12
  br label %152, !llvm.loop !41

175:                                              ; preds = %152
  br label %176

176:                                              ; preds = %175, %148
  br label %177

177:                                              ; preds = %176, %147
  %178 = load ptr, ptr %17, align 8, !tbaa !5
  %179 = call i64 @PxeUndiOpen(ptr noundef %178, ptr noundef %19)
  store i64 %179, ptr %14, align 8, !tbaa !12
  %180 = load i64, ptr %14, align 8, !tbaa !12
  %181 = icmp slt i64 %180, 0
  br i1 %181, label %182, label %184

182:                                              ; preds = %177
  %183 = load i64, ptr %14, align 8, !tbaa !12
  store i64 %183, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

184:                                              ; preds = %177
  %185 = getelementptr inbounds %struct.PXENV_UNDI_OPEN_T, ptr %19, i32 0, i32 0
  %186 = load i16, ptr %185, align 1, !tbaa !33
  %187 = zext i16 %186 to i32
  %188 = icmp ne i32 %187, 0
  br i1 %188, label %189, label %190

189:                                              ; preds = %184
  store i64 -9223372036854775801, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

190:                                              ; preds = %184
  %191 = load ptr, ptr %17, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %191, i32 0, i32 19
  store i8 0, ptr %192, align 1, !tbaa !42
  %193 = load i32, ptr %16, align 4, !tbaa !9
  %194 = load ptr, ptr %17, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %194, i32 0, i32 3
  %196 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %195, i32 0, i32 7
  store i32 %193, ptr %196, align 4, !tbaa !27
  %197 = load i32, ptr %16, align 4, !tbaa !9
  %198 = and i32 %197, 2
  %199 = icmp ne i32 %198, 0
  br i1 %199, label %200, label %224

200:                                              ; preds = %190
  %201 = load i64, ptr %12, align 8, !tbaa !12
  %202 = trunc i64 %201 to i32
  %203 = load ptr, ptr %17, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %203, i32 0, i32 3
  %205 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %204, i32 0, i32 9
  store i32 %202, ptr %205, align 4, !tbaa !40
  store i64 0, ptr %15, align 8, !tbaa !12
  br label %206

206:                                              ; preds = %220, %200
  %207 = load i64, ptr %15, align 8, !tbaa !12
  %208 = load i64, ptr %12, align 8, !tbaa !12
  %209 = icmp ult i64 %207, %208
  br i1 %209, label %210, label %223

210:                                              ; preds = %206
  %211 = load ptr, ptr %17, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_DEV, ptr %211, i32 0, i32 3
  %213 = getelementptr inbounds %struct.EFI_SIMPLE_NETWORK_MODE, ptr %212, i32 0, i32 10
  %214 = load i64, ptr %15, align 8, !tbaa !12
  %215 = getelementptr inbounds [16 x %struct.EFI_MAC_ADDRESS], ptr %213, i64 0, i64 %214
  %216 = load ptr, ptr %13, align 8, !tbaa !5
  %217 = load i64, ptr %15, align 8, !tbaa !12
  %218 = getelementptr inbounds %struct.EFI_MAC_ADDRESS, ptr %216, i64 %217
  %219 = call ptr @CopyMem(ptr noundef %215, ptr noundef %218, i64 noundef 32)
  br label %220

220:                                              ; preds = %210
  %221 = load i64, ptr %15, align 8, !tbaa !12
  %222 = add i64 %221, 1
  store i64 %222, ptr %15, align 8, !tbaa !12
  br label %206, !llvm.loop !43

223:                                              ; preds = %206
  br label %224

224:                                              ; preds = %223, %190
  store i64 0, ptr %7, align 8
  store i32 1, ptr %20, align 4
  br label %225

225:                                              ; preds = %224, %189, %182, %108, %101, %93, %65, %55, %53, %47, %23
  call void @llvm.lifetime.end.p0(i64 136, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %226 = load i64, ptr %7, align 8
  ret i64 %226
}

declare zeroext i8 @DebugAssertEnabled() #1

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i16 @Undi16GetPacketFilterSetting(i64 noundef) #2

declare i64 @PxeUndiOpen(ptr noundef, ptr noundef) #1

declare i64 @PxeUndiClose(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"", !13, i64 0, !6, i64 8, !16, i64 16, !17, i64 144, !19, i64 800, !6, i64 840, !6, i64 848, !6, i64 856, !7, i64 864, !6, i64 872, !6, i64 880, !20, i64 888, !20, i64 890, !21, i64 896, !6, i64 1416, !6, i64 1424, !22, i64 1432, !23, i64 1482, !24, i64 1499, !7, i64 1541, !25, i64 1542, !6, i64 1560, !6, i64 1568, !6, i64 1576, !6, i64 1584, !7, i64 1592, !13, i64 1600, !13, i64 1608, !13, i64 1616, !13, i64 1624, !6, i64 1632, !6, i64 1640, !6, i64 1648, !6, i64 1656}
!16 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !13, i64 0, !6, i64 8, !6, i64 16, !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}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !18, i64 552, !18, i64 584, !18, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!18 = !{!"", !7, i64 0}
!19 = !{!"_EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL", !13, i64 0, !13, i64 8, !13, i64 16, !10, i64 24, !7, i64 28, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !20, i64 36}
!20 = !{!"short", !7, i64 0}
!21 = !{!"", !10, i64 0, !10, i64 4, !7, i64 8}
!22 = !{!"", !20, i64 0, !20, i64 2, !20, i64 4, !20, i64 6, !20, i64 8, !20, i64 10, !7, i64 12, !7, i64 28, !20, i64 44, !20, i64 46, !20, i64 48}
!23 = !{!"", !20, i64 0, !7, i64 2, !7, i64 3}
!24 = !{!"", !20, i64 0, !7, i64 2, !10, i64 18, !10, i64 22, !7, i64 26}
!25 = !{!"", !20, i64 0, !20, i64 2, !20, i64 4, !20, i64 6, !20, i64 8, !20, i64 10, !20, i64 12, !7, i64 14, !7, i64 15}
!26 = !{!15, !10, i64 144}
!27 = !{!15, !10, i64 172}
!28 = !{!15, !10, i64 176}
!29 = !{!30, !20, i64 0}
!30 = !{!"", !20, i64 0}
!31 = !{!15, !10, i64 896}
!32 = !{!15, !10, i64 900}
!33 = !{!34, !20, i64 0}
!34 = !{!"", !20, i64 0, !20, i64 2, !20, i64 4, !35, i64 6}
!35 = !{!"", !20, i64 0, !7, i64 2}
!36 = !{!34, !20, i64 4}
!37 = !{!34, !20, i64 6}
!38 = distinct !{!38, !39}
!39 = !{!"llvm.loop.mustprogress"}
!40 = !{!15, !10, i64 180}
!41 = distinct !{!41, !39}
!42 = !{!15, !7, i64 1541}
!43 = distinct !{!43, !39}


; 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.PXENV_UNDI_CLOSE_T = type { i16 }
%struct.PXENV_UNDI_OPEN_T = type { i16, i16, i16, %struct.PXENV_UNDI_MCAST_ADDR_T }
%struct.PXENV_UNDI_MCAST_ADDR_T = type { i16, [8 x [16 x i8]] }
%struct.EFI_MAC_ADDRESS = type { [32 x i8] }

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

; 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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775808, 1) i64 @Undi16SimpleNetworkReceiveFilters(ptr noundef %0, i32 noundef %1, i32 noundef %2, i8 noundef zeroext %3, i64 noundef %4, ptr noundef %5) local_unnamed_addr #2 {
  %7 = alloca %struct.PXENV_UNDI_CLOSE_T, align 2
  %8 = alloca %struct.PXENV_UNDI_OPEN_T, align 2
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 136, ptr nonnull %8) #3
  %9 = icmp eq ptr %0, null
  br i1 %9, label %.loopexit, label %10

10:                                               ; preds = %6
  %11 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not = icmp eq i8 %11, 0
  %.pre = ptrtoint ptr %0 to i64
  %.pre81 = add i64 %.pre, -16
  %.pre83 = inttoptr i64 %.pre81 to ptr
  br i1 %.not, label %._crit_edge, label %12

12:                                               ; preds = %10
  %13 = load i64, ptr %.pre83, align 8, !tbaa !5
  %.not65 = icmp eq i64 %13, 909209203
  br i1 %.not65, label %._crit_edge, label %.thread

.thread:                                          ; preds = %12
  tail call void @DebugAssert(ptr noundef nonnull @.str.29, i64 noundef 2374, ptr noundef nonnull @.str.30) #3
  br label %15

._crit_edge:                                      ; preds = %10, %12
  %14 = icmp eq i64 %.pre81, 0
  br i1 %14, label %.loopexit, label %15

15:                                               ; preds = %.thread, %._crit_edge
  %16 = phi ptr [ %0, %.thread ], [ %.pre83, %._crit_edge ]
  %17 = getelementptr inbounds i8, ptr %16, i64 144
  %18 = load i32, ptr %17, align 8, !tbaa !22
  switch i32 %18, label %19 [
    i32 0, label %.loopexit
    i32 2, label %20
  ]

19:                                               ; preds = %15
  br label %.loopexit

20:                                               ; preds = %15
  %21 = or i32 %2, %1
  %or.cond = icmp ne i32 %21, 0
  %22 = icmp ne i8 %3, 0
  %or.cond3 = or i1 %or.cond, %22
  br i1 %or.cond3, label %23, label %.loopexit

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %16, i64 172
  %25 = load i32, ptr %24, align 4, !tbaa !23
  %26 = or i32 %25, %1
  %27 = xor i32 %2, -1
  %28 = and i32 %26, %27
  %29 = and i32 %28, 2
  %.not66 = icmp eq i32 %29, 0
  br i1 %.not66, label %38, label %30

30:                                               ; preds = %23
  %31 = icmp eq i64 %4, 0
  %32 = icmp eq ptr %5, null
  %or.cond5 = or i1 %31, %32
  br i1 %or.cond5, label %.loopexit, label %33

33:                                               ; preds = %30
  %34 = getelementptr inbounds i8, ptr %16, i64 176
  %35 = load i32, ptr %34, align 8, !tbaa !24
  %36 = zext i32 %35 to i64
  %37 = icmp ult i64 %36, %4
  br i1 %37, label %.loopexit, label %38

38:                                               ; preds = %33, %23
  store i16 -21555, ptr %7, align 2, !tbaa !25
  %39 = call i64 @PxeUndiClose(ptr noundef nonnull %16, ptr noundef nonnull %7) #3
  %40 = icmp slt i64 %39, 0
  br i1 %40, label %.loopexit, label %41

41:                                               ; preds = %38
  %42 = load i16, ptr %7, align 2, !tbaa !25
  %.not67 = icmp eq i16 %42, 0
  br i1 %.not67, label %43, label %.loopexit

43:                                               ; preds = %41
  %44 = getelementptr inbounds i8, ptr %16, i64 896
  store i32 0, ptr %44, align 8, !tbaa !27
  %45 = getelementptr inbounds i8, ptr %16, i64 900
  store i32 0, ptr %45, align 4, !tbaa !28
  %46 = call ptr @ZeroMem(ptr noundef nonnull %8, i64 noundef 136) #3
  store i16 -21555, ptr %8, align 2, !tbaa !29
  %47 = zext i32 %28 to i64
  %48 = call zeroext i16 @Undi16GetPacketFilterSetting(i64 noundef %47)
  %49 = getelementptr inbounds i8, ptr %8, i64 4
  store i16 %48, ptr %49, align 2, !tbaa !32
  br i1 %.not66, label %59, label %50

50:                                               ; preds = %43
  %51 = trunc i64 %4 to i16
  %52 = getelementptr inbounds i8, ptr %8, i64 6
  store i16 %51, ptr %52, align 2, !tbaa !33
  %.not76 = icmp eq i64 %4, 0
  br i1 %.not76, label %.loopexit69, label %.lr.ph

.lr.ph:                                           ; preds = %50
  %53 = getelementptr inbounds i8, ptr %8, i64 8
  br label %54

54:                                               ; preds = %.lr.ph, %54
  %.05971 = phi i64 [ 0, %.lr.ph ], [ %58, %54 ]
  %55 = getelementptr inbounds [8 x [16 x i8]], ptr %53, i64 0, i64 %.05971
  %56 = getelementptr inbounds %struct.EFI_MAC_ADDRESS, ptr %5, i64 %.05971
  %57 = call ptr @CopyMem(ptr noundef nonnull %55, ptr noundef %56, i64 noundef 16) #3
  %58 = add nuw i64 %.05971, 1
  %exitcond.not = icmp eq i64 %58, %4
  br i1 %exitcond.not, label %.loopexit69, label %54, !llvm.loop !34

59:                                               ; preds = %43
  br i1 %22, label %.loopexit69, label %.preheader

.preheader:                                       ; preds = %59
  %60 = getelementptr inbounds i8, ptr %16, i64 180
  %61 = load i32, ptr %60, align 4, !tbaa !36
  %.not77 = icmp eq i32 %61, 0
  br i1 %.not77, label %.loopexit69, label %.lr.ph73

.lr.ph73:                                         ; preds = %.preheader
  %62 = getelementptr inbounds i8, ptr %8, i64 8
  %63 = getelementptr inbounds i8, ptr %16, i64 184
  br label %64

64:                                               ; preds = %.lr.ph73, %64
  %.172 = phi i64 [ 0, %.lr.ph73 ], [ %68, %64 ]
  %65 = getelementptr inbounds [8 x [16 x i8]], ptr %62, i64 0, i64 %.172
  %66 = getelementptr inbounds [16 x %struct.EFI_MAC_ADDRESS], ptr %63, i64 0, i64 %.172
  %67 = call ptr @CopyMem(ptr noundef nonnull %65, ptr noundef nonnull %66, i64 noundef 16) #3
  %68 = add nuw nsw i64 %.172, 1
  %69 = load i32, ptr %60, align 4, !tbaa !36
  %70 = zext i32 %69 to i64
  %71 = icmp ult i64 %68, %70
  br i1 %71, label %64, label %.loopexit69, !llvm.loop !37

.loopexit69:                                      ; preds = %54, %64, %50, %.preheader, %59
  %72 = call i64 @PxeUndiOpen(ptr noundef nonnull %16, ptr noundef nonnull %8) #3
  %73 = icmp slt i64 %72, 0
  br i1 %73, label %.loopexit, label %74

74:                                               ; preds = %.loopexit69
  %75 = load i16, ptr %8, align 2, !tbaa !29
  %.not68 = icmp eq i16 %75, 0
  br i1 %.not68, label %76, label %.loopexit

76:                                               ; preds = %74
  %77 = getelementptr inbounds i8, ptr %16, i64 1541
  store i8 0, ptr %77, align 1, !tbaa !38
  store i32 %28, ptr %24, align 4, !tbaa !23
  br i1 %.not66, label %.loopexit, label %78

78:                                               ; preds = %76
  %79 = trunc i64 %4 to i32
  %80 = getelementptr inbounds i8, ptr %16, i64 180
  store i32 %79, ptr %80, align 4, !tbaa !36
  %.not78 = icmp eq i64 %4, 0
  br i1 %.not78, label %.loopexit, label %.lr.ph75

.lr.ph75:                                         ; preds = %78
  %81 = getelementptr inbounds i8, ptr %16, i64 184
  br label %82

82:                                               ; preds = %.lr.ph75, %82
  %.274 = phi i64 [ 0, %.lr.ph75 ], [ %86, %82 ]
  %83 = getelementptr inbounds [16 x %struct.EFI_MAC_ADDRESS], ptr %81, i64 0, i64 %.274
  %84 = getelementptr inbounds %struct.EFI_MAC_ADDRESS, ptr %5, i64 %.274
  %85 = call ptr @CopyMem(ptr noundef nonnull %83, ptr noundef %84, i64 noundef 32) #3
  %86 = add nuw i64 %.274, 1
  %exitcond80.not = icmp eq i64 %86, %4
  br i1 %exitcond80.not, label %.loopexit, label %82, !llvm.loop !39

.loopexit:                                        ; preds = %82, %78, %76, %74, %.loopexit69, %41, %38, %30, %33, %20, %15, %._crit_edge, %6, %19
  %.0 = phi i64 [ -9223372036854775801, %19 ], [ -9223372036854775806, %6 ], [ -9223372036854775801, %._crit_edge ], [ -9223372036854775789, %15 ], [ 0, %20 ], [ -9223372036854775806, %33 ], [ -9223372036854775806, %30 ], [ %39, %38 ], [ -9223372036854775801, %41 ], [ %72, %.loopexit69 ], [ -9223372036854775801, %74 ], [ 0, %76 ], [ 0, %78 ], [ 0, %82 ]
  call void @llvm.lifetime.end.p0(i64 136, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %7) #3
  ret i64 %.0
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i16 @Undi16GetPacketFilterSetting(i64 noundef) local_unnamed_addr #2

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 16, !12, i64 144, !15, i64 800, !10, i64 840, !10, i64 848, !10, i64 856, !8, i64 864, !10, i64 872, !10, i64 880, !16, i64 888, !16, i64 890, !17, i64 896, !10, i64 1416, !10, i64 1424, !18, i64 1432, !19, i64 1482, !20, i64 1499, !8, i64 1541, !21, i64 1542, !10, i64 1560, !10, i64 1568, !10, i64 1576, !10, i64 1584, !8, i64 1592, !7, i64 1600, !7, i64 1608, !7, i64 1616, !7, i64 1624, !10, i64 1632, !10, i64 1640, !10, i64 1648, !10, i64 1656}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_EFI_SIMPLE_NETWORK_PROTOCOL", !7, i64 0, !10, i64 8, !10, i64 16, !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}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !8, i64 40, !14, i64 552, !14, i64 584, !14, i64 616, !8, i64 648, !8, i64 649, !8, i64 650, !8, i64 651, !8, i64 652}
!13 = !{!"int", !8, i64 0}
!14 = !{!"", !8, i64 0}
!15 = !{!"_EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL", !7, i64 0, !7, i64 8, !7, i64 16, !13, i64 24, !8, i64 28, !8, i64 32, !8, i64 33, !8, i64 34, !8, i64 35, !16, i64 36}
!16 = !{!"short", !8, i64 0}
!17 = !{!"", !13, i64 0, !13, i64 4, !8, i64 8}
!18 = !{!"", !16, i64 0, !16, i64 2, !16, i64 4, !16, i64 6, !16, i64 8, !16, i64 10, !8, i64 12, !8, i64 28, !16, i64 44, !16, i64 46, !16, i64 48}
!19 = !{!"", !16, i64 0, !8, i64 2, !8, i64 3}
!20 = !{!"", !16, i64 0, !8, i64 2, !13, i64 18, !13, i64 22, !8, i64 26}
!21 = !{!"", !16, i64 0, !16, i64 2, !16, i64 4, !16, i64 6, !16, i64 8, !16, i64 10, !16, i64 12, !8, i64 14, !8, i64 15}
!22 = !{!6, !13, i64 144}
!23 = !{!6, !13, i64 172}
!24 = !{!6, !13, i64 176}
!25 = !{!26, !16, i64 0}
!26 = !{!"", !16, i64 0}
!27 = !{!6, !13, i64 896}
!28 = !{!6, !13, i64 900}
!29 = !{!30, !16, i64 0}
!30 = !{!"", !16, i64 0, !16, i64 2, !16, i64 4, !31, i64 6}
!31 = !{!"", !16, i64 0, !8, i64 2}
!32 = !{!30, !16, i64 4}
!33 = !{!30, !16, i64 6}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = !{!6, !13, i64 180}
!37 = distinct !{!37, !35}
!38 = !{!6, !8, i64 1541}
!39 = distinct !{!39, !35}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass