; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/ShellPkg/Library (HFileImageSave)

; 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.HEFI_EDITOR_FILE_IMAGE = type { ptr, i64, i8 }
%struct.HEFI_EDITOR_BUFFER_IMAGE = type { ptr, ptr, i64, ptr, %struct.HEFI_EDITOR_POSITION, %struct.HEFI_EDITOR_POSITION, %struct.HEFI_EDITOR_POSITION, i64, i8, i8, i32, ptr, ptr, ptr }
%struct.HEFI_EDITOR_POSITION = type { i64, i64 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct._HEFI_EDITOR_LINE = type { i64, [16 x i8], i64, %struct._LIST_ENTRY }

@HFileImage = external dso_local global %struct.HEFI_EDITOR_FILE_IMAGE, align 8
@HBufferImage = external global %struct.HEFI_EDITOR_BUFFER_IMAGE, align 8
@.str.4 = external hidden unnamed_addr constant [165 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i32], align 4
@.str.7 = external hidden unnamed_addr constant [27 x i32], align 4
@.str.8 = external hidden unnamed_addr constant [18 x i32], align 4
@.str.9 = external hidden unnamed_addr constant [19 x i32], align 4
@.str.10 = external hidden unnamed_addr constant [15 x i32], align 4

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

declare void @FreePool(ptr noundef) #0

declare ptr @CatSPrint(ptr noundef, ptr noundef, ...) #0

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

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

declare ptr @AllocateZeroPool(i64 noundef) #0

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

declare i64 @StatusBarSetStatusString(ptr noundef) #0

declare zeroext i8 @DebugAssertEnabled() #0

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

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

18:                                               ; preds = %1
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %43

21:                                               ; preds = %18
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = load ptr, ptr @HFileImage, align 8, !tbaa !15
  %24 = call i64 @StrCmp(ptr noundef %22, ptr noundef %23)
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %43

26:                                               ; preds = %21
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = call i64 @ShellIsFile(ptr noundef %27)
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %30, label %42

30:                                               ; preds = %26
  %31 = load i8, ptr getelementptr inbounds (%struct.HEFI_EDITOR_BUFFER_IMAGE, ptr @HBufferImage, i32 0, i32 9), align 1, !tbaa !17
  %32 = zext i8 %31 to i32
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  store i64 0, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %214

35:                                               ; preds = %30
  %36 = load i8, ptr getelementptr inbounds (%struct.HEFI_EDITOR_FILE_IMAGE, ptr @HFileImage, i32 0, i32 2), align 8, !tbaa !18
  %37 = zext i8 %36 to i32
  %38 = icmp eq i32 %37, 1
  br i1 %38, label %39, label %41

39:                                               ; preds = %35
  %40 = call i64 @StatusBarSetStatusString(ptr noundef @.str.6)
  store i64 0, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %214

41:                                               ; preds = %35
  br label %42

42:                                               ; preds = %41, %26
  br label %43

43:                                               ; preds = %42, %21, %18, %1
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = call i64 @ShellIsDirectory(ptr noundef %44)
  %46 = icmp eq i64 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %43
  %48 = call i64 @StatusBarSetStatusString(ptr noundef @.str.7)
  store i64 -9223372036854775807, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %214

49:                                               ; preds = %43
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call i64 @ShellOpenFileByName(ptr noundef %50, ptr noundef %9, i64 noundef 3, i64 noundef 0)
  store i64 %51, ptr %7, align 8, !tbaa !19
  %52 = load i64, ptr %7, align 8, !tbaa !19
  %53 = icmp slt i64 %52, 0
  br i1 %53, label %64, label %54

54:                                               ; preds = %49
  %55 = call i64 @ShellDeleteFile(ptr noundef %9)
  store i64 %55, ptr %7, align 8, !tbaa !19
  %56 = load i64, ptr %7, align 8, !tbaa !19
  %57 = icmp slt i64 %56, 0
  br i1 %57, label %61, label %58

58:                                               ; preds = %54
  %59 = load i64, ptr %7, align 8, !tbaa !19
  %60 = icmp eq i64 %59, 2
  br i1 %60, label %61, label %63

61:                                               ; preds = %58, %54
  %62 = call i64 @StatusBarSetStatusString(ptr noundef @.str.8)
  store i64 -9223372036854775807, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %214

63:                                               ; preds = %58
  br label %64

64:                                               ; preds = %63, %49
  store i64 0, ptr %8, align 8, !tbaa !19
  store i64 0, ptr %10, align 8, !tbaa !19
  %65 = load ptr, ptr @HBufferImage, align 8, !tbaa !20
  %66 = getelementptr inbounds %struct._LIST_ENTRY, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !21
  store ptr %67, ptr %4, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %106, %64
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load ptr, ptr @HBufferImage, align 8, !tbaa !20
  %71 = icmp ne ptr %69, %70
  br i1 %71, label %72, label %110

72:                                               ; preds = %68
  %73 = call zeroext i8 @DebugAssertEnabled()
  %74 = zext i8 %73 to i32
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %86

76:                                               ; preds = %72
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = ptrtoint ptr %77 to i64
  %79 = sub i64 %78, ptrtoint (ptr getelementptr inbounds (%struct._HEFI_EDITOR_LINE, ptr null, i32 0, i32 3) to i64)
  %80 = inttoptr i64 %79 to ptr
  %81 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %80, i32 0, i32 0
  %82 = load i64, ptr %81, align 8, !tbaa !23
  %83 = icmp ne i64 %82, 1819043173
  br i1 %83, label %84, label %86

84:                                               ; preds = %76
  call void @DebugAssert(ptr noundef @.str.4, i64 noundef 329, ptr noundef @.str.5)
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  br label %91

86:                                               ; preds = %76, %72
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = ptrtoint ptr %87 to i64
  %89 = sub i64 %88, ptrtoint (ptr getelementptr inbounds (%struct._HEFI_EDITOR_LINE, ptr null, i32 0, i32 3) to i64)
  %90 = inttoptr i64 %89 to ptr
  br label %91

91:                                               ; preds = %86, %84
  %92 = phi ptr [ %85, %84 ], [ %90, %86 ]
  store ptr %92, ptr %5, align 8, !tbaa !5
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %93, i32 0, i32 2
  %95 = load i64, ptr %94, align 8, !tbaa !25
  %96 = icmp ne i64 %95, 0
  br i1 %96, label %97, label %103

97:                                               ; preds = %91
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %98, i32 0, i32 2
  %100 = load i64, ptr %99, align 8, !tbaa !25
  %101 = load i64, ptr %10, align 8, !tbaa !19
  %102 = add i64 %101, %100
  store i64 %102, ptr %10, align 8, !tbaa !19
  br label %103

103:                                              ; preds = %97, %91
  %104 = load i64, ptr %8, align 8, !tbaa !19
  %105 = add i64 %104, 1
  store i64 %105, ptr %8, align 8, !tbaa !19
  br label %106

106:                                              ; preds = %103
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._LIST_ENTRY, ptr %107, i32 0, i32 0
  %109 = load ptr, ptr %108, align 8, !tbaa !21
  store ptr %109, ptr %4, align 8, !tbaa !5
  br label %68, !llvm.loop !26

110:                                              ; preds = %68
  %111 = load i64, ptr %10, align 8, !tbaa !19
  %112 = call ptr @AllocateZeroPool(i64 noundef %111)
  store ptr %112, ptr %11, align 8, !tbaa !5
  %113 = load ptr, ptr %11, align 8, !tbaa !5
  %114 = icmp eq ptr %113, null
  br i1 %114, label %115, label %116

115:                                              ; preds = %110
  store i64 -9223372036854775799, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %214

116:                                              ; preds = %110
  %117 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %117, ptr %12, align 8, !tbaa !5
  %118 = load ptr, ptr @HBufferImage, align 8, !tbaa !20
  %119 = getelementptr inbounds %struct._LIST_ENTRY, ptr %118, i32 0, i32 0
  %120 = load ptr, ptr %119, align 8, !tbaa !21
  store ptr %120, ptr %4, align 8, !tbaa !5
  br label %121

121:                                              ; preds = %165, %116
  %122 = load ptr, ptr %4, align 8, !tbaa !5
  %123 = load ptr, ptr @HBufferImage, align 8, !tbaa !20
  %124 = icmp ne ptr %122, %123
  br i1 %124, label %125, label %169

125:                                              ; preds = %121
  %126 = call zeroext i8 @DebugAssertEnabled()
  %127 = zext i8 %126 to i32
  %128 = icmp ne i32 %127, 0
  br i1 %128, label %129, label %139

129:                                              ; preds = %125
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = ptrtoint ptr %130 to i64
  %132 = sub i64 %131, ptrtoint (ptr getelementptr inbounds (%struct._HEFI_EDITOR_LINE, ptr null, i32 0, i32 3) to i64)
  %133 = inttoptr i64 %132 to ptr
  %134 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %133, i32 0, i32 0
  %135 = load i64, ptr %134, align 8, !tbaa !23
  %136 = icmp ne i64 %135, 1819043173
  br i1 %136, label %137, label %139

137:                                              ; preds = %129
  call void @DebugAssert(ptr noundef @.str.4, i64 noundef 349, ptr noundef @.str.5)
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  br label %144

139:                                              ; preds = %129, %125
  %140 = load ptr, ptr %4, align 8, !tbaa !5
  %141 = ptrtoint ptr %140 to i64
  %142 = sub i64 %141, ptrtoint (ptr getelementptr inbounds (%struct._HEFI_EDITOR_LINE, ptr null, i32 0, i32 3) to i64)
  %143 = inttoptr i64 %142 to ptr
  br label %144

144:                                              ; preds = %139, %137
  %145 = phi ptr [ %138, %137 ], [ %143, %139 ]
  store ptr %145, ptr %5, align 8, !tbaa !5
  %146 = load ptr, ptr %5, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %146, i32 0, i32 2
  %148 = load i64, ptr %147, align 8, !tbaa !25
  %149 = icmp ne i64 %148, 0
  br i1 %149, label %150, label %164

150:                                              ; preds = %144
  %151 = load ptr, ptr %12, align 8, !tbaa !5
  %152 = load ptr, ptr %5, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %152, i32 0, i32 1
  %154 = getelementptr inbounds [16 x i8], ptr %153, i64 0, i64 0
  %155 = load ptr, ptr %5, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %155, i32 0, i32 2
  %157 = load i64, ptr %156, align 8, !tbaa !25
  %158 = call ptr @CopyMem(ptr noundef %151, ptr noundef %154, i64 noundef %157)
  %159 = load ptr, ptr %5, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %159, i32 0, i32 2
  %161 = load i64, ptr %160, align 8, !tbaa !25
  %162 = load ptr, ptr %12, align 8, !tbaa !5
  %163 = getelementptr inbounds i8, ptr %162, i64 %161
  store ptr %163, ptr %12, align 8, !tbaa !5
  br label %164

164:                                              ; preds = %150, %144
  br label %165

165:                                              ; preds = %164
  %166 = load ptr, ptr %4, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct._LIST_ENTRY, ptr %166, i32 0, i32 0
  %168 = load ptr, ptr %167, align 8, !tbaa !21
  store ptr %168, ptr %4, align 8, !tbaa !5
  br label %121, !llvm.loop !28

169:                                              ; preds = %121
  %170 = load ptr, ptr %3, align 8, !tbaa !5
  %171 = call i64 @ShellOpenFileByName(ptr noundef %170, ptr noundef %9, i64 noundef -9223372036854775805, i64 noundef 0)
  store i64 %171, ptr %7, align 8, !tbaa !19
  %172 = load i64, ptr %7, align 8, !tbaa !19
  %173 = icmp slt i64 %172, 0
  br i1 %173, label %174, label %176

174:                                              ; preds = %169
  %175 = call i64 @StatusBarSetStatusString(ptr noundef @.str.9)
  store i64 -9223372036854775807, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %214

176:                                              ; preds = %169
  %177 = load ptr, ptr %9, align 8, !tbaa !5
  %178 = load ptr, ptr %11, align 8, !tbaa !5
  %179 = call i64 @ShellWriteFile(ptr noundef %177, ptr noundef %10, ptr noundef %178)
  store i64 %179, ptr %7, align 8, !tbaa !19
  %180 = load ptr, ptr %11, align 8, !tbaa !5
  call void @FreePool(ptr noundef %180)
  %181 = load i64, ptr %7, align 8, !tbaa !19
  %182 = icmp slt i64 %181, 0
  br i1 %182, label %183, label %185

183:                                              ; preds = %176
  %184 = call i64 @ShellDeleteFile(ptr noundef %9)
  store i64 -9223372036854775807, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %214

185:                                              ; preds = %176
  %186 = call i64 @ShellCloseFile(ptr noundef %9)
  store i8 0, ptr getelementptr inbounds (%struct.HEFI_EDITOR_BUFFER_IMAGE, ptr @HBufferImage, i32 0, i32 9), align 1, !tbaa !17
  %187 = load i64, ptr %8, align 8, !tbaa !19
  %188 = call ptr (ptr, ptr, ...) @CatSPrint(ptr noundef null, ptr noundef @.str.10, i64 noundef %187)
  store ptr %188, ptr %6, align 8, !tbaa !5
  %189 = load ptr, ptr %6, align 8, !tbaa !5
  %190 = call i64 @StatusBarSetStatusString(ptr noundef %189)
  %191 = load ptr, ptr %6, align 8, !tbaa !5
  call void @FreePool(ptr noundef %191)
  %192 = load i32, ptr %13, align 4, !tbaa !14
  %193 = icmp ne i32 %192, 5
  br i1 %193, label %194, label %197

194:                                              ; preds = %185
  %195 = load ptr, ptr %3, align 8, !tbaa !5
  %196 = icmp ne ptr %195, null
  br i1 %196, label %206, label %197

197:                                              ; preds = %194, %185
  %198 = load ptr, ptr %3, align 8, !tbaa !5
  %199 = icmp ne ptr %198, null
  br i1 %199, label %200, label %213

200:                                              ; preds = %197
  %201 = load ptr, ptr @HFileImage, align 8, !tbaa !15
  %202 = icmp ne ptr %201, null
  br i1 %202, label %203, label %213

203:                                              ; preds = %200
  %204 = call i64 @StringNoCaseCompare(ptr noundef %3, ptr noundef @HFileImage)
  %205 = icmp ne i64 %204, 0
  br i1 %205, label %206, label %213

206:                                              ; preds = %203, %194
  %207 = load ptr, ptr %3, align 8, !tbaa !5
  %208 = call i64 @HFileImageSetFileName(ptr noundef %207)
  %209 = load ptr, ptr @HFileImage, align 8, !tbaa !15
  %210 = icmp eq ptr %209, null
  br i1 %210, label %211, label %212

211:                                              ; preds = %206
  store i64 -9223372036854775799, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %214

212:                                              ; preds = %206
  br label %213

213:                                              ; preds = %212, %203, %200, %197
  store i8 0, ptr getelementptr inbounds (%struct.HEFI_EDITOR_FILE_IMAGE, ptr @HFileImage, i32 0, i32 2), align 8, !tbaa !18
  store i64 0, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %214

214:                                              ; preds = %213, %211, %183, %174, %115, %61, %47, %39, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %215 = load i64, ptr %2, align 8
  ret i64 %215
}

declare i64 @StrCmp(ptr noundef, ptr noundef) #0

declare i64 @ShellIsFile(ptr noundef) #0

declare i64 @ShellIsDirectory(ptr noundef) #0

declare i64 @ShellOpenFileByName(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #0

declare i64 @ShellDeleteFile(ptr noundef) #0

declare i64 @ShellWriteFile(ptr noundef, ptr noundef, ptr noundef) #0

declare i64 @ShellCloseFile(ptr noundef) #0

declare i64 @StringNoCaseCompare(ptr noundef, ptr noundef) #0

attributes #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !13, i64 92}
!10 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !12, i64 48, !12, i64 64, !11, i64 80, !7, i64 88, !7, i64 89, !13, i64 92, !6, i64 96, !6, i64 104, !6, i64 112}
!11 = !{!"long long", !7, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"", !6, i64 0, !11, i64 8, !7, i64 16}
!17 = !{!10, !7, i64 89}
!18 = !{!16, !7, i64 16}
!19 = !{!11, !11, i64 0}
!20 = !{!10, !6, i64 0}
!21 = !{!22, !6, i64 0}
!22 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!23 = !{!24, !11, i64 0}
!24 = !{!"_HEFI_EDITOR_LINE", !11, i64 0, !7, i64 8, !11, i64 24, !22, i64 32}
!25 = !{!24, !11, i64 24}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}


; 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.HEFI_EDITOR_FILE_IMAGE = type { ptr, i64, i8 }
%struct.HEFI_EDITOR_BUFFER_IMAGE = type { ptr, ptr, i64, ptr, %struct.HEFI_EDITOR_POSITION, %struct.HEFI_EDITOR_POSITION, %struct.HEFI_EDITOR_POSITION, i64, i8, i8, i32, ptr, ptr, ptr }
%struct.HEFI_EDITOR_POSITION = type { i64, i64 }

@HFileImage = external dso_local global %struct.HEFI_EDITOR_FILE_IMAGE, align 8
@HBufferImage = external local_unnamed_addr global %struct.HEFI_EDITOR_BUFFER_IMAGE, align 8
@.str.4 = external hidden unnamed_addr constant [165 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i32], align 4
@.str.7 = external hidden unnamed_addr constant [27 x i32], align 4
@.str.8 = external hidden unnamed_addr constant [18 x i32], align 4
@.str.9 = external hidden unnamed_addr constant [19 x i32], align 4
@.str.10 = external hidden unnamed_addr constant [15 x i32], align 4

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

declare void @FreePool(ptr noundef) local_unnamed_addr #0

declare ptr @CatSPrint(ptr noundef, ptr noundef, ...) local_unnamed_addr #0

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

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

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #0

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

declare i64 @StatusBarSetStatusString(ptr noundef) local_unnamed_addr #0

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775807, 1) i64 @HFileImageSave(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @HBufferImage, i64 92), align 4, !tbaa !9
  store i32 5, ptr getelementptr inbounds (i8, ptr @HBufferImage, i64 92), align 4, !tbaa !9
  %6 = load ptr, ptr @HFileImage, align 8, !tbaa !14
  %7 = icmp ne ptr %6, null
  %8 = icmp ne ptr %0, null
  %or.cond = and i1 %8, %7
  br i1 %or.cond, label %9, label %23

9:                                                ; preds = %1
  %10 = tail call i64 @StrCmp(ptr noundef nonnull %0, ptr noundef nonnull %6) #3
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %12, label %23

12:                                               ; preds = %9
  %13 = tail call i64 @ShellIsFile(ptr noundef nonnull %0) #3
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %15, label %23

15:                                               ; preds = %12
  %16 = load i8, ptr getelementptr inbounds (i8, ptr @HBufferImage, i64 89), align 1, !tbaa !16
  %17 = icmp eq i8 %16, 0
  br i1 %17, label %100, label %18

18:                                               ; preds = %15
  %19 = load i8, ptr getelementptr inbounds (i8, ptr @HFileImage, i64 16), align 8, !tbaa !17
  %20 = icmp eq i8 %19, 1
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = tail call i64 @StatusBarSetStatusString(ptr noundef nonnull @.str.6) #3
  br label %100

23:                                               ; preds = %12, %18, %9, %1
  %24 = tail call i64 @ShellIsDirectory(ptr noundef %0) #3
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  %27 = tail call i64 @StatusBarSetStatusString(ptr noundef nonnull @.str.7) #3
  br label %100

28:                                               ; preds = %23
  %29 = call i64 @ShellOpenFileByName(ptr noundef %0, ptr noundef nonnull %3, i64 noundef 3, i64 noundef 0) #3
  %30 = icmp slt i64 %29, 0
  br i1 %30, label %37, label %31

31:                                               ; preds = %28
  %32 = call i64 @ShellDeleteFile(ptr noundef nonnull %3) #3
  %33 = icmp slt i64 %32, 0
  %34 = icmp eq i64 %32, 2
  %or.cond3 = or i1 %33, %34
  br i1 %or.cond3, label %35, label %37

35:                                               ; preds = %31
  %36 = call i64 @StatusBarSetStatusString(ptr noundef nonnull @.str.8) #3
  br label %100

37:                                               ; preds = %31, %28
  store i64 0, ptr %4, align 8, !tbaa !18
  %38 = load ptr, ptr @HBufferImage, align 8, !tbaa !19
  %.04056 = load ptr, ptr %38, align 8, !tbaa !20
  %.not57 = icmp eq ptr %.04056, %38
  br i1 %.not57, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %37, %49
  %39 = phi i64 [ %50, %49 ], [ 0, %37 ]
  %.04059 = phi ptr [ %.040, %49 ], [ %.04056, %37 ]
  %.04258 = phi i64 [ %51, %49 ], [ 0, %37 ]
  %40 = call zeroext i8 @DebugAssertEnabled() #3
  %.not53 = icmp eq i8 %40, 0
  %.pre74 = ptrtoint ptr %.04059 to i64
  %.pre76 = add i64 %.pre74, -32
  %.pre78 = inttoptr i64 %.pre76 to ptr
  br i1 %.not53, label %.lr.ph._crit_edge, label %41

41:                                               ; preds = %.lr.ph
  %42 = load i64, ptr %.pre78, align 8, !tbaa !22
  %.not54 = icmp eq i64 %42, 1819043173
  br i1 %.not54, label %.lr.ph._crit_edge, label %43

43:                                               ; preds = %41
  call void @DebugAssert(ptr noundef nonnull @.str.4, i64 noundef 329, ptr noundef nonnull @.str.5) #3
  br label %.lr.ph._crit_edge

.lr.ph._crit_edge:                                ; preds = %.lr.ph, %41, %43
  %44 = phi ptr [ %.04059, %43 ], [ %.pre78, %41 ], [ %.pre78, %.lr.ph ]
  %45 = getelementptr inbounds i8, ptr %44, i64 24
  %46 = load i64, ptr %45, align 8, !tbaa !24
  %.not55 = icmp eq i64 %46, 0
  br i1 %.not55, label %49, label %47

47:                                               ; preds = %.lr.ph._crit_edge
  %48 = add i64 %39, %46
  store i64 %48, ptr %4, align 8, !tbaa !18
  br label %49

49:                                               ; preds = %47, %.lr.ph._crit_edge
  %50 = phi i64 [ %48, %47 ], [ %39, %.lr.ph._crit_edge ]
  %51 = add i64 %.04258, 1
  %.040 = load ptr, ptr %.04059, align 8, !tbaa !20
  %52 = load ptr, ptr @HBufferImage, align 8, !tbaa !19
  %.not = icmp eq ptr %.040, %52
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !25

._crit_edge:                                      ; preds = %49, %37
  %53 = phi i64 [ 0, %37 ], [ %50, %49 ]
  %.042.lcssa = phi i64 [ 0, %37 ], [ %51, %49 ]
  %54 = call ptr @AllocateZeroPool(i64 noundef %53) #3
  %55 = icmp eq ptr %54, null
  br i1 %55, label %100, label %56

56:                                               ; preds = %._crit_edge
  %57 = load ptr, ptr @HBufferImage, align 8, !tbaa !19
  %.14160 = load ptr, ptr %57, align 8, !tbaa !20
  %.not4861 = icmp eq ptr %.14160, %57
  br i1 %.not4861, label %._crit_edge66, label %.lr.ph65

.lr.ph65:                                         ; preds = %56, %70
  %.14163 = phi ptr [ %.141, %70 ], [ %.14160, %56 ]
  %.03962 = phi ptr [ %.1, %70 ], [ %54, %56 ]
  %58 = call zeroext i8 @DebugAssertEnabled() #3
  %.not50 = icmp eq i8 %58, 0
  %.pre69 = ptrtoint ptr %.14163 to i64
  %.pre70 = add i64 %.pre69, -32
  %.pre72 = inttoptr i64 %.pre70 to ptr
  br i1 %.not50, label %.lr.ph65._crit_edge, label %59

59:                                               ; preds = %.lr.ph65
  %60 = load i64, ptr %.pre72, align 8, !tbaa !22
  %.not51 = icmp eq i64 %60, 1819043173
  br i1 %.not51, label %.lr.ph65._crit_edge, label %61

61:                                               ; preds = %59
  call void @DebugAssert(ptr noundef nonnull @.str.4, i64 noundef 349, ptr noundef nonnull @.str.5) #3
  br label %.lr.ph65._crit_edge

.lr.ph65._crit_edge:                              ; preds = %.lr.ph65, %59, %61
  %62 = phi ptr [ %.14163, %61 ], [ %.pre72, %59 ], [ %.pre72, %.lr.ph65 ]
  %63 = getelementptr inbounds i8, ptr %62, i64 24
  %64 = load i64, ptr %63, align 8, !tbaa !24
  %.not52 = icmp eq i64 %64, 0
  br i1 %.not52, label %70, label %65

65:                                               ; preds = %.lr.ph65._crit_edge
  %66 = getelementptr inbounds i8, ptr %62, i64 8
  %67 = call ptr @CopyMem(ptr noundef %.03962, ptr noundef nonnull %66, i64 noundef %64) #3
  %68 = load i64, ptr %63, align 8, !tbaa !24
  %69 = getelementptr inbounds i8, ptr %.03962, i64 %68
  br label %70

70:                                               ; preds = %.lr.ph65._crit_edge, %65
  %.1 = phi ptr [ %69, %65 ], [ %.03962, %.lr.ph65._crit_edge ]
  %.141 = load ptr, ptr %.14163, align 8, !tbaa !20
  %71 = load ptr, ptr @HBufferImage, align 8, !tbaa !19
  %.not48 = icmp eq ptr %.141, %71
  br i1 %.not48, label %._crit_edge66.loopexit, label %.lr.ph65, !llvm.loop !27

._crit_edge66.loopexit:                           ; preds = %70
  %.pre = load ptr, ptr %2, align 8
  br label %._crit_edge66

._crit_edge66:                                    ; preds = %._crit_edge66.loopexit, %56
  %72 = phi ptr [ %.pre, %._crit_edge66.loopexit ], [ %0, %56 ]
  %73 = call i64 @ShellOpenFileByName(ptr noundef %72, ptr noundef nonnull %3, i64 noundef -9223372036854775805, i64 noundef 0) #3
  %74 = icmp slt i64 %73, 0
  br i1 %74, label %75, label %77

75:                                               ; preds = %._crit_edge66
  %76 = call i64 @StatusBarSetStatusString(ptr noundef nonnull @.str.9) #3
  br label %100

77:                                               ; preds = %._crit_edge66
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = call i64 @ShellWriteFile(ptr noundef %78, ptr noundef nonnull %4, ptr noundef nonnull %54) #3
  call void @FreePool(ptr noundef nonnull %54) #3
  %80 = icmp slt i64 %79, 0
  br i1 %80, label %81, label %83

81:                                               ; preds = %77
  %82 = call i64 @ShellDeleteFile(ptr noundef nonnull %3) #3
  br label %100

83:                                               ; preds = %77
  %84 = call i64 @ShellCloseFile(ptr noundef nonnull %3) #3
  store i8 0, ptr getelementptr inbounds (i8, ptr @HBufferImage, i64 89), align 1, !tbaa !16
  %85 = call ptr (ptr, ptr, ...) @CatSPrint(ptr noundef null, ptr noundef nonnull @.str.10, i64 noundef %.042.lcssa) #3
  %86 = call i64 @StatusBarSetStatusString(ptr noundef %85) #3
  call void @FreePool(ptr noundef %85) #3
  %87 = icmp ne i32 %5, 5
  %88 = icmp ne ptr %72, null
  %or.cond5 = and i1 %87, %88
  br i1 %or.cond5, label %94, label %89

89:                                               ; preds = %83
  %90 = load ptr, ptr @HFileImage, align 8
  %91 = icmp ne ptr %90, null
  %or.cond7 = select i1 %88, i1 %91, i1 false
  br i1 %or.cond7, label %92, label %99

92:                                               ; preds = %89
  %93 = call i64 @StringNoCaseCompare(ptr noundef nonnull %2, ptr noundef nonnull @HFileImage) #3
  %.not49 = icmp eq i64 %93, 0
  br i1 %.not49, label %99, label %._crit_edge67

._crit_edge67:                                    ; preds = %92
  %.pre68 = load ptr, ptr %2, align 8, !tbaa !5
  br label %94

94:                                               ; preds = %._crit_edge67, %83
  %95 = phi ptr [ %.pre68, %._crit_edge67 ], [ %72, %83 ]
  %96 = call i64 @HFileImageSetFileName(ptr noundef %95)
  %97 = load ptr, ptr @HFileImage, align 8, !tbaa !14
  %98 = icmp eq ptr %97, null
  br i1 %98, label %100, label %99

99:                                               ; preds = %94, %92, %89
  store i8 0, ptr getelementptr inbounds (i8, ptr @HFileImage, i64 16), align 8, !tbaa !17
  br label %100

100:                                              ; preds = %94, %._crit_edge, %15, %99, %81, %75, %35, %26, %21
  %.0 = phi i64 [ 0, %21 ], [ -9223372036854775807, %26 ], [ -9223372036854775807, %75 ], [ -9223372036854775807, %81 ], [ 0, %99 ], [ -9223372036854775807, %35 ], [ 0, %15 ], [ -9223372036854775799, %._crit_edge ], [ -9223372036854775799, %94 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i64 %.0
}

declare i64 @StrCmp(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i64 @ShellIsFile(ptr noundef) local_unnamed_addr #0

declare i64 @ShellIsDirectory(ptr noundef) local_unnamed_addr #0

declare i64 @ShellOpenFileByName(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

declare i64 @ShellDeleteFile(ptr noundef) local_unnamed_addr #0

declare i64 @ShellWriteFile(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare i64 @ShellCloseFile(ptr noundef) local_unnamed_addr #0

declare i64 @StringNoCaseCompare(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !13, i64 92}
!10 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !12, i64 48, !12, i64 64, !11, i64 80, !7, i64 88, !7, i64 89, !13, i64 92, !6, i64 96, !6, i64 104, !6, i64 112}
!11 = !{!"long long", !7, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"", !6, i64 0, !11, i64 8, !7, i64 16}
!16 = !{!10, !7, i64 89}
!17 = !{!15, !7, i64 16}
!18 = !{!11, !11, i64 0}
!19 = !{!10, !6, i64 0}
!20 = !{!21, !6, i64 0}
!21 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!22 = !{!23, !11, i64 0}
!23 = !{!"_HEFI_EDITOR_LINE", !11, i64 0, !7, i64 8, !11, i64 24, !21, i64 32}
!24 = !{!23, !11, i64 24}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}


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