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

; 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._EFI_DRIVER_BINDING_PROTOCOL = type { ptr, ptr, ptr, i32, ptr, ptr }
%struct.GUID = type { i32, i16, i16, [8 x i8] }
%struct._MTFTP4_SERVICE = type { i32, %struct._EFI_SERVICE_BINDING_PROTOCOL, i16, %struct._LIST_ENTRY, ptr, ptr, ptr, ptr, ptr }
%struct._EFI_SERVICE_BINDING_PROTOCOL = type { ptr, ptr }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct._MTFTP4_PROTOCOL = type { i32, %struct._LIST_ENTRY, %struct._EFI_MTFTP4_PROTOCOL, i64, i8, ptr, ptr, %struct.EFI_MTFTP4_CONFIG_DATA, ptr, %struct.MTFTP4_OPTION, i16, i16, i16, %struct._LIST_ENTRY, i32, i16, i16, i32, ptr, ptr, i32, i32, i32, i32, i32, i16, i8, ptr }
%struct._EFI_MTFTP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_MTFTP4_CONFIG_DATA = type { i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, i16, i16 }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct.MTFTP4_OPTION = type { i16, i8, i32, i32, i16, i8, i32 }
%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._UDP_IO = type { i32, %struct._LIST_ENTRY, i64, i8, ptr, ptr, ptr, %struct.EFI_SIMPLE_NETWORK_MODE, %struct._LIST_ENTRY, ptr, %union.anon, %union.anon.0 }
%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] }
%union.anon = type { ptr }
%union.anon.0 = type { %struct.EFI_UDP6_CONFIG_DATA }
%struct.EFI_UDP6_CONFIG_DATA = type { i8, i8, i8, i8, i8, i32, i32, %struct.EFI_IPv6_ADDRESS, i16, %struct.EFI_IPv6_ADDRESS, i16 }
%struct.EFI_IPv6_ADDRESS = type { [16 x i8] }

@gMtftp4DriverBinding = external dso_local global %struct._EFI_DRIVER_BINDING_PROTOCOL, align 8
@gBS = external global ptr, align 8
@.str = external hidden unnamed_addr constant [157 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@gEfiUdp4ProtocolGuid = external global %struct.GUID, align 4
@gEfiMtftp4ProtocolGuid = external global %struct.GUID, align 4

; Function Attrs: nounwind uwtable
define dso_local i64 @Mtftp4ServiceBindingCreateChild(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %17, label %14

14:                                               ; preds = %2
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14, %2
  store i64 -9223372036854775806, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %168

18:                                               ; preds = %14
  %19 = call ptr @AllocatePool(i64 noundef 272)
  store ptr %19, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %168

23:                                               ; preds = %18
  %24 = call zeroext i8 @DebugAssertEnabled()
  %25 = zext i8 %24 to i32
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %37

27:                                               ; preds = %23
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = ptrtoint ptr %28 to i64
  %30 = sub i64 %29, ptrtoint (ptr getelementptr inbounds (%struct._MTFTP4_SERVICE, ptr null, i32 0, i32 1) to i64)
  %31 = inttoptr i64 %30 to ptr
  %32 = getelementptr inbounds %struct._MTFTP4_SERVICE, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = icmp ne i32 %33, 1347700308
  br i1 %34, label %35, label %37

35:                                               ; preds = %27
  call void @DebugAssert(ptr noundef @.str, i64 noundef 510, ptr noundef @.str.2)
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  br label %42

37:                                               ; preds = %27, %23
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = ptrtoint ptr %38 to i64
  %40 = sub i64 %39, ptrtoint (ptr getelementptr inbounds (%struct._MTFTP4_SERVICE, ptr null, i32 0, i32 1) to i64)
  %41 = inttoptr i64 %40 to ptr
  br label %42

42:                                               ; preds = %37, %35
  %43 = phi ptr [ %36, %35 ], [ %41, %37 ]
  store ptr %43, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  call void @Mtftp4InitProtocol(ptr noundef %44, ptr noundef %45)
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._MTFTP4_SERVICE, ptr %46, i32 0, i32 6
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._MTFTP4_SERVICE, ptr %49, i32 0, i32 7
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = call ptr @UdpIoCreateIo(ptr noundef %48, ptr noundef %51, ptr noundef @Mtftp4ConfigNullUdp, i8 noundef zeroext 4, ptr noundef %52)
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %54, i32 0, i32 18
  store ptr %53, ptr %55, align 8, !tbaa !17
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %56, i32 0, i32 18
  %58 = load ptr, ptr %57, align 8, !tbaa !17
  %59 = icmp eq ptr %58, null
  br i1 %59, label %60, label %62

60:                                               ; preds = %42
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  call void @FreePool(ptr noundef %61)
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %168

62:                                               ; preds = %42
  %63 = load ptr, ptr @gBS, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %63, i32 0, i32 39
  %65 = load ptr, ptr %64, align 8, !tbaa !24
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %67, i32 0, i32 2
  %69 = call i64 (ptr, ...) %65(ptr noundef %66, ptr noundef @gEfiMtftp4ProtocolGuid, ptr noundef %68, ptr noundef null)
  store i64 %69, ptr %8, align 8, !tbaa !27
  %70 = load i64, ptr %8, align 8, !tbaa !27
  %71 = icmp slt i64 %70, 0
  br i1 %71, label %72, label %79

72:                                               ; preds = %62
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %73, i32 0, i32 18
  %75 = load ptr, ptr %74, align 8, !tbaa !17
  %76 = call i64 @UdpIoFreeIo(ptr noundef %75)
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  call void @FreePool(ptr noundef %77)
  %78 = load i64, ptr %8, align 8, !tbaa !27
  store i64 %78, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %168

79:                                               ; preds = %62
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = load ptr, ptr %80, align 8, !tbaa !5
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %82, i32 0, i32 6
  store ptr %81, ptr %83, align 8, !tbaa !28
  %84 = load ptr, ptr @gBS, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %84, i32 0, i32 33
  %86 = load ptr, ptr %85, align 8, !tbaa !29
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._MTFTP4_SERVICE, ptr %87, i32 0, i32 8
  %89 = load ptr, ptr %88, align 8, !tbaa !30
  %90 = getelementptr inbounds %struct._UDP_IO, ptr %89, i32 0, i32 6
  %91 = load ptr, ptr %90, align 8, !tbaa !31
  %92 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gMtftp4DriverBinding, i32 0, i32 5), align 8, !tbaa !34
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %93, i32 0, i32 6
  %95 = load ptr, ptr %94, align 8, !tbaa !28
  %96 = call i64 %86(ptr noundef %91, ptr noundef @gEfiUdp4ProtocolGuid, ptr noundef %10, ptr noundef %92, ptr noundef %95, i32 noundef 8)
  store i64 %96, ptr %8, align 8, !tbaa !27
  %97 = load i64, ptr %8, align 8, !tbaa !27
  %98 = icmp slt i64 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %79
  br label %146

100:                                              ; preds = %79
  %101 = load ptr, ptr @gBS, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %101, i32 0, i32 33
  %103 = load ptr, ptr %102, align 8, !tbaa !29
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %104, i32 0, i32 18
  %106 = load ptr, ptr %105, align 8, !tbaa !17
  %107 = getelementptr inbounds %struct._UDP_IO, ptr %106, i32 0, i32 6
  %108 = load ptr, ptr %107, align 8, !tbaa !31
  %109 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gMtftp4DriverBinding, i32 0, i32 5), align 8, !tbaa !34
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %110, i32 0, i32 6
  %112 = load ptr, ptr %111, align 8, !tbaa !28
  %113 = call i64 %103(ptr noundef %108, ptr noundef @gEfiUdp4ProtocolGuid, ptr noundef %10, ptr noundef %109, ptr noundef %112, i32 noundef 8)
  store i64 %113, ptr %8, align 8, !tbaa !27
  %114 = load i64, ptr %8, align 8, !tbaa !27
  %115 = icmp slt i64 %114, 0
  br i1 %115, label %116, label %128

116:                                              ; preds = %100
  %117 = load ptr, ptr @gBS, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %117, i32 0, i32 34
  %119 = load ptr, ptr %118, align 8, !tbaa !36
  %120 = load ptr, ptr %6, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct._MTFTP4_SERVICE, ptr %120, i32 0, i32 8
  %122 = load ptr, ptr %121, align 8, !tbaa !30
  %123 = getelementptr inbounds %struct._UDP_IO, ptr %122, i32 0, i32 6
  %124 = load ptr, ptr %123, align 8, !tbaa !31
  %125 = load ptr, ptr getelementptr inbounds (%struct._EFI_DRIVER_BINDING_PROTOCOL, ptr @gMtftp4DriverBinding, i32 0, i32 5), align 8, !tbaa !34
  %126 = load ptr, ptr %5, align 8, !tbaa !5
  %127 = call i64 %119(ptr noundef %124, ptr noundef @gEfiUdp4ProtocolGuid, ptr noundef %125, ptr noundef %126)
  br label %146

128:                                              ; preds = %100
  %129 = load ptr, ptr @gBS, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %129, i32 0, i32 1
  %131 = load ptr, ptr %130, align 8, !tbaa !37
  %132 = call i64 %131(i64 noundef 8)
  store i64 %132, ptr %9, align 8, !tbaa !27
  %133 = load ptr, ptr %6, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct._MTFTP4_SERVICE, ptr %133, i32 0, i32 3
  %135 = load ptr, ptr %7, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %135, i32 0, i32 1
  %137 = call ptr @InsertTailList(ptr noundef %134, ptr noundef %136)
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct._MTFTP4_SERVICE, ptr %138, i32 0, i32 2
  %140 = load i16, ptr %139, align 8, !tbaa !38
  %141 = add i16 %140, 1
  store i16 %141, ptr %139, align 8, !tbaa !38
  %142 = load ptr, ptr @gBS, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %142, i32 0, i32 2
  %144 = load ptr, ptr %143, align 8, !tbaa !39
  %145 = load i64, ptr %9, align 8, !tbaa !27
  call void %144(i64 noundef %145)
  store i64 0, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %168

146:                                              ; preds = %116, %99
  %147 = load ptr, ptr %7, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %147, i32 0, i32 6
  %149 = load ptr, ptr %148, align 8, !tbaa !28
  %150 = icmp ne ptr %149, null
  br i1 %150, label %151, label %161

151:                                              ; preds = %146
  %152 = load ptr, ptr @gBS, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %152, i32 0, i32 40
  %154 = load ptr, ptr %153, align 8, !tbaa !40
  %155 = load ptr, ptr %7, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %155, i32 0, i32 6
  %157 = load ptr, ptr %156, align 8, !tbaa !28
  %158 = load ptr, ptr %7, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %158, i32 0, i32 2
  %160 = call i64 (ptr, ...) %154(ptr noundef %157, ptr noundef @gEfiMtftp4ProtocolGuid, ptr noundef %159, ptr noundef null)
  br label %161

161:                                              ; preds = %151, %146
  %162 = load ptr, ptr %7, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %162, i32 0, i32 18
  %164 = load ptr, ptr %163, align 8, !tbaa !17
  %165 = call i64 @UdpIoFreeIo(ptr noundef %164)
  %166 = load ptr, ptr %7, align 8, !tbaa !5
  call void @FreePool(ptr noundef %166)
  %167 = load i64, ptr %8, align 8, !tbaa !27
  store i64 %167, ptr %3, align 8
  store i32 1, ptr %11, align 4
  br label %168

168:                                              ; preds = %161, %128, %72, %60, %22, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %169 = load i64, ptr %3, align 8
  ret i64 %169
}

; 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

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

declare ptr @AllocatePool(i64 noundef) #2

declare void @FreePool(ptr noundef) #2

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

declare i64 @UdpIoFreeIo(ptr noundef) #2

declare zeroext i8 @DebugAssertEnabled() #2

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

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

declare ptr @InsertTailList(ptr 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, !11, i64 0}
!10 = !{!"_MTFTP4_SERVICE", !11, i64 0, !12, i64 8, !13, i64 24, !14, i64 32, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_SERVICE_BINDING_PROTOCOL", !6, i64 0, !6, i64 8}
!13 = !{!"short", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!10, !6, i64 64}
!16 = !{!10, !6, i64 72}
!17 = !{!18, !6, i64 224}
!18 = !{!"_MTFTP4_PROTOCOL", !11, i64 0, !14, i64 8, !19, i64 24, !20, i64 88, !7, i64 96, !6, i64 104, !6, i64 112, !21, i64 120, !6, i64 152, !23, i64 160, !13, i64 180, !13, i64 182, !13, i64 184, !14, i64 192, !11, i64 208, !13, i64 212, !13, i64 214, !11, i64 216, !6, i64 224, !6, i64 232, !11, i64 240, !11, i64 244, !11, i64 248, !11, i64 252, !11, i64 256, !13, i64 260, !7, i64 262, !6, i64 264}
!19 = !{!"_EFI_MTFTP4_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!20 = !{!"long long", !7, i64 0}
!21 = !{!"", !7, i64 0, !22, i64 1, !22, i64 5, !13, i64 10, !22, i64 12, !22, i64 16, !13, i64 20, !13, i64 22, !13, i64 24}
!22 = !{!"", !7, i64 0}
!23 = !{!"", !13, i64 0, !7, i64 2, !11, i64 4, !11, i64 8, !13, i64 12, !7, i64 14, !11, i64 16}
!24 = !{!25, !6, i64 328}
!25 = !{!"", !26, 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}
!26 = !{!"", !20, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!27 = !{!20, !20, i64 0}
!28 = !{!18, !6, i64 112}
!29 = !{!25, !6, i64 280}
!30 = !{!10, !6, i64 80}
!31 = !{!32, !6, i64 56}
!32 = !{!"_UDP_IO", !11, i64 0, !14, i64 8, !20, i64 24, !7, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !33, i64 64, !14, i64 720, !6, i64 736, !7, i64 744, !7, i64 752}
!33 = !{!"", !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, !22, i64 552, !22, i64 584, !22, i64 616, !7, i64 648, !7, i64 649, !7, i64 650, !7, i64 651, !7, i64 652}
!34 = !{!35, !6, i64 40}
!35 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !6, i64 40}
!36 = !{!25, !6, i64 288}
!37 = !{!25, !6, i64 24}
!38 = !{!10, !13, i64 24}
!39 = !{!25, !6, i64 32}
!40 = !{!25, !6, i64 336}


; 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._EFI_DRIVER_BINDING_PROTOCOL = type { ptr, ptr, ptr, i32, ptr, ptr }
%struct.GUID = type { i32, i16, i16, [8 x i8] }

@gMtftp4DriverBinding = external dso_local local_unnamed_addr global %struct._EFI_DRIVER_BINDING_PROTOCOL, align 8
@gBS = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [157 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@gEfiUdp4ProtocolGuid = external global %struct.GUID, align 4
@gEfiMtftp4ProtocolGuid = external global %struct.GUID, align 4

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775808, 1) i64 @Mtftp4ServiceBindingCreateChild(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %1, null
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %89, label %6

6:                                                ; preds = %2
  %7 = tail call ptr @AllocatePool(i64 noundef 272) #3
  %8 = icmp eq ptr %7, null
  br i1 %8, label %89, label %9

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

11:                                               ; preds = %9
  %12 = load i32, ptr %.pre53, align 8, !tbaa !5
  %.not49 = icmp eq i32 %12, 1347700308
  br i1 %.not49, label %._crit_edge, label %13

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

._crit_edge:                                      ; preds = %9, %11, %13
  %14 = phi ptr [ %0, %13 ], [ %.pre53, %11 ], [ %.pre53, %9 ]
  tail call void @Mtftp4InitProtocol(ptr noundef %14, ptr noundef nonnull %7)
  %15 = getelementptr inbounds i8, ptr %14, i64 64
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %14, i64 72
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = tail call ptr @UdpIoCreateIo(ptr noundef %16, ptr noundef %18, ptr noundef nonnull @Mtftp4ConfigNullUdp, i8 noundef zeroext 4, ptr noundef nonnull %7) #3
  %20 = getelementptr inbounds i8, ptr %7, i64 224
  store ptr %19, ptr %20, align 8, !tbaa !16
  %21 = icmp eq ptr %19, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %._crit_edge
  tail call void @FreePool(ptr noundef nonnull %7) #3
  br label %89

23:                                               ; preds = %._crit_edge
  %24 = load ptr, ptr @gBS, align 8, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %24, i64 328
  %26 = load ptr, ptr %25, align 8, !tbaa !24
  %27 = getelementptr inbounds i8, ptr %7, i64 24
  %28 = tail call i64 (ptr, ...) %26(ptr noundef nonnull %1, ptr noundef nonnull @gEfiMtftp4ProtocolGuid, ptr noundef nonnull %27, ptr noundef null) #3
  %29 = icmp slt i64 %28, 0
  br i1 %29, label %30, label %33

30:                                               ; preds = %23
  %31 = load ptr, ptr %20, align 8, !tbaa !16
  %32 = tail call i64 @UdpIoFreeIo(ptr noundef %31) #3
  tail call void @FreePool(ptr noundef nonnull %7) #3
  br label %89

33:                                               ; preds = %23
  %34 = load ptr, ptr %1, align 8, !tbaa !23
  %35 = getelementptr inbounds i8, ptr %7, i64 112
  store ptr %34, ptr %35, align 8, !tbaa !27
  %36 = load ptr, ptr @gBS, align 8, !tbaa !23
  %37 = getelementptr inbounds i8, ptr %36, i64 280
  %38 = load ptr, ptr %37, align 8, !tbaa !28
  %39 = getelementptr inbounds i8, ptr %14, i64 80
  %40 = load ptr, ptr %39, align 8, !tbaa !29
  %41 = getelementptr inbounds i8, ptr %40, i64 56
  %42 = load ptr, ptr %41, align 8, !tbaa !30
  %43 = load ptr, ptr getelementptr inbounds (i8, ptr @gMtftp4DriverBinding, i64 40), align 8, !tbaa !33
  %44 = call i64 %38(ptr noundef %42, ptr noundef nonnull @gEfiUdp4ProtocolGuid, ptr noundef nonnull %3, ptr noundef %43, ptr noundef %34, i32 noundef 8) #3
  %45 = icmp slt i64 %44, 0
  br i1 %45, label %79, label %46

46:                                               ; preds = %33
  %47 = load ptr, ptr @gBS, align 8, !tbaa !23
  %48 = getelementptr inbounds i8, ptr %47, i64 280
  %49 = load ptr, ptr %48, align 8, !tbaa !28
  %50 = load ptr, ptr %20, align 8, !tbaa !16
  %51 = getelementptr inbounds i8, ptr %50, i64 56
  %52 = load ptr, ptr %51, align 8, !tbaa !30
  %53 = load ptr, ptr getelementptr inbounds (i8, ptr @gMtftp4DriverBinding, i64 40), align 8, !tbaa !33
  %54 = load ptr, ptr %35, align 8, !tbaa !27
  %55 = call i64 %49(ptr noundef %52, ptr noundef nonnull @gEfiUdp4ProtocolGuid, ptr noundef nonnull %3, ptr noundef %53, ptr noundef %54, i32 noundef 8) #3
  %56 = icmp slt i64 %55, 0
  %57 = load ptr, ptr @gBS, align 8, !tbaa !23
  br i1 %56, label %58, label %66

58:                                               ; preds = %46
  %59 = getelementptr inbounds i8, ptr %57, i64 288
  %60 = load ptr, ptr %59, align 8, !tbaa !35
  %61 = load ptr, ptr %39, align 8, !tbaa !29
  %62 = getelementptr inbounds i8, ptr %61, i64 56
  %63 = load ptr, ptr %62, align 8, !tbaa !30
  %64 = load ptr, ptr getelementptr inbounds (i8, ptr @gMtftp4DriverBinding, i64 40), align 8, !tbaa !33
  %65 = call i64 %60(ptr noundef %63, ptr noundef nonnull @gEfiUdp4ProtocolGuid, ptr noundef %64, ptr noundef nonnull %1) #3
  br label %79

66:                                               ; preds = %46
  %67 = getelementptr inbounds i8, ptr %57, i64 24
  %68 = load ptr, ptr %67, align 8, !tbaa !36
  %69 = call i64 %68(i64 noundef 8) #3
  %70 = getelementptr inbounds i8, ptr %14, i64 32
  %71 = getelementptr inbounds i8, ptr %7, i64 8
  %72 = call ptr @InsertTailList(ptr noundef nonnull %70, ptr noundef nonnull %71) #3
  %73 = getelementptr inbounds i8, ptr %14, i64 24
  %74 = load i16, ptr %73, align 8, !tbaa !37
  %75 = add i16 %74, 1
  store i16 %75, ptr %73, align 8, !tbaa !37
  %76 = load ptr, ptr @gBS, align 8, !tbaa !23
  %77 = getelementptr inbounds i8, ptr %76, i64 32
  %78 = load ptr, ptr %77, align 8, !tbaa !38
  call void %78(i64 noundef %69) #3
  br label %89

79:                                               ; preds = %33, %58
  %.041 = phi i64 [ %44, %33 ], [ %55, %58 ]
  %80 = load ptr, ptr %35, align 8, !tbaa !27
  %.not50 = icmp eq ptr %80, null
  br i1 %.not50, label %86, label %81

81:                                               ; preds = %79
  %82 = load ptr, ptr @gBS, align 8, !tbaa !23
  %83 = getelementptr inbounds i8, ptr %82, i64 336
  %84 = load ptr, ptr %83, align 8, !tbaa !39
  %85 = call i64 (ptr, ...) %84(ptr noundef nonnull %80, ptr noundef nonnull @gEfiMtftp4ProtocolGuid, ptr noundef nonnull %27, ptr noundef null) #3
  br label %86

86:                                               ; preds = %81, %79
  %87 = load ptr, ptr %20, align 8, !tbaa !16
  %88 = call i64 @UdpIoFreeIo(ptr noundef %87) #3
  call void @FreePool(ptr noundef nonnull %7) #3
  br label %89

89:                                               ; preds = %6, %2, %86, %66, %30, %22
  %.0 = phi i64 [ -9223372036854775799, %22 ], [ %28, %30 ], [ %.041, %86 ], [ 0, %66 ], [ -9223372036854775806, %2 ], [ -9223372036854775799, %6 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #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

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

declare ptr @AllocatePool(i64 noundef) local_unnamed_addr #2

declare void @FreePool(ptr noundef) local_unnamed_addr #2

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

declare i64 @UdpIoFreeIo(ptr 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: nounwind uwtable
declare dso_local void @Mtftp4InitProtocol(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @InsertTailList(ptr 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, !7, i64 0}
!6 = !{!"_MTFTP4_SERVICE", !7, i64 0, !10, i64 8, !12, i64 24, !13, i64 32, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80}
!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 = !{!"short", !8, i64 0}
!13 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!14 = !{!6, !11, i64 64}
!15 = !{!6, !11, i64 72}
!16 = !{!17, !11, i64 224}
!17 = !{!"_MTFTP4_PROTOCOL", !7, i64 0, !13, i64 8, !18, i64 24, !19, i64 88, !8, i64 96, !11, i64 104, !11, i64 112, !20, i64 120, !11, i64 152, !22, i64 160, !12, i64 180, !12, i64 182, !12, i64 184, !13, i64 192, !7, i64 208, !12, i64 212, !12, i64 214, !7, i64 216, !11, i64 224, !11, i64 232, !7, i64 240, !7, i64 244, !7, i64 248, !7, i64 252, !7, i64 256, !12, i64 260, !8, i64 262, !11, i64 264}
!18 = !{!"_EFI_MTFTP4_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!19 = !{!"long long", !8, i64 0}
!20 = !{!"", !8, i64 0, !21, i64 1, !21, i64 5, !12, i64 10, !21, i64 12, !21, i64 16, !12, i64 20, !12, i64 22, !12, i64 24}
!21 = !{!"", !8, i64 0}
!22 = !{!"", !12, i64 0, !8, i64 2, !7, i64 4, !7, i64 8, !12, i64 12, !8, i64 14, !7, i64 16}
!23 = !{!11, !11, i64 0}
!24 = !{!25, !11, i64 328}
!25 = !{!"", !26, i64 0, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !11, i64 184, !11, i64 192, !11, i64 200, !11, i64 208, !11, i64 216, !11, i64 224, !11, i64 232, !11, i64 240, !11, i64 248, !11, i64 256, !11, i64 264, !11, i64 272, !11, i64 280, !11, i64 288, !11, i64 296, !11, i64 304, !11, i64 312, !11, i64 320, !11, i64 328, !11, i64 336, !11, i64 344, !11, i64 352, !11, i64 360, !11, i64 368}
!26 = !{!"", !19, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!27 = !{!17, !11, i64 112}
!28 = !{!25, !11, i64 280}
!29 = !{!6, !11, i64 80}
!30 = !{!31, !11, i64 56}
!31 = !{!"_UDP_IO", !7, i64 0, !13, i64 8, !19, i64 24, !8, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !32, i64 64, !13, i64 720, !11, i64 736, !8, i64 744, !8, i64 752}
!32 = !{!"", !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, !21, i64 552, !21, i64 584, !21, i64 616, !8, i64 648, !8, i64 649, !8, i64 650, !8, i64 651, !8, i64 652}
!33 = !{!34, !11, i64 40}
!34 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !7, i64 24, !11, i64 32, !11, i64 40}
!35 = !{!25, !11, i64 288}
!36 = !{!25, !11, i64 24}
!37 = !{!6, !12, i64 24}
!38 = !{!25, !11, i64 32}
!39 = !{!25, !11, i64 336}


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