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

; 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._MTFTP6_INSTANCE = type { i32, ptr, %struct._LIST_ENTRY, %struct._EFI_MTFTP6_PROTOCOL, ptr, ptr, ptr, %struct.MTFTP6_EXT_OPTION_INFO, i16, i16, %struct._LIST_ENTRY, %struct.EFI_IPv6_ADDRESS, i16, i16, ptr, %struct.EFI_IPv6_ADDRESS, i16, ptr, ptr, i32, i32, i32, i32, i64, i8, i8, i8 }
%struct._EFI_MTFTP6_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.MTFTP6_EXT_OPTION_INFO = type { i16, i8, i32, %struct.EFI_IPv6_ADDRESS, i16, i8, i32 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_IPv6_ADDRESS = type { [16 x i8] }
%struct._EFI_MTFTP6_TOKEN = type { i64, ptr, ptr, ptr, ptr, i32, ptr, i64, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_MTFTP6_OPTION = type { ptr, ptr }
%struct.EFI_MTFTP6_REQ_HEADER = type <{ i16, [1 x i8] }>

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [138 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 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

; Function Attrs: nounwind uwtable
define dso_local i64 @Mtftp6SendRequest(ptr noundef %0, i16 noundef zeroext %1) #1 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i16 %1, ptr %5, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %17, i32 0, i32 6
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  store ptr %19, ptr %8, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %20, i32 0, i32 6
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  store ptr %22, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %23, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !21
  store ptr %25, ptr %10, align 8, !tbaa !5
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %29

28:                                               ; preds = %2
  store ptr @.str, ptr %10, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %28, %2
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !22
  %33 = call i64 @AsciiStrLen(ptr noundef %32)
  %34 = trunc i64 %33 to i32
  store i32 %34, ptr %12, align 4, !tbaa !23
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = call i64 @AsciiStrLen(ptr noundef %35)
  %37 = trunc i64 %36 to i32
  store i32 %37, ptr %13, align 4, !tbaa !23
  %38 = load i32, ptr %12, align 4, !tbaa !23
  %39 = load i32, ptr %13, align 4, !tbaa !23
  %40 = add i32 %38, %39
  %41 = add i32 %40, 4
  store i32 %41, ptr %14, align 4, !tbaa !23
  store i64 0, ptr %15, align 8, !tbaa !24
  br label %42

42:                                               ; preds = %70, %29
  %43 = load i64, ptr %15, align 8, !tbaa !24
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %44, i32 0, i32 5
  %46 = load i32, ptr %45, align 8, !tbaa !25
  %47 = zext i32 %46 to i64
  %48 = icmp ult i64 %43, %47
  br i1 %48, label %49, label %73

49:                                               ; preds = %42
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i64, ptr %15, align 8, !tbaa !24
  %52 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %50, i64 %51
  %53 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !26
  %55 = call i64 @AsciiStrLen(ptr noundef %54)
  %56 = trunc i64 %55 to i32
  store i32 %56, ptr %12, align 4, !tbaa !23
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load i64, ptr %15, align 8, !tbaa !24
  %59 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %57, i64 %58
  %60 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !28
  %62 = call i64 @AsciiStrLen(ptr noundef %61)
  %63 = trunc i64 %62 to i32
  store i32 %63, ptr %13, align 4, !tbaa !23
  %64 = load i32, ptr %12, align 4, !tbaa !23
  %65 = load i32, ptr %13, align 4, !tbaa !23
  %66 = add i32 %64, %65
  %67 = add i32 %66, 2
  %68 = load i32, ptr %14, align 4, !tbaa !23
  %69 = add i32 %68, %67
  store i32 %69, ptr %14, align 4, !tbaa !23
  br label %70

70:                                               ; preds = %49
  %71 = load i64, ptr %15, align 8, !tbaa !24
  %72 = add i64 %71, 1
  store i64 %72, ptr %15, align 8, !tbaa !24
  br label %42, !llvm.loop !29

73:                                               ; preds = %42
  %74 = load i32, ptr %14, align 4, !tbaa !23
  %75 = call ptr @NetbufAlloc(i32 noundef %74)
  store ptr %75, ptr %9, align 8, !tbaa !5
  %76 = icmp eq ptr %75, null
  br i1 %76, label %77, label %78

77:                                               ; preds = %73
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %16, align 4
  br label %180

78:                                               ; preds = %73
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = load i32, ptr %14, align 4, !tbaa !23
  %81 = call ptr @NetbufAllocSpace(ptr noundef %79, i32 noundef %80, i8 noundef zeroext 0)
  store ptr %81, ptr %6, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %78
  %83 = call zeroext i8 @DebugAssertEnabled()
  %84 = icmp ne i8 %83, 0
  br i1 %84, label %85, label %90

85:                                               ; preds = %82
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = icmp ne ptr %86, null
  br i1 %87, label %89, label %88

88:                                               ; preds = %85
  call void @DebugAssert(ptr noundef @.str.1, i64 noundef 511, ptr noundef @.str.2)
  br label %89

89:                                               ; preds = %88, %85
  br label %90

90:                                               ; preds = %89, %82
  br label %91

91:                                               ; preds = %90
  br label %92

92:                                               ; preds = %91
  %93 = load i16, ptr %5, align 2, !tbaa !9
  %94 = call zeroext i16 @SwapBytes16(i16 noundef zeroext %93)
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  store i16 %94, ptr %95, align 1, !tbaa !31
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.EFI_MTFTP6_REQ_HEADER, ptr %96, i32 0, i32 1
  %98 = getelementptr inbounds [1 x i8], ptr %97, i64 0, i64 0
  store ptr %98, ptr %11, align 8, !tbaa !5
  %99 = load ptr, ptr %11, align 8, !tbaa !5
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %100, i32 0, i32 3
  %102 = load ptr, ptr %101, align 8, !tbaa !22
  %103 = call ptr @AsciiStrCpy(ptr noundef %99, ptr noundef %102)
  store ptr %103, ptr %11, align 8, !tbaa !5
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %104, i32 0, i32 3
  %106 = load ptr, ptr %105, align 8, !tbaa !22
  %107 = call i64 @AsciiStrLen(ptr noundef %106)
  %108 = add i64 %107, 1
  %109 = load ptr, ptr %11, align 8, !tbaa !5
  %110 = getelementptr inbounds i8, ptr %109, i64 %108
  store ptr %110, ptr %11, align 8, !tbaa !5
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  %112 = load ptr, ptr %10, align 8, !tbaa !5
  %113 = call ptr @AsciiStrCpy(ptr noundef %111, ptr noundef %112)
  store ptr %113, ptr %11, align 8, !tbaa !5
  %114 = load ptr, ptr %10, align 8, !tbaa !5
  %115 = call i64 @AsciiStrLen(ptr noundef %114)
  %116 = add i64 %115, 1
  %117 = load ptr, ptr %11, align 8, !tbaa !5
  %118 = getelementptr inbounds i8, ptr %117, i64 %116
  store ptr %118, ptr %11, align 8, !tbaa !5
  store i64 0, ptr %15, align 8, !tbaa !24
  br label %119

119:                                              ; preds = %159, %92
  %120 = load i64, ptr %15, align 8, !tbaa !24
  %121 = load ptr, ptr %8, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %121, i32 0, i32 5
  %123 = load i32, ptr %122, align 8, !tbaa !25
  %124 = zext i32 %123 to i64
  %125 = icmp ult i64 %120, %124
  br i1 %125, label %126, label %162

126:                                              ; preds = %119
  %127 = load ptr, ptr %11, align 8, !tbaa !5
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = load i64, ptr %15, align 8, !tbaa !24
  %130 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %128, i64 %129
  %131 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %130, i32 0, i32 0
  %132 = load ptr, ptr %131, align 8, !tbaa !26
  %133 = call ptr @AsciiStrCpy(ptr noundef %127, ptr noundef %132)
  store ptr %133, ptr %11, align 8, !tbaa !5
  %134 = load ptr, ptr %7, align 8, !tbaa !5
  %135 = load i64, ptr %15, align 8, !tbaa !24
  %136 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %134, i64 %135
  %137 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %136, i32 0, i32 0
  %138 = load ptr, ptr %137, align 8, !tbaa !26
  %139 = call i64 @AsciiStrLen(ptr noundef %138)
  %140 = add i64 %139, 1
  %141 = load ptr, ptr %11, align 8, !tbaa !5
  %142 = getelementptr inbounds i8, ptr %141, i64 %140
  store ptr %142, ptr %11, align 8, !tbaa !5
  %143 = load ptr, ptr %11, align 8, !tbaa !5
  %144 = load ptr, ptr %7, align 8, !tbaa !5
  %145 = load i64, ptr %15, align 8, !tbaa !24
  %146 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %144, i64 %145
  %147 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %146, i32 0, i32 1
  %148 = load ptr, ptr %147, align 8, !tbaa !28
  %149 = call ptr @AsciiStrCpy(ptr noundef %143, ptr noundef %148)
  store ptr %149, ptr %11, align 8, !tbaa !5
  %150 = load ptr, ptr %7, align 8, !tbaa !5
  %151 = load i64, ptr %15, align 8, !tbaa !24
  %152 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %150, i64 %151
  %153 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %152, i32 0, i32 1
  %154 = load ptr, ptr %153, align 8, !tbaa !28
  %155 = call i64 @AsciiStrLen(ptr noundef %154)
  %156 = add i64 %155, 1
  %157 = load ptr, ptr %11, align 8, !tbaa !5
  %158 = getelementptr inbounds i8, ptr %157, i64 %156
  store ptr %158, ptr %11, align 8, !tbaa !5
  br label %159

159:                                              ; preds = %126
  %160 = load i64, ptr %15, align 8, !tbaa !24
  %161 = add i64 %160, 1
  store i64 %161, ptr %15, align 8, !tbaa !24
  br label %119, !llvm.loop !32

162:                                              ; preds = %119
  %163 = load ptr, ptr %4, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %163, i32 0, i32 18
  %165 = load ptr, ptr %164, align 8, !tbaa !33
  %166 = icmp ne ptr %165, null
  br i1 %166, label %167, label %171

167:                                              ; preds = %162
  %168 = load ptr, ptr %4, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %168, i32 0, i32 18
  %170 = load ptr, ptr %169, align 8, !tbaa !33
  call void @NetbufFree(ptr noundef %170)
  br label %171

171:                                              ; preds = %167, %162
  %172 = load ptr, ptr %9, align 8, !tbaa !5
  %173 = load ptr, ptr %4, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %173, i32 0, i32 18
  store ptr %172, ptr %174, align 8, !tbaa !33
  %175 = load ptr, ptr %4, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %175, i32 0, i32 19
  store i32 0, ptr %176, align 8, !tbaa !34
  %177 = load ptr, ptr %4, align 8, !tbaa !5
  %178 = load ptr, ptr %9, align 8, !tbaa !5
  %179 = call i64 @Mtftp6TransmitPacket(ptr noundef %177, ptr noundef %178)
  store i64 %179, ptr %3, align 8
  store i32 1, ptr %16, align 4
  br label %180

180:                                              ; preds = %171, %77
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %181 = load i64, ptr %3, align 8
  ret i64 %181
}

declare i64 @AsciiStrLen(ptr noundef) #2

declare ptr @NetbufAlloc(i32 noundef) #2

declare ptr @NetbufAllocSpace(ptr noundef, i32 noundef, i8 noundef zeroext) #2

declare zeroext i8 @DebugAssertEnabled() #2

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

declare zeroext i16 @SwapBytes16(i16 noundef zeroext) #2

declare ptr @AsciiStrCpy(ptr noundef, ptr noundef) #2

declare void @NetbufFree(ptr noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !6, i64 112}
!12 = !{!"_MTFTP6_INSTANCE", !13, i64 0, !6, i64 8, !14, i64 16, !15, i64 32, !6, i64 96, !6, i64 104, !6, i64 112, !16, i64 120, !10, i64 152, !10, i64 154, !14, i64 160, !17, i64 176, !10, i64 192, !10, i64 194, !6, i64 200, !17, i64 208, !10, i64 224, !6, i64 232, !6, i64 240, !13, i64 248, !13, i64 252, !13, i64 256, !13, i64 260, !18, i64 264, !7, i64 272, !7, i64 273, !7, i64 274}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"_EFI_MTFTP6_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}
!16 = !{!"", !10, i64 0, !7, i64 2, !13, i64 4, !17, i64 8, !10, i64 24, !7, i64 26, !13, i64 28}
!17 = !{!"", !7, i64 0}
!18 = !{!"long long", !7, i64 0}
!19 = !{!20, !6, i64 48}
!20 = !{!"_EFI_MTFTP6_TOKEN", !18, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !6, i64 48, !18, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!21 = !{!20, !6, i64 32}
!22 = !{!20, !6, i64 24}
!23 = !{!13, !13, i64 0}
!24 = !{!18, !18, i64 0}
!25 = !{!20, !13, i64 40}
!26 = !{!27, !6, i64 0}
!27 = !{!"", !6, i64 0, !6, i64 8}
!28 = !{!27, !6, i64 8}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!7, !7, i64 0}
!32 = distinct !{!32, !30}
!33 = !{!12, !6, i64 240}
!34 = !{!12, !13, i64 248}


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

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [138 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @Mtftp6SendRequest(ptr noundef %0, i16 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 112
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 48
  %6 = load ptr, ptr %5, align 8, !tbaa !17
  %7 = getelementptr inbounds i8, ptr %4, i64 32
  %8 = load ptr, ptr %7, align 8, !tbaa !19
  %9 = icmp eq ptr %8, null
  %spec.store.select = select i1 %9, ptr @.str, ptr %8
  %10 = getelementptr inbounds i8, ptr %4, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !20
  %12 = tail call i64 @AsciiStrLen(ptr noundef %11) #2
  %13 = trunc i64 %12 to i32
  %14 = tail call i64 @AsciiStrLen(ptr noundef nonnull %spec.store.select) #2
  %15 = trunc i64 %14 to i32
  %16 = add i32 %13, 4
  %17 = add i32 %16, %15
  %18 = getelementptr inbounds i8, ptr %4, i64 40
  %19 = load i32, ptr %18, align 8, !tbaa !21
  %.not68 = icmp eq i32 %19, 0
  br i1 %.not68, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.062 = phi i64 [ %31, %.lr.ph ], [ 0, %2 ]
  %.05661 = phi i32 [ %30, %.lr.ph ], [ %17, %2 ]
  %20 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %6, i64 %.062
  %21 = load ptr, ptr %20, align 8, !tbaa !22
  %22 = tail call i64 @AsciiStrLen(ptr noundef %21) #2
  %23 = trunc i64 %22 to i32
  %24 = getelementptr inbounds i8, ptr %20, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !24
  %26 = tail call i64 @AsciiStrLen(ptr noundef %25) #2
  %27 = trunc i64 %26 to i32
  %28 = add i32 %.05661, 2
  %29 = add i32 %28, %23
  %30 = add i32 %29, %27
  %31 = add nuw nsw i64 %.062, 1
  %32 = load i32, ptr %18, align 8, !tbaa !21
  %33 = zext i32 %32 to i64
  %34 = icmp ult i64 %31, %33
  br i1 %34, label %.lr.ph, label %._crit_edge, !llvm.loop !25

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.056.lcssa = phi i32 [ %17, %2 ], [ %30, %.lr.ph ]
  %35 = tail call ptr @NetbufAlloc(i32 noundef %.056.lcssa) #2
  %36 = icmp eq ptr %35, null
  br i1 %36, label %79, label %37

37:                                               ; preds = %._crit_edge
  %38 = tail call ptr @NetbufAllocSpace(ptr noundef nonnull %35, i32 noundef %.056.lcssa, i8 noundef zeroext 0) #2
  %39 = tail call zeroext i8 @DebugAssertEnabled() #2
  %40 = icmp eq i8 %39, 0
  %41 = icmp ne ptr %38, null
  %or.cond = select i1 %40, i1 true, i1 %41
  br i1 %or.cond, label %43, label %42

42:                                               ; preds = %37
  tail call void @DebugAssert(ptr noundef nonnull @.str.1, i64 noundef 511, ptr noundef nonnull @.str.2) #2
  br label %43

43:                                               ; preds = %42, %37
  %44 = tail call zeroext i16 @SwapBytes16(i16 noundef zeroext %1) #2
  store i16 %44, ptr %38, align 1, !tbaa !27
  %45 = getelementptr inbounds i8, ptr %38, i64 2
  %46 = load ptr, ptr %10, align 8, !tbaa !20
  %47 = tail call ptr @AsciiStrCpy(ptr noundef nonnull %45, ptr noundef %46) #2
  %48 = load ptr, ptr %10, align 8, !tbaa !20
  %49 = tail call i64 @AsciiStrLen(ptr noundef %48) #2
  %50 = getelementptr i8, ptr %47, i64 %49
  %51 = getelementptr i8, ptr %50, i64 1
  %52 = tail call ptr @AsciiStrCpy(ptr noundef %51, ptr noundef nonnull %spec.store.select) #2
  %53 = tail call i64 @AsciiStrLen(ptr noundef nonnull %spec.store.select) #2
  %54 = load i32, ptr %18, align 8, !tbaa !21
  %.not69 = icmp eq i32 %54, 0
  br i1 %.not69, label %._crit_edge67, label %.lr.ph66.preheader

.lr.ph66.preheader:                               ; preds = %43
  %55 = getelementptr i8, ptr %52, i64 %53
  br label %.lr.ph66

.lr.ph66:                                         ; preds = %.lr.ph66.preheader, %.lr.ph66
  %.164 = phi i64 [ %69, %.lr.ph66 ], [ 0, %.lr.ph66.preheader ]
  %.pn63 = phi ptr [ %68, %.lr.ph66 ], [ %55, %.lr.ph66.preheader ]
  %.057 = getelementptr i8, ptr %.pn63, i64 1
  %56 = getelementptr inbounds %struct.EFI_MTFTP6_OPTION, ptr %6, i64 %.164
  %57 = load ptr, ptr %56, align 8, !tbaa !22
  %58 = tail call ptr @AsciiStrCpy(ptr noundef %.057, ptr noundef %57) #2
  %59 = load ptr, ptr %56, align 8, !tbaa !22
  %60 = tail call i64 @AsciiStrLen(ptr noundef %59) #2
  %61 = getelementptr i8, ptr %58, i64 %60
  %62 = getelementptr i8, ptr %61, i64 1
  %63 = getelementptr inbounds i8, ptr %56, i64 8
  %64 = load ptr, ptr %63, align 8, !tbaa !24
  %65 = tail call ptr @AsciiStrCpy(ptr noundef %62, ptr noundef %64) #2
  %66 = load ptr, ptr %63, align 8, !tbaa !24
  %67 = tail call i64 @AsciiStrLen(ptr noundef %66) #2
  %68 = getelementptr i8, ptr %65, i64 %67
  %69 = add nuw nsw i64 %.164, 1
  %70 = load i32, ptr %18, align 8, !tbaa !21
  %71 = zext i32 %70 to i64
  %72 = icmp ult i64 %69, %71
  br i1 %72, label %.lr.ph66, label %._crit_edge67, !llvm.loop !28

._crit_edge67:                                    ; preds = %.lr.ph66, %43
  %73 = getelementptr inbounds i8, ptr %0, i64 240
  %74 = load ptr, ptr %73, align 8, !tbaa !29
  %.not = icmp eq ptr %74, null
  br i1 %.not, label %76, label %75

75:                                               ; preds = %._crit_edge67
  tail call void @NetbufFree(ptr noundef nonnull %74) #2
  br label %76

76:                                               ; preds = %75, %._crit_edge67
  store ptr %35, ptr %73, align 8, !tbaa !29
  %77 = getelementptr inbounds i8, ptr %0, i64 248
  store i32 0, ptr %77, align 8, !tbaa !30
  %78 = tail call i64 @Mtftp6TransmitPacket(ptr noundef nonnull %0, ptr noundef nonnull %35)
  br label %79

79:                                               ; preds = %._crit_edge, %76
  %.058 = phi i64 [ %78, %76 ], [ -9223372036854775799, %._crit_edge ]
  ret i64 %.058
}

declare i64 @AsciiStrLen(ptr noundef) local_unnamed_addr #1

declare ptr @NetbufAlloc(i32 noundef) local_unnamed_addr #1

declare ptr @NetbufAllocSpace(ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

declare zeroext i16 @SwapBytes16(i16 noundef zeroext) local_unnamed_addr #1

declare ptr @AsciiStrCpy(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @NetbufFree(ptr noundef) local_unnamed_addr #1

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

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 = { "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 }

!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, !10, i64 112}
!6 = !{!"_MTFTP6_INSTANCE", !7, i64 0, !10, i64 8, !11, i64 16, !12, i64 32, !10, i64 96, !10, i64 104, !10, i64 112, !13, i64 120, !14, i64 152, !14, i64 154, !11, i64 160, !15, i64 176, !14, i64 192, !14, i64 194, !10, i64 200, !15, i64 208, !14, i64 224, !10, i64 232, !10, i64 240, !7, i64 248, !7, i64 252, !7, i64 256, !7, i64 260, !16, i64 264, !8, i64 272, !8, i64 273, !8, i64 274}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}
!12 = !{!"_EFI_MTFTP6_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!13 = !{!"", !14, i64 0, !8, i64 2, !7, i64 4, !15, i64 8, !14, i64 24, !8, i64 26, !7, i64 28}
!14 = !{!"short", !8, i64 0}
!15 = !{!"", !8, i64 0}
!16 = !{!"long long", !8, i64 0}
!17 = !{!18, !10, i64 48}
!18 = !{!"_EFI_MTFTP6_TOKEN", !16, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40, !10, i64 48, !16, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96}
!19 = !{!18, !10, i64 32}
!20 = !{!18, !10, i64 24}
!21 = !{!18, !7, i64 40}
!22 = !{!23, !10, i64 0}
!23 = !{!"", !10, i64 0, !10, i64 8}
!24 = !{!23, !10, i64 8}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!8, !8, i64 0}
!28 = distinct !{!28, !26}
!29 = !{!6, !10, i64 240}
!30 = !{!6, !7, i64 248}


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