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

; 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.EFI_BOOT_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, 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._EFI_DRIVER_BINDING_PROTOCOL = type { ptr, ptr, ptr, i32, ptr, ptr }
%struct.UNDI32_DEV = type { i64, %struct._EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL, ptr, ptr, ptr, %struct.s_data_instance }
%struct._EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL = type { i64, i64, i64, i32, [4 x i8], i8, i8, i8, i8, i16 }
%struct.s_data_instance = type { i16, i16, i8, i8, i16, i16, i16, i16, i16, [32 x i8], [32 x i8], [32 x i8], [64 x i32], [128 x i32], i32, i32, i16, i16, i8, i8, i8, i8, i16, i16, i16, i16, i32, i32, i16, i16, [2 x i16], i8, i8, i16, i32, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i64, [64 x i64], i16, i16, i16, i16, i8, i8, i8, i8, i8, [3 x i8], %struct.mc, i64, ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.mc = type { [3 x i16], i16, [8 x [32 x i8]] }
%struct._EFI_PCI_IO_PROTOCOL = type { ptr, ptr, %struct.EFI_PCI_IO_PROTOCOL_ACCESS, %struct.EFI_PCI_IO_PROTOCOL_ACCESS, %struct.EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr }
%struct.EFI_PCI_IO_PROTOCOL_ACCESS = type { ptr, ptr }
%struct.EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS = type { ptr, ptr }

@gBS = external global ptr, align 8
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@gEfiPciIoProtocolGuid = external global %struct.GUID, align 4
@gEfiNetworkInterfaceIdentifierProtocolGuid_31 = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [136 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

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

18:                                               ; preds = %4
  %19 = load ptr, ptr @gBS, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %19, i32 0, i32 34
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %23, i32 0, i32 5
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = call i64 %21(ptr noundef %22, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %25, ptr noundef %26)
  store i64 %27, ptr %10, align 8, !tbaa !9
  %28 = load ptr, ptr @gBS, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %28, i32 0, i32 34
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %32, i32 0, i32 5
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = call i64 %30(ptr noundef %31, ptr noundef @gEfiPciIoProtocolGuid, ptr noundef %34, ptr noundef %35)
  store i64 %36, ptr %10, align 8, !tbaa !9
  %37 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %37, ptr %5, align 8
  store i32 1, ptr %15, align 4
  br label %178

38:                                               ; preds = %4
  store i8 1, ptr %11, align 1, !tbaa !17
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %170, %38
  %40 = load i64, ptr %12, align 8, !tbaa !9
  %41 = load i64, ptr %8, align 8, !tbaa !9
  %42 = icmp ult i64 %40, %41
  br i1 %42, label %43, label %173

43:                                               ; preds = %39
  %44 = load ptr, ptr @gBS, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %44, i32 0, i32 33
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = load i64, ptr %12, align 8, !tbaa !9
  %49 = getelementptr inbounds ptr, ptr %47, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %51, i32 0, i32 5
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = call i64 %46(ptr noundef %50, ptr noundef @gEfiNetworkInterfaceIdentifierProtocolGuid_31, ptr noundef %14, ptr noundef %53, ptr noundef %54, i32 noundef 2)
  store i64 %55, ptr %10, align 8, !tbaa !9
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = icmp slt i64 %56, 0
  br i1 %57, label %165, label %58

58:                                               ; preds = %43
  %59 = call zeroext i8 @DebugAssertEnabled()
  %60 = zext i8 %59 to i32
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %72

62:                                               ; preds = %58
  %63 = load ptr, ptr %14, align 8, !tbaa !5
  %64 = ptrtoint ptr %63 to i64
  %65 = sub i64 %64, ptrtoint (ptr getelementptr inbounds (%struct.UNDI32_DEV, ptr null, i32 0, i32 1) to i64)
  %66 = inttoptr i64 %65 to ptr
  %67 = getelementptr inbounds %struct.UNDI32_DEV, ptr %66, i32 0, i32 0
  %68 = load i64, ptr %67, align 8, !tbaa !19
  %69 = icmp ne i64 %68, 1768189557
  br i1 %69, label %70, label %72

70:                                               ; preds = %62
  call void @DebugAssert(ptr noundef @.str, i64 noundef 617, ptr noundef @.str.1)
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  br label %77

72:                                               ; preds = %62, %58
  %73 = load ptr, ptr %14, align 8, !tbaa !5
  %74 = ptrtoint ptr %73 to i64
  %75 = sub i64 %74, ptrtoint (ptr getelementptr inbounds (%struct.UNDI32_DEV, ptr null, i32 0, i32 1) to i64)
  %76 = inttoptr i64 %75 to ptr
  br label %77

77:                                               ; preds = %72, %70
  %78 = phi ptr [ %71, %70 ], [ %76, %72 ]
  store ptr %78, ptr %13, align 8, !tbaa !5
  %79 = load ptr, ptr @gBS, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %79, i32 0, i32 34
  %81 = load ptr, ptr %80, align 8, !tbaa !11
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %83, i32 0, i32 5
  %85 = load ptr, ptr %84, align 8, !tbaa !15
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = load i64, ptr %12, align 8, !tbaa !9
  %88 = getelementptr inbounds ptr, ptr %86, i64 %87
  %89 = load ptr, ptr %88, align 8, !tbaa !5
  %90 = call i64 %81(ptr noundef %82, ptr noundef @gEfiPciIoProtocolGuid, ptr noundef %85, ptr noundef %89)
  store i64 %90, ptr %10, align 8, !tbaa !9
  %91 = load i64, ptr %10, align 8, !tbaa !9
  %92 = icmp slt i64 %91, 0
  br i1 %92, label %164, label %93

93:                                               ; preds = %77
  %94 = load ptr, ptr @gBS, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %94, i32 0, i32 40
  %96 = load ptr, ptr %95, align 8, !tbaa !25
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = load i64, ptr %12, align 8, !tbaa !9
  %99 = getelementptr inbounds ptr, ptr %97, i64 %98
  %100 = load ptr, ptr %99, align 8, !tbaa !5
  %101 = load ptr, ptr %13, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.UNDI32_DEV, ptr %101, i32 0, i32 4
  %103 = load ptr, ptr %102, align 8, !tbaa !26
  %104 = load ptr, ptr %13, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.UNDI32_DEV, ptr %104, i32 0, i32 1
  %106 = call i64 (ptr, ...) %96(ptr noundef %100, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %103, ptr noundef @gEfiNetworkInterfaceIdentifierProtocolGuid_31, ptr noundef %105, ptr noundef null)
  store i64 %106, ptr %10, align 8, !tbaa !9
  %107 = load i64, ptr %10, align 8, !tbaa !9
  %108 = icmp slt i64 %107, 0
  br i1 %108, label %163, label %109

109:                                              ; preds = %93
  %110 = load ptr, ptr %13, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.UNDI32_DEV, ptr %110, i32 0, i32 5
  %112 = getelementptr inbounds %struct.s_data_instance, ptr %111, i32 0, i32 59
  %113 = load ptr, ptr %112, align 8, !tbaa !27
  %114 = getelementptr inbounds %struct._EFI_PCI_IO_PROTOCOL, ptr %113, i32 0, i32 12
  %115 = load ptr, ptr %114, align 8, !tbaa !28
  %116 = load ptr, ptr %13, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.UNDI32_DEV, ptr %116, i32 0, i32 5
  %118 = getelementptr inbounds %struct.s_data_instance, ptr %117, i32 0, i32 59
  %119 = load ptr, ptr %118, align 8, !tbaa !27
  %120 = load ptr, ptr %13, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.UNDI32_DEV, ptr %120, i32 0, i32 5
  %122 = getelementptr inbounds %struct.s_data_instance, ptr %121, i32 0, i32 60
  %123 = load i64, ptr %122, align 8, !tbaa !31
  %124 = call i64 %115(ptr noundef %119, i32 noundef 1, i64 noundef %123, ptr noundef null)
  store i64 %124, ptr %10, align 8, !tbaa !9
  br label %125

125:                                              ; preds = %109
  %126 = call zeroext i8 @DebugAssertEnabled()
  %127 = icmp ne i8 %126, 0
  br i1 %127, label %128, label %148

128:                                              ; preds = %125
  %129 = load i64, ptr %10, align 8, !tbaa !9
  %130 = icmp slt i64 %129, 0
  br i1 %130, label %131, label %147

131:                                              ; preds = %128
  br label %132

132:                                              ; preds = %131
  %133 = call zeroext i8 @DebugPrintEnabled()
  %134 = icmp ne i8 %133, 0
  br i1 %134, label %135, label %144

135:                                              ; preds = %132
  br label %136

136:                                              ; preds = %135
  %137 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %138 = icmp ne i8 %137, 0
  br i1 %138, label %139, label %141

139:                                              ; preds = %136
  %140 = load i64, ptr %10, align 8, !tbaa !9
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.2, i64 noundef %140)
  br label %141

141:                                              ; preds = %139, %136
  br label %142

142:                                              ; preds = %141
  br label %143

143:                                              ; preds = %142
  br label %144

144:                                              ; preds = %143, %132
  br label %145

145:                                              ; preds = %144
  br label %146

146:                                              ; preds = %145
  call void @DebugAssert(ptr noundef @.str, i64 noundef 645, ptr noundef @.str.3)
  br label %147

147:                                              ; preds = %146, %128
  br label %148

148:                                              ; preds = %147, %125
  br label %149

149:                                              ; preds = %148
  br label %150

150:                                              ; preds = %149
  %151 = load ptr, ptr @gBS, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %151, i32 0, i32 7
  %153 = load ptr, ptr %152, align 8, !tbaa !32
  %154 = load ptr, ptr %13, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.UNDI32_DEV, ptr %154, i32 0, i32 4
  %156 = load ptr, ptr %155, align 8, !tbaa !26
  %157 = call i64 %153(ptr noundef %156)
  %158 = load ptr, ptr @gBS, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %158, i32 0, i32 7
  %160 = load ptr, ptr %159, align 8, !tbaa !32
  %161 = load ptr, ptr %13, align 8, !tbaa !5
  %162 = call i64 %160(ptr noundef %161)
  br label %163

163:                                              ; preds = %150, %93
  br label %164

164:                                              ; preds = %163, %77
  br label %165

165:                                              ; preds = %164, %43
  %166 = load i64, ptr %10, align 8, !tbaa !9
  %167 = icmp slt i64 %166, 0
  br i1 %167, label %168, label %169

168:                                              ; preds = %165
  store i8 0, ptr %11, align 1, !tbaa !17
  br label %169

169:                                              ; preds = %168, %165
  br label %170

170:                                              ; preds = %169
  %171 = load i64, ptr %12, align 8, !tbaa !9
  %172 = add i64 %171, 1
  store i64 %172, ptr %12, align 8, !tbaa !9
  br label %39, !llvm.loop !33

173:                                              ; preds = %39
  %174 = load i8, ptr %11, align 1, !tbaa !17
  %175 = icmp ne i8 %174, 0
  br i1 %175, label %177, label %176

176:                                              ; preds = %173
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %15, align 4
  br label %178

177:                                              ; preds = %173
  store i64 0, ptr %5, align 8
  store i32 1, ptr %15, align 4
  br label %178

178:                                              ; preds = %177, %176, %18
  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 8, ptr %10) #3
  %179 = load i64, ptr %5, align 8
  ret i64 %179
}

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

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

declare zeroext i8 @DebugAssertEnabled() #2

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

declare zeroext i8 @DebugPrintEnabled() #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #2

declare void @DebugPrint(i64 noundef, ptr noundef, ...) #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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 288}
!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, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!13 = !{!"", !10, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !6, i64 40}
!16 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!7, !7, i64 0}
!18 = !{!12, !6, i64 280}
!19 = !{!20, !10, i64 0}
!20 = !{!"", !10, i64 0, !21, i64 8, !6, i64 48, !6, i64 56, !6, i64 64, !23, i64 72}
!21 = !{!"_EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !14, i64 24, !7, i64 28, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !22, i64 36}
!22 = !{!"short", !7, i64 0}
!23 = !{!"s_data_instance", !22, i64 0, !22, i64 2, !7, i64 4, !7, i64 5, !22, i64 6, !22, i64 8, !22, i64 10, !22, i64 12, !22, i64 14, !7, i64 16, !7, i64 48, !7, i64 80, !7, i64 112, !7, i64 368, !14, i64 880, !14, i64 884, !22, i64 888, !22, i64 890, !7, i64 892, !7, i64 893, !7, i64 894, !7, i64 895, !22, i64 896, !22, i64 898, !22, i64 900, !22, i64 902, !14, i64 904, !14, i64 908, !22, i64 912, !22, i64 914, !7, i64 916, !7, i64 920, !7, i64 921, !22, i64 922, !14, i64 924, !6, i64 928, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !10, i64 976, !10, i64 984, !10, i64 992, !10, i64 1000, !10, i64 1008, !7, i64 1016, !22, i64 1528, !22, i64 1530, !22, i64 1532, !22, i64 1534, !7, i64 1536, !7, i64 1537, !7, i64 1538, !7, i64 1539, !7, i64 1540, !7, i64 1541, !24, i64 1544, !10, i64 1808, !6, i64 1816, !10, i64 1824, !6, i64 1832, !6, i64 1840, !6, i64 1848, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888, !6, i64 1896, !6, i64 1904, !6, i64 1912}
!24 = !{!"mc", !7, i64 0, !22, i64 6, !7, i64 8}
!25 = !{!12, !6, i64 336}
!26 = !{!20, !6, i64 64}
!27 = !{!20, !6, i64 1888}
!28 = !{!29, !6, i64 120}
!29 = !{!"_EFI_PCI_IO_PROTOCOL", !6, i64 0, !6, i64 8, !30, i64 16, !30, i64 32, !30, i64 48, !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, !6, i64 136, !10, i64 144, !6, i64 152}
!30 = !{!"", !6, i64 0, !6, i64 8}
!31 = !{!20, !10, i64 1896}
!32 = !{!12, !6, i64 72}
!33 = distinct !{!33, !34}
!34 = !{!"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] }

@gBS = external local_unnamed_addr global ptr, align 8
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@gEfiPciIoProtocolGuid = external global %struct.GUID, align 4
@gEfiNetworkInterfaceIdentifierProtocolGuid_31 = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [136 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @UndiDriverStop(ptr nocapture noundef readonly %0, ptr noundef %1, i64 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = icmp eq i64 %2, 0
  br i1 %6, label %8, label %.preheader

.preheader:                                       ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  br label %20

8:                                                ; preds = %4
  %9 = load ptr, ptr @gBS, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 288
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = tail call i64 %11(ptr noundef %1, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef %13, ptr noundef %1) #3
  %15 = load ptr, ptr @gBS, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 288
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %12, align 8, !tbaa !14
  %19 = tail call i64 %17(ptr noundef %1, ptr noundef nonnull @gEfiPciIoProtocolGuid, ptr noundef %18, ptr noundef %1) #3
  br label %84

20:                                               ; preds = %.preheader, %80
  %.03649 = phi i64 [ 0, %.preheader ], [ %82, %80 ]
  %.03748 = phi i8 [ 1, %.preheader ], [ %spec.select, %80 ]
  %21 = load ptr, ptr @gBS, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 280
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %24 = getelementptr inbounds ptr, ptr %3, i64 %.03649
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !14
  %27 = call i64 %23(ptr noundef %25, ptr noundef nonnull @gEfiNetworkInterfaceIdentifierProtocolGuid_31, ptr noundef nonnull %5, ptr noundef %26, ptr noundef %1, i32 noundef 2) #3
  %28 = icmp slt i64 %27, 0
  br i1 %28, label %80, label %29

29:                                               ; preds = %20
  %30 = call zeroext i8 @DebugAssertEnabled() #3
  %.not44 = icmp eq i8 %30, 0
  %.pre = load ptr, ptr %5, align 8, !tbaa !5
  %.pre50 = ptrtoint ptr %.pre to i64
  %.pre51 = add i64 %.pre50, -8
  %.pre53 = inttoptr i64 %.pre51 to ptr
  br i1 %.not44, label %._crit_edge, label %31

31:                                               ; preds = %29
  %32 = load i64, ptr %.pre53, align 8, !tbaa !17
  %.not45 = icmp eq i64 %32, 1768189557
  br i1 %.not45, label %._crit_edge, label %33

33:                                               ; preds = %31
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 617, ptr noundef nonnull @.str.1) #3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %29, %31, %33
  %35 = phi ptr [ %34, %33 ], [ %.pre53, %31 ], [ %.pre53, %29 ]
  %36 = load ptr, ptr @gBS, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 288
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !14
  %40 = load ptr, ptr %24, align 8, !tbaa !5
  %41 = call i64 %38(ptr noundef %1, ptr noundef nonnull @gEfiPciIoProtocolGuid, ptr noundef %39, ptr noundef %40) #3
  %42 = icmp slt i64 %41, 0
  br i1 %42, label %80, label %43

43:                                               ; preds = %._crit_edge
  %44 = load ptr, ptr @gBS, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i64 336
  %46 = load ptr, ptr %45, align 8, !tbaa !23
  %47 = load ptr, ptr %24, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %35, i64 64
  %49 = load ptr, ptr %48, align 8, !tbaa !24
  %50 = getelementptr inbounds i8, ptr %35, i64 8
  %51 = call i64 (ptr, ...) %46(ptr noundef %47, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef %49, ptr noundef nonnull @gEfiNetworkInterfaceIdentifierProtocolGuid_31, ptr noundef nonnull %50, ptr noundef null) #3
  %52 = icmp slt i64 %51, 0
  br i1 %52, label %80, label %53

53:                                               ; preds = %43
  %54 = getelementptr inbounds i8, ptr %35, i64 1888
  %55 = load ptr, ptr %54, align 8, !tbaa !25
  %56 = getelementptr inbounds i8, ptr %55, i64 120
  %57 = load ptr, ptr %56, align 8, !tbaa !26
  %58 = getelementptr inbounds i8, ptr %35, i64 1896
  %59 = load i64, ptr %58, align 8, !tbaa !29
  %60 = call i64 %57(ptr noundef %55, i32 noundef 1, i64 noundef %59, ptr noundef null) #3
  %61 = call zeroext i8 @DebugAssertEnabled() #3
  %62 = icmp ne i8 %61, 0
  %63 = icmp slt i64 %60, 0
  %or.cond = select i1 %62, i1 %63, i1 false
  br i1 %or.cond, label %64, label %70

64:                                               ; preds = %53
  %65 = call zeroext i8 @DebugPrintEnabled() #3
  %.not46 = icmp eq i8 %65, 0
  br i1 %.not46, label %69, label %66

66:                                               ; preds = %64
  %67 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not47 = icmp eq i8 %67, 0
  br i1 %.not47, label %69, label %68

68:                                               ; preds = %66
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.2, i64 noundef %60) #3
  br label %69

69:                                               ; preds = %66, %68, %64
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 645, ptr noundef nonnull @.str.3) #3
  br label %70

70:                                               ; preds = %69, %53
  %71 = load ptr, ptr @gBS, align 8, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %71, i64 72
  %73 = load ptr, ptr %72, align 8, !tbaa !30
  %74 = load ptr, ptr %48, align 8, !tbaa !24
  %75 = call i64 %73(ptr noundef %74) #3
  %76 = load ptr, ptr @gBS, align 8, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %76, i64 72
  %78 = load ptr, ptr %77, align 8, !tbaa !30
  %79 = call i64 %78(ptr noundef nonnull %35) #3
  br label %80

80:                                               ; preds = %._crit_edge, %70, %43, %20
  %.038 = phi i64 [ %27, %20 ], [ %41, %._crit_edge ], [ %51, %43 ], [ %60, %70 ]
  %81 = icmp slt i64 %.038, 0
  %spec.select = select i1 %81, i8 0, i8 %.03748
  %82 = add nuw i64 %.03649, 1
  %exitcond.not = icmp eq i64 %82, %2
  br i1 %exitcond.not, label %83, label %20, !llvm.loop !31

83:                                               ; preds = %80
  %.not = icmp eq i8 %spec.select, 0
  %. = select i1 %.not, i64 -9223372036854775801, i64 0
  br label %84

84:                                               ; preds = %83, %8
  %.0 = phi i64 [ %19, %8 ], [ %., %83 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret i64 %.0
}

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

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

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

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) local_unnamed_addr #2

declare void @DebugPrint(i64 noundef, ptr noundef, ...) local_unnamed_addr #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 = { 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 = { 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, !6, i64 288}
!10 = !{!"", !11, 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, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!11 = !{!"", !12, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 40}
!15 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40}
!16 = !{!10, !6, i64 280}
!17 = !{!18, !12, i64 0}
!18 = !{!"", !12, i64 0, !19, i64 8, !6, i64 48, !6, i64 56, !6, i64 64, !21, i64 72}
!19 = !{!"_EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL", !12, i64 0, !12, i64 8, !12, i64 16, !13, 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 = !{!"s_data_instance", !20, i64 0, !20, i64 2, !7, i64 4, !7, i64 5, !20, i64 6, !20, i64 8, !20, i64 10, !20, i64 12, !20, i64 14, !7, i64 16, !7, i64 48, !7, i64 80, !7, i64 112, !7, i64 368, !13, i64 880, !13, i64 884, !20, i64 888, !20, i64 890, !7, i64 892, !7, i64 893, !7, i64 894, !7, i64 895, !20, i64 896, !20, i64 898, !20, i64 900, !20, i64 902, !13, i64 904, !13, i64 908, !20, i64 912, !20, i64 914, !7, i64 916, !7, i64 920, !7, i64 921, !20, i64 922, !13, i64 924, !6, i64 928, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !12, i64 976, !12, i64 984, !12, i64 992, !12, i64 1000, !12, i64 1008, !7, i64 1016, !20, i64 1528, !20, i64 1530, !20, i64 1532, !20, i64 1534, !7, i64 1536, !7, i64 1537, !7, i64 1538, !7, i64 1539, !7, i64 1540, !7, i64 1541, !22, i64 1544, !12, i64 1808, !6, i64 1816, !12, i64 1824, !6, i64 1832, !6, i64 1840, !6, i64 1848, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888, !6, i64 1896, !6, i64 1904, !6, i64 1912}
!22 = !{!"mc", !7, i64 0, !20, i64 6, !7, i64 8}
!23 = !{!10, !6, i64 336}
!24 = !{!18, !6, i64 64}
!25 = !{!18, !6, i64 1888}
!26 = !{!27, !6, i64 120}
!27 = !{!"_EFI_PCI_IO_PROTOCOL", !6, i64 0, !6, i64 8, !28, i64 16, !28, i64 32, !28, i64 48, !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, !6, i64 136, !12, i64 144, !6, i64 152}
!28 = !{!"", !6, i64 0, !6, i64 8}
!29 = !{!18, !12, i64 1896}
!30 = !{!10, !6, i64 72}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}


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