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

; 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_EDITOR_FILE_BUFFER = type { ptr, i32, ptr, ptr, i64, %struct.EFI_EDITOR_POSITION, %struct.EFI_EDITOR_POSITION, %struct.EFI_EDITOR_POSITION, %struct.EFI_EDITOR_POSITION, i8, i8, i8, ptr }
%struct.EFI_EDITOR_POSITION = type { i64, i64 }
%struct.EFI_EDITOR_GLOBAL_EDITOR = type { ptr, %union.EFI_EDITOR_COLOR_UNION, %struct.EFI_EDITOR_POSITION, ptr, i8, ptr, i32, i32 }
%union.EFI_EDITOR_COLOR_UNION = type { i64 }
%struct._EFI_EDITOR_LINE = type { i64, ptr, i64, i64, i32, %struct._LIST_ENTRY }
%struct._LIST_ENTRY = type { ptr, ptr }

@FileBuffer = external dso_local global %struct.EFI_EDITOR_FILE_BUFFER, align 8
@FileBufferOnlyLineNeedRefresh = external dso_local global i8, align 1
@MainEditor = external global %struct.EFI_EDITOR_GLOBAL_EDITOR, align 8

; 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
declare dso_local i64 @FileBufferRestorePosition() #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBufferRefresh() #1

declare ptr @ReallocatePool(i64 noundef, i64 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @FileBufferReplace(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !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
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call i64 @StrLen(ptr noundef %13)
  store i64 %14, ptr %6, align 8, !tbaa !9
  %15 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %16 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %15, i32 0, i32 2
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = add i64 %17, 1
  store i64 %18, ptr %10, align 8, !tbaa !9
  %19 = load i64, ptr %10, align 8, !tbaa !9
  %20 = load i64, ptr %6, align 8, !tbaa !9
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = sub i64 %20, %21
  %23 = add i64 %19, %22
  store i64 %23, ptr %9, align 8, !tbaa !9
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = load i64, ptr %5, align 8, !tbaa !9
  %26 = icmp ugt i64 %24, %25
  br i1 %26, label %27, label %111

27:                                               ; preds = %2
  %28 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %29 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %28, i32 0, i32 3
  %30 = load i64, ptr %29, align 8, !tbaa !18
  %31 = add i64 %30, 1
  %32 = load i64, ptr %9, align 8, !tbaa !9
  %33 = icmp ule i64 %31, %32
  br i1 %33, label %34, label %49

34:                                               ; preds = %27
  %35 = load i64, ptr %10, align 8, !tbaa !9
  %36 = mul i64 2, %35
  %37 = load i64, ptr %9, align 8, !tbaa !9
  %38 = mul i64 2, %37
  %39 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %40 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !19
  %42 = call ptr @ReallocatePool(i64 noundef %36, i64 noundef %38, ptr noundef %41)
  %43 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %44 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %43, i32 0, i32 1
  store ptr %42, ptr %44, align 8, !tbaa !19
  %45 = load i64, ptr %9, align 8, !tbaa !9
  %46 = sub i64 %45, 1
  %47 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %48 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %47, i32 0, i32 3
  store i64 %46, ptr %48, align 8, !tbaa !18
  br label %49

49:                                               ; preds = %34, %27
  %50 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %51 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %50, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !19
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %49
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %219

55:                                               ; preds = %49
  %56 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %57 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !19
  %59 = load i64, ptr %9, align 8, !tbaa !9
  %60 = sub i64 %59, 1
  %61 = getelementptr inbounds i16, ptr %58, i64 %60
  store ptr %61, ptr %8, align 8, !tbaa !5
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = load i64, ptr %5, align 8, !tbaa !9
  %64 = sub i64 %62, %63
  store i64 %64, ptr %11, align 8, !tbaa !9
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %85, %55
  %66 = load i64, ptr %7, align 8, !tbaa !9
  %67 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %68 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %67, i32 0, i32 2
  %69 = load i64, ptr %68, align 8, !tbaa !15
  %70 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 6), i32 0, i32 1), align 8, !tbaa !20
  %71 = sub i64 %69, %70
  %72 = load i64, ptr %5, align 8, !tbaa !9
  %73 = sub i64 %71, %72
  %74 = add i64 %73, 2
  %75 = icmp ult i64 %66, %74
  br i1 %75, label %76, label %88

76:                                               ; preds = %65
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = load i64, ptr %11, align 8, !tbaa !9
  %79 = sub i64 0, %78
  %80 = getelementptr inbounds i16, ptr %77, i64 %79
  %81 = load i16, ptr %80, align 2, !tbaa !21
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  store i16 %81, ptr %82, align 2, !tbaa !21
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds i16, ptr %83, i32 -1
  store ptr %84, ptr %8, align 8, !tbaa !5
  br label %85

85:                                               ; preds = %76
  %86 = load i64, ptr %7, align 8, !tbaa !9
  %87 = add i64 %86, 1
  store i64 %87, ptr %7, align 8, !tbaa !9
  br label %65, !llvm.loop !23

88:                                               ; preds = %65
  %89 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %90 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !19
  %92 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 6), i32 0, i32 1), align 8, !tbaa !20
  %93 = getelementptr inbounds i16, ptr %91, i64 %92
  %94 = getelementptr inbounds i16, ptr %93, i64 -1
  store ptr %94, ptr %8, align 8, !tbaa !5
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %95

95:                                               ; preds = %107, %88
  %96 = load i64, ptr %7, align 8, !tbaa !9
  %97 = load i64, ptr %6, align 8, !tbaa !9
  %98 = icmp ult i64 %96, %97
  br i1 %98, label %99, label %110

99:                                               ; preds = %95
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = load i64, ptr %7, align 8, !tbaa !9
  %102 = getelementptr inbounds i16, ptr %100, i64 %101
  %103 = load i16, ptr %102, align 2, !tbaa !21
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = load i64, ptr %7, align 8, !tbaa !9
  %106 = getelementptr inbounds i16, ptr %104, i64 %105
  store i16 %103, ptr %106, align 2, !tbaa !21
  br label %107

107:                                              ; preds = %99
  %108 = load i64, ptr %7, align 8, !tbaa !9
  %109 = add i64 %108, 1
  store i64 %109, ptr %7, align 8, !tbaa !9
  br label %95, !llvm.loop !25

110:                                              ; preds = %95
  br label %111

111:                                              ; preds = %110, %2
  %112 = load i64, ptr %6, align 8, !tbaa !9
  %113 = load i64, ptr %5, align 8, !tbaa !9
  %114 = icmp ult i64 %112, %113
  br i1 %114, label %115, label %167

115:                                              ; preds = %111
  %116 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %117 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %116, i32 0, i32 1
  %118 = load ptr, ptr %117, align 8, !tbaa !19
  %119 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 6), i32 0, i32 1), align 8, !tbaa !20
  %120 = getelementptr inbounds i16, ptr %118, i64 %119
  %121 = getelementptr inbounds i16, ptr %120, i64 -1
  store ptr %121, ptr %8, align 8, !tbaa !5
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %122

122:                                              ; preds = %134, %115
  %123 = load i64, ptr %7, align 8, !tbaa !9
  %124 = load i64, ptr %6, align 8, !tbaa !9
  %125 = icmp ult i64 %123, %124
  br i1 %125, label %126, label %137

126:                                              ; preds = %122
  %127 = load ptr, ptr %4, align 8, !tbaa !5
  %128 = load i64, ptr %7, align 8, !tbaa !9
  %129 = getelementptr inbounds i16, ptr %127, i64 %128
  %130 = load i16, ptr %129, align 2, !tbaa !21
  %131 = load ptr, ptr %8, align 8, !tbaa !5
  %132 = load i64, ptr %7, align 8, !tbaa !9
  %133 = getelementptr inbounds i16, ptr %131, i64 %132
  store i16 %130, ptr %133, align 2, !tbaa !21
  br label %134

134:                                              ; preds = %126
  %135 = load i64, ptr %7, align 8, !tbaa !9
  %136 = add i64 %135, 1
  store i64 %136, ptr %7, align 8, !tbaa !9
  br label %122, !llvm.loop !26

137:                                              ; preds = %122
  %138 = load i64, ptr %6, align 8, !tbaa !9
  %139 = load ptr, ptr %8, align 8, !tbaa !5
  %140 = getelementptr inbounds i16, ptr %139, i64 %138
  store ptr %140, ptr %8, align 8, !tbaa !5
  %141 = load i64, ptr %5, align 8, !tbaa !9
  %142 = load i64, ptr %6, align 8, !tbaa !9
  %143 = sub i64 %141, %142
  store i64 %143, ptr %11, align 8, !tbaa !9
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %144

144:                                              ; preds = %163, %137
  %145 = load i64, ptr %7, align 8, !tbaa !9
  %146 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %147 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %146, i32 0, i32 2
  %148 = load i64, ptr %147, align 8, !tbaa !15
  %149 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 6), i32 0, i32 1), align 8, !tbaa !20
  %150 = sub i64 %148, %149
  %151 = load i64, ptr %6, align 8, !tbaa !9
  %152 = sub i64 %150, %151
  %153 = add i64 %152, 2
  %154 = icmp ult i64 %145, %153
  br i1 %154, label %155, label %166

155:                                              ; preds = %144
  %156 = load ptr, ptr %8, align 8, !tbaa !5
  %157 = load i64, ptr %11, align 8, !tbaa !9
  %158 = getelementptr inbounds i16, ptr %156, i64 %157
  %159 = load i16, ptr %158, align 2, !tbaa !21
  %160 = load ptr, ptr %8, align 8, !tbaa !5
  store i16 %159, ptr %160, align 2, !tbaa !21
  %161 = load ptr, ptr %8, align 8, !tbaa !5
  %162 = getelementptr inbounds i16, ptr %161, i32 1
  store ptr %162, ptr %8, align 8, !tbaa !5
  br label %163

163:                                              ; preds = %155
  %164 = load i64, ptr %7, align 8, !tbaa !9
  %165 = add i64 %164, 1
  store i64 %165, ptr %7, align 8, !tbaa !9
  br label %144, !llvm.loop !27

166:                                              ; preds = %144
  br label %167

167:                                              ; preds = %166, %111
  %168 = load i64, ptr %6, align 8, !tbaa !9
  %169 = load i64, ptr %5, align 8, !tbaa !9
  %170 = icmp eq i64 %168, %169
  br i1 %170, label %171, label %194

171:                                              ; preds = %167
  %172 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %173 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %172, i32 0, i32 1
  %174 = load ptr, ptr %173, align 8, !tbaa !19
  %175 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 6), i32 0, i32 1), align 8, !tbaa !20
  %176 = getelementptr inbounds i16, ptr %174, i64 %175
  %177 = getelementptr inbounds i16, ptr %176, i64 -1
  store ptr %177, ptr %8, align 8, !tbaa !5
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %178

178:                                              ; preds = %190, %171
  %179 = load i64, ptr %7, align 8, !tbaa !9
  %180 = load i64, ptr %6, align 8, !tbaa !9
  %181 = icmp ult i64 %179, %180
  br i1 %181, label %182, label %193

182:                                              ; preds = %178
  %183 = load ptr, ptr %4, align 8, !tbaa !5
  %184 = load i64, ptr %7, align 8, !tbaa !9
  %185 = getelementptr inbounds i16, ptr %183, i64 %184
  %186 = load i16, ptr %185, align 2, !tbaa !21
  %187 = load ptr, ptr %8, align 8, !tbaa !5
  %188 = load i64, ptr %7, align 8, !tbaa !9
  %189 = getelementptr inbounds i16, ptr %187, i64 %188
  store i16 %186, ptr %189, align 2, !tbaa !21
  br label %190

190:                                              ; preds = %182
  %191 = load i64, ptr %7, align 8, !tbaa !9
  %192 = add i64 %191, 1
  store i64 %192, ptr %7, align 8, !tbaa !9
  br label %178, !llvm.loop !28

193:                                              ; preds = %178
  br label %194

194:                                              ; preds = %193, %167
  %195 = load i64, ptr %6, align 8, !tbaa !9
  %196 = load i64, ptr %5, align 8, !tbaa !9
  %197 = sub i64 %195, %196
  %198 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !11
  %199 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %198, i32 0, i32 2
  %200 = load i64, ptr %199, align 8, !tbaa !15
  %201 = add i64 %200, %197
  store i64 %201, ptr %199, align 8, !tbaa !15
  store i8 1, ptr @FileBufferOnlyLineNeedRefresh, align 1, !tbaa !29
  store i8 1, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 9), align 8, !tbaa !30
  %202 = load ptr, ptr @MainEditor, align 8, !tbaa !31
  %203 = getelementptr inbounds %struct.EFI_EDITOR_FILE_BUFFER, ptr %202, i32 0, i32 0
  %204 = load ptr, ptr %203, align 8, !tbaa !33
  %205 = load ptr, ptr @MainEditor, align 8, !tbaa !31
  %206 = getelementptr inbounds %struct.EFI_EDITOR_FILE_BUFFER, ptr %205, i32 0, i32 1
  %207 = load i32, ptr %206, align 8, !tbaa !34
  %208 = load ptr, ptr @MainEditor, align 8, !tbaa !31
  %209 = getelementptr inbounds %struct.EFI_EDITOR_FILE_BUFFER, ptr %208, i32 0, i32 11
  %210 = load i8, ptr %209, align 2, !tbaa !35
  %211 = load ptr, ptr @MainEditor, align 8, !tbaa !31
  %212 = getelementptr inbounds %struct.EFI_EDITOR_FILE_BUFFER, ptr %211, i32 0, i32 9
  %213 = load i8, ptr %212, align 8, !tbaa !30
  %214 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_GLOBAL_EDITOR, ptr @MainEditor, i32 0, i32 2), i32 0, i32 1), align 8, !tbaa !36
  %215 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_GLOBAL_EDITOR, ptr @MainEditor, i32 0, i32 2), align 8, !tbaa !37
  %216 = call i64 @MainTitleBarRefresh(ptr noundef %204, i32 noundef %207, i8 noundef zeroext %210, i8 noundef zeroext %213, i64 noundef %214, i64 noundef %215, i64 noundef 0, i64 noundef 0)
  %217 = call i64 @FileBufferRestorePosition()
  %218 = call i64 @FileBufferRefresh()
  store i64 0, ptr %3, align 8
  store i32 1, ptr %12, align 4
  br label %219

219:                                              ; preds = %194, %54
  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
  %220 = load i64, ptr %3, align 8
  ret i64 %220
}

declare i64 @StrLen(ptr noundef) #2

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

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 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 112}
!12 = !{!"", !6, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !14, i64 40, !14, i64 56, !14, i64 72, !14, i64 88, !7, i64 104, !7, i64 105, !7, i64 106, !6, i64 112}
!13 = !{!"int", !7, i64 0}
!14 = !{!"", !10, i64 0, !10, i64 8}
!15 = !{!16, !10, i64 16}
!16 = !{!"_EFI_EDITOR_LINE", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !13, i64 32, !17, i64 40}
!17 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!18 = !{!16, !10, i64 24}
!19 = !{!16, !6, i64 8}
!20 = !{!12, !10, i64 64}
!21 = !{!22, !22, i64 0}
!22 = !{!"short", !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = distinct !{!26, !24}
!27 = distinct !{!27, !24}
!28 = distinct !{!28, !24}
!29 = !{!7, !7, i64 0}
!30 = !{!12, !7, i64 104}
!31 = !{!32, !6, i64 0}
!32 = !{!"", !6, i64 0, !7, i64 8, !14, i64 16, !6, i64 32, !7, i64 40, !6, i64 48, !13, i64 56, !13, i64 60}
!33 = !{!12, !6, i64 0}
!34 = !{!12, !13, i64 8}
!35 = !{!12, !7, i64 106}
!36 = !{!32, !10, i64 24}
!37 = !{!32, !10, i64 16}


; 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_EDITOR_FILE_BUFFER = type { ptr, i32, ptr, ptr, i64, %struct.EFI_EDITOR_POSITION, %struct.EFI_EDITOR_POSITION, %struct.EFI_EDITOR_POSITION, %struct.EFI_EDITOR_POSITION, i8, i8, i8, ptr }
%struct.EFI_EDITOR_POSITION = type { i64, i64 }
%struct.EFI_EDITOR_GLOBAL_EDITOR = type { ptr, %union.EFI_EDITOR_COLOR_UNION, %struct.EFI_EDITOR_POSITION, ptr, i8, ptr, i32, i32 }
%union.EFI_EDITOR_COLOR_UNION = type { i64 }

@FileBuffer = external dso_local local_unnamed_addr global %struct.EFI_EDITOR_FILE_BUFFER, align 8
@FileBufferOnlyLineNeedRefresh = external dso_local local_unnamed_addr global i8, align 1
@MainEditor = external local_unnamed_addr global %struct.EFI_EDITOR_GLOBAL_EDITOR, align 8

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBufferRestorePosition() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @FileBufferRefresh() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775799, 1) i64 @FileBufferReplace(ptr noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = ptrtoint ptr %0 to i64
  %4 = tail call i64 @StrLen(ptr noundef %0) #3
  %5 = load ptr, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 112), align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load i64, ptr %6, align 8, !tbaa !13
  %8 = add i64 %7, 1
  %9 = sub i64 %4, %1
  %10 = add i64 %8, %9
  %11 = icmp ugt i64 %4, %1
  br i1 %11, label %12, label %.loopexit74

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %5, i64 24
  %14 = load i64, ptr %13, align 8, !tbaa !16
  %15 = add i64 %14, 1
  %.not = icmp ugt i64 %15, %10
  br i1 %.not, label %._crit_edge99, label %16

._crit_edge99:                                    ; preds = %12
  %.phi.trans.insert = getelementptr inbounds i8, ptr %5, i64 8
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !17
  br label %26

16:                                               ; preds = %12
  %17 = shl i64 %8, 1
  %18 = shl i64 %10, 1
  %19 = getelementptr inbounds i8, ptr %5, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = tail call ptr @ReallocatePool(i64 noundef %17, i64 noundef %18, ptr noundef %20) #3
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 112), align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  store ptr %21, ptr %23, align 8, !tbaa !17
  %24 = add i64 %7, %9
  %25 = getelementptr inbounds i8, ptr %22, i64 24
  store i64 %24, ptr %25, align 8, !tbaa !16
  br label %26

26:                                               ; preds = %._crit_edge99, %16
  %27 = phi ptr [ %21, %16 ], [ %.pre, %._crit_edge99 ]
  %28 = phi ptr [ %22, %16 ], [ %5, %._crit_edge99 ]
  %29 = ptrtoint ptr %27 to i64
  %30 = icmp eq ptr %27, null
  br i1 %30, label %228, label %31

31:                                               ; preds = %26
  %32 = getelementptr inbounds i8, ptr %28, i64 16
  %33 = load i64, ptr %32, align 8, !tbaa !13
  %34 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 64), align 8, !tbaa !18
  %35 = add i64 %33, 2
  %36 = add i64 %34, %1
  %.not89 = icmp eq i64 %35, %36
  br i1 %.not89, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %31
  %37 = sub i64 %35, %36
  %38 = getelementptr i16, ptr %27, i64 %7
  %39 = getelementptr i16, ptr %38, i64 %9
  %40 = sub i64 0, %9
  %umax = tail call i64 @llvm.umax.i64(i64 %37, i64 1)
  %min.iters.check = icmp ult i64 %37, 40
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.lr.ph
  %41 = add i64 %umax, -1
  %mul.result.neg = mul i64 %41, -2
  %42 = getelementptr i8, ptr %39, i64 %mul.result.neg
  %43 = icmp ugt ptr %42, %39
  %mul.result101.neg = mul i64 %41, -2
  %mul.overflow102 = icmp slt i64 %41, 0
  %44 = getelementptr i8, ptr %38, i64 %mul.result101.neg
  %45 = icmp ugt ptr %44, %38
  %46 = or i1 %45, %mul.overflow102
  %47 = or i1 %43, %46
  br i1 %47, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %vector.scevcheck
  %48 = sub i64 %1, %4
  %49 = and i64 %48, 9223372036854775792
  %diff.check = icmp eq i64 %49, 0
  br i1 %diff.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %umax, -16
  %50 = mul i64 %n.vec, -2
  %ind.end = getelementptr i8, ptr %39, i64 %50
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = mul i64 %index, -2
  %next.gep = getelementptr i8, ptr %39, i64 %offset.idx
  %51 = getelementptr inbounds i16, ptr %next.gep, i64 %40
  %52 = getelementptr inbounds i8, ptr %51, i64 -14
  %53 = getelementptr inbounds i8, ptr %51, i64 -30
  %wide.load = load <8 x i16>, ptr %52, align 2, !tbaa !19
  %wide.load105 = load <8 x i16>, ptr %53, align 2, !tbaa !19
  %54 = getelementptr i8, ptr %next.gep, i64 -14
  %55 = getelementptr i8, ptr %next.gep, i64 -30
  store <8 x i16> %wide.load, ptr %54, align 2, !tbaa !19
  store <8 x i16> %wide.load105, ptr %55, align 2, !tbaa !19
  %index.next = add nuw i64 %index, 16
  %56 = icmp eq i64 %index.next, %n.vec
  br i1 %56, label %middle.block, label %vector.body, !llvm.loop !21

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %37, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %vector.scevcheck, %.lr.ph
  %.05876.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %vector.scevcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %.05975.ph = phi ptr [ %39, %vector.memcheck ], [ %39, %vector.scevcheck ], [ %39, %.lr.ph ], [ %ind.end, %middle.block ]
  %xtraiter = and i64 %umax, 7
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %.05876.prol = phi i64 [ %60, %scalar.ph.prol ], [ %.05876.ph, %scalar.ph.preheader ]
  %.05975.prol = phi ptr [ %59, %scalar.ph.prol ], [ %.05975.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %57 = getelementptr inbounds i16, ptr %.05975.prol, i64 %40
  %58 = load i16, ptr %57, align 2, !tbaa !19
  store i16 %58, ptr %.05975.prol, align 2, !tbaa !19
  %59 = getelementptr inbounds i8, ptr %.05975.prol, i64 -2
  %60 = add nuw i64 %.05876.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !25

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.05876.unr = phi i64 [ %.05876.ph, %scalar.ph.preheader ], [ %60, %scalar.ph.prol ]
  %.05975.unr = phi ptr [ %.05975.ph, %scalar.ph.preheader ], [ %59, %scalar.ph.prol ]
  %61 = sub i64 %.05876.ph, %umax
  %62 = icmp ugt i64 %61, -8
  br i1 %62, label %._crit_edge, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.05876 = phi i64 [ %87, %scalar.ph ], [ %.05876.unr, %scalar.ph.prol.loopexit ]
  %.05975 = phi ptr [ %86, %scalar.ph ], [ %.05975.unr, %scalar.ph.prol.loopexit ]
  %63 = getelementptr inbounds i16, ptr %.05975, i64 %40
  %64 = load i16, ptr %63, align 2, !tbaa !19
  store i16 %64, ptr %.05975, align 2, !tbaa !19
  %65 = getelementptr inbounds i8, ptr %.05975, i64 -2
  %66 = getelementptr inbounds i16, ptr %65, i64 %40
  %67 = load i16, ptr %66, align 2, !tbaa !19
  store i16 %67, ptr %65, align 2, !tbaa !19
  %68 = getelementptr inbounds i8, ptr %.05975, i64 -4
  %69 = getelementptr inbounds i16, ptr %68, i64 %40
  %70 = load i16, ptr %69, align 2, !tbaa !19
  store i16 %70, ptr %68, align 2, !tbaa !19
  %71 = getelementptr inbounds i8, ptr %.05975, i64 -6
  %72 = getelementptr inbounds i16, ptr %71, i64 %40
  %73 = load i16, ptr %72, align 2, !tbaa !19
  store i16 %73, ptr %71, align 2, !tbaa !19
  %74 = getelementptr inbounds i8, ptr %.05975, i64 -8
  %75 = getelementptr inbounds i16, ptr %74, i64 %40
  %76 = load i16, ptr %75, align 2, !tbaa !19
  store i16 %76, ptr %74, align 2, !tbaa !19
  %77 = getelementptr inbounds i8, ptr %.05975, i64 -10
  %78 = getelementptr inbounds i16, ptr %77, i64 %40
  %79 = load i16, ptr %78, align 2, !tbaa !19
  store i16 %79, ptr %77, align 2, !tbaa !19
  %80 = getelementptr inbounds i8, ptr %.05975, i64 -12
  %81 = getelementptr inbounds i16, ptr %80, i64 %40
  %82 = load i16, ptr %81, align 2, !tbaa !19
  store i16 %82, ptr %80, align 2, !tbaa !19
  %83 = getelementptr inbounds i8, ptr %.05975, i64 -14
  %84 = getelementptr inbounds i16, ptr %83, i64 %40
  %85 = load i16, ptr %84, align 2, !tbaa !19
  store i16 %85, ptr %83, align 2, !tbaa !19
  %86 = getelementptr inbounds i8, ptr %.05975, i64 -16
  %87 = add nuw i64 %.05876, 8
  %exitcond.not.7 = icmp eq i64 %37, %87
  br i1 %exitcond.not.7, label %._crit_edge, label %scalar.ph, !llvm.loop !27

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %31
  %88 = getelementptr inbounds i16, ptr %27, i64 %34
  %89 = getelementptr inbounds i8, ptr %88, i64 -2
  %umax94 = tail call i64 @llvm.umax.i64(i64 %4, i64 1)
  %min.iters.check113 = icmp ult i64 %4, 16
  br i1 %min.iters.check113, label %scalar.ph112.preheader, label %vector.memcheck109

vector.memcheck109:                               ; preds = %._crit_edge
  %90 = shl i64 %34, 1
  %91 = add i64 %90, %29
  %92 = add i64 %91, -2
  %93 = sub i64 %92, %3
  %diff.check110 = icmp ult i64 %93, 32
  br i1 %diff.check110, label %scalar.ph112.preheader, label %vector.ph114

vector.ph114:                                     ; preds = %vector.memcheck109
  %n.vec116 = and i64 %umax94, -16
  br label %vector.body118

vector.body118:                                   ; preds = %vector.body118, %vector.ph114
  %index119 = phi i64 [ 0, %vector.ph114 ], [ %index.next122, %vector.body118 ]
  %94 = getelementptr inbounds i16, ptr %0, i64 %index119
  %95 = getelementptr inbounds i8, ptr %94, i64 16
  %wide.load120 = load <8 x i16>, ptr %94, align 2, !tbaa !19
  %wide.load121 = load <8 x i16>, ptr %95, align 2, !tbaa !19
  %96 = getelementptr inbounds i16, ptr %89, i64 %index119
  %97 = getelementptr inbounds i8, ptr %96, i64 16
  store <8 x i16> %wide.load120, ptr %96, align 2, !tbaa !19
  store <8 x i16> %wide.load121, ptr %97, align 2, !tbaa !19
  %index.next122 = add nuw i64 %index119, 16
  %98 = icmp eq i64 %index.next122, %n.vec116
  br i1 %98, label %middle.block111, label %vector.body118, !llvm.loop !28

middle.block111:                                  ; preds = %vector.body118
  %cmp.n123 = icmp eq i64 %4, %n.vec116
  br i1 %cmp.n123, label %.loopexit74, label %scalar.ph112.preheader

scalar.ph112.preheader:                           ; preds = %middle.block111, %vector.memcheck109, %._crit_edge
  %.177.ph = phi i64 [ 0, %vector.memcheck109 ], [ 0, %._crit_edge ], [ %n.vec116, %middle.block111 ]
  %xtraiter177 = and i64 %umax94, 3
  %lcmp.mod178.not = icmp eq i64 %xtraiter177, 0
  br i1 %lcmp.mod178.not, label %scalar.ph112.prol.loopexit, label %scalar.ph112.prol

scalar.ph112.prol:                                ; preds = %scalar.ph112.preheader, %scalar.ph112.prol
  %.177.prol = phi i64 [ %102, %scalar.ph112.prol ], [ %.177.ph, %scalar.ph112.preheader ]
  %prol.iter179 = phi i64 [ %prol.iter179.next, %scalar.ph112.prol ], [ 0, %scalar.ph112.preheader ]
  %99 = getelementptr inbounds i16, ptr %0, i64 %.177.prol
  %100 = load i16, ptr %99, align 2, !tbaa !19
  %101 = getelementptr inbounds i16, ptr %89, i64 %.177.prol
  store i16 %100, ptr %101, align 2, !tbaa !19
  %102 = add nuw i64 %.177.prol, 1
  %prol.iter179.next = add i64 %prol.iter179, 1
  %prol.iter179.cmp.not = icmp eq i64 %prol.iter179.next, %xtraiter177
  br i1 %prol.iter179.cmp.not, label %scalar.ph112.prol.loopexit, label %scalar.ph112.prol, !llvm.loop !29

scalar.ph112.prol.loopexit:                       ; preds = %scalar.ph112.prol, %scalar.ph112.preheader
  %.177.unr = phi i64 [ %.177.ph, %scalar.ph112.preheader ], [ %102, %scalar.ph112.prol ]
  %103 = sub i64 %.177.ph, %umax94
  %104 = icmp ugt i64 %103, -4
  br i1 %104, label %.loopexit74, label %scalar.ph112.preheader.new

scalar.ph112.preheader.new:                       ; preds = %scalar.ph112.prol.loopexit
  %invariant.gep = getelementptr i8, ptr %0, i64 2
  br label %scalar.ph112

scalar.ph112:                                     ; preds = %scalar.ph112, %scalar.ph112.preheader.new
  %.177 = phi i64 [ %.177.unr, %scalar.ph112.preheader.new ], [ %118, %scalar.ph112 ]
  %105 = getelementptr inbounds i16, ptr %0, i64 %.177
  %106 = load i16, ptr %105, align 2, !tbaa !19
  %107 = getelementptr inbounds i16, ptr %89, i64 %.177
  store i16 %106, ptr %107, align 2, !tbaa !19
  %gep = getelementptr i16, ptr %invariant.gep, i64 %.177
  %108 = load i16, ptr %gep, align 2, !tbaa !19
  %109 = getelementptr i16, ptr %88, i64 %.177
  store i16 %108, ptr %109, align 2, !tbaa !19
  %110 = add nuw i64 %.177, 2
  %111 = getelementptr inbounds i16, ptr %0, i64 %110
  %112 = load i16, ptr %111, align 2, !tbaa !19
  %113 = getelementptr inbounds i16, ptr %89, i64 %110
  store i16 %112, ptr %113, align 2, !tbaa !19
  %114 = add nuw i64 %.177, 3
  %115 = getelementptr inbounds i16, ptr %0, i64 %114
  %116 = load i16, ptr %115, align 2, !tbaa !19
  %117 = getelementptr inbounds i16, ptr %89, i64 %114
  store i16 %116, ptr %117, align 2, !tbaa !19
  %118 = add nuw i64 %.177, 4
  %exitcond95.not.3 = icmp eq i64 %4, %118
  br i1 %exitcond95.not.3, label %.loopexit74, label %scalar.ph112, !llvm.loop !30

.loopexit74:                                      ; preds = %scalar.ph112.prol.loopexit, %scalar.ph112, %middle.block111, %2
  %119 = phi i64 [ %7, %2 ], [ %33, %middle.block111 ], [ %33, %scalar.ph112 ], [ %33, %scalar.ph112.prol.loopexit ]
  %120 = phi ptr [ %5, %2 ], [ %28, %middle.block111 ], [ %28, %scalar.ph112 ], [ %28, %scalar.ph112.prol.loopexit ]
  %121 = icmp ult i64 %4, %1
  br i1 %121, label %122, label %.loopexit73

122:                                              ; preds = %.loopexit74
  %123 = getelementptr inbounds i8, ptr %120, i64 8
  %124 = load ptr, ptr %123, align 8, !tbaa !17
  %125 = ptrtoint ptr %124 to i64
  %126 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 64), align 8, !tbaa !18
  %127 = getelementptr i16, ptr %124, i64 %126
  %128 = getelementptr i8, ptr %127, i64 -2
  %.not90 = icmp eq i64 %4, 0
  br i1 %.not90, label %._crit_edge81, label %.lr.ph80.preheader

.lr.ph80.preheader:                               ; preds = %122
  %min.iters.check128 = icmp ult i64 %4, 16
  br i1 %min.iters.check128, label %.lr.ph80.preheader176, label %vector.memcheck124

vector.memcheck124:                               ; preds = %.lr.ph80.preheader
  %129 = shl i64 %126, 1
  %130 = add i64 %129, %125
  %131 = add i64 %130, -2
  %132 = sub i64 %131, %3
  %diff.check125 = icmp ult i64 %132, 32
  br i1 %diff.check125, label %.lr.ph80.preheader176, label %vector.ph129

vector.ph129:                                     ; preds = %vector.memcheck124
  %n.vec131 = and i64 %4, -16
  br label %vector.body133

vector.body133:                                   ; preds = %vector.body133, %vector.ph129
  %index134 = phi i64 [ 0, %vector.ph129 ], [ %index.next137, %vector.body133 ]
  %133 = getelementptr inbounds i16, ptr %0, i64 %index134
  %134 = getelementptr inbounds i8, ptr %133, i64 16
  %wide.load135 = load <8 x i16>, ptr %133, align 2, !tbaa !19
  %wide.load136 = load <8 x i16>, ptr %134, align 2, !tbaa !19
  %135 = getelementptr inbounds i16, ptr %128, i64 %index134
  %136 = getelementptr inbounds i8, ptr %135, i64 16
  store <8 x i16> %wide.load135, ptr %135, align 2, !tbaa !19
  store <8 x i16> %wide.load136, ptr %136, align 2, !tbaa !19
  %index.next137 = add nuw i64 %index134, 16
  %137 = icmp eq i64 %index.next137, %n.vec131
  br i1 %137, label %middle.block126, label %vector.body133, !llvm.loop !31

middle.block126:                                  ; preds = %vector.body133
  %cmp.n138 = icmp eq i64 %4, %n.vec131
  br i1 %cmp.n138, label %._crit_edge81, label %.lr.ph80.preheader176

.lr.ph80.preheader176:                            ; preds = %middle.block126, %vector.memcheck124, %.lr.ph80.preheader
  %.278.ph = phi i64 [ 0, %vector.memcheck124 ], [ 0, %.lr.ph80.preheader ], [ %n.vec131, %middle.block126 ]
  %xtraiter180 = and i64 %4, 3
  %lcmp.mod181.not = icmp eq i64 %xtraiter180, 0
  br i1 %lcmp.mod181.not, label %.lr.ph80.prol.loopexit, label %.lr.ph80.prol

.lr.ph80.prol:                                    ; preds = %.lr.ph80.preheader176, %.lr.ph80.prol
  %.278.prol = phi i64 [ %141, %.lr.ph80.prol ], [ %.278.ph, %.lr.ph80.preheader176 ]
  %prol.iter182 = phi i64 [ %prol.iter182.next, %.lr.ph80.prol ], [ 0, %.lr.ph80.preheader176 ]
  %138 = getelementptr inbounds i16, ptr %0, i64 %.278.prol
  %139 = load i16, ptr %138, align 2, !tbaa !19
  %140 = getelementptr inbounds i16, ptr %128, i64 %.278.prol
  store i16 %139, ptr %140, align 2, !tbaa !19
  %141 = add nuw i64 %.278.prol, 1
  %prol.iter182.next = add i64 %prol.iter182, 1
  %prol.iter182.cmp.not = icmp eq i64 %prol.iter182.next, %xtraiter180
  br i1 %prol.iter182.cmp.not, label %.lr.ph80.prol.loopexit, label %.lr.ph80.prol, !llvm.loop !32

.lr.ph80.prol.loopexit:                           ; preds = %.lr.ph80.prol, %.lr.ph80.preheader176
  %.278.unr = phi i64 [ %.278.ph, %.lr.ph80.preheader176 ], [ %141, %.lr.ph80.prol ]
  %142 = sub i64 %.278.ph, %4
  %143 = icmp ugt i64 %142, -4
  br i1 %143, label %._crit_edge81, label %.lr.ph80.preheader176.new

.lr.ph80.preheader176.new:                        ; preds = %.lr.ph80.prol.loopexit
  %invariant.gep190 = getelementptr i8, ptr %0, i64 2
  br label %.lr.ph80

.lr.ph80:                                         ; preds = %.lr.ph80, %.lr.ph80.preheader176.new
  %.278 = phi i64 [ %.278.unr, %.lr.ph80.preheader176.new ], [ %157, %.lr.ph80 ]
  %144 = getelementptr inbounds i16, ptr %0, i64 %.278
  %145 = load i16, ptr %144, align 2, !tbaa !19
  %146 = getelementptr inbounds i16, ptr %128, i64 %.278
  store i16 %145, ptr %146, align 2, !tbaa !19
  %gep191 = getelementptr i16, ptr %invariant.gep190, i64 %.278
  %147 = load i16, ptr %gep191, align 2, !tbaa !19
  %148 = getelementptr i16, ptr %127, i64 %.278
  store i16 %147, ptr %148, align 2, !tbaa !19
  %149 = add nuw i64 %.278, 2
  %150 = getelementptr inbounds i16, ptr %0, i64 %149
  %151 = load i16, ptr %150, align 2, !tbaa !19
  %152 = getelementptr inbounds i16, ptr %128, i64 %149
  store i16 %151, ptr %152, align 2, !tbaa !19
  %153 = add nuw i64 %.278, 3
  %154 = getelementptr inbounds i16, ptr %0, i64 %153
  %155 = load i16, ptr %154, align 2, !tbaa !19
  %156 = getelementptr inbounds i16, ptr %128, i64 %153
  store i16 %155, ptr %156, align 2, !tbaa !19
  %157 = add nuw i64 %.278, 4
  %exitcond96.not.3 = icmp eq i64 %157, %4
  br i1 %exitcond96.not.3, label %._crit_edge81, label %.lr.ph80, !llvm.loop !33

._crit_edge81:                                    ; preds = %.lr.ph80.prol.loopexit, %.lr.ph80, %middle.block126, %122
  %158 = sub i64 %1, %4
  %159 = add i64 %4, %126
  %reass.sub = sub i64 %119, %159
  %160 = add i64 %reass.sub, 2
  %.not91 = icmp eq i64 %160, 0
  br i1 %.not91, label %.loopexit73, label %.lr.ph85.preheader

.lr.ph85.preheader:                               ; preds = %._crit_edge81
  %161 = getelementptr i16, ptr %128, i64 %4
  %162 = add i64 %119, 2
  %163 = add i64 %4, %126
  %164 = sub i64 %162, %163
  %min.iters.check143 = icmp ult i64 %164, 16
  br i1 %min.iters.check143, label %.lr.ph85.preheader175, label %vector.memcheck139

vector.memcheck139:                               ; preds = %.lr.ph85.preheader
  %165 = sub i64 %4, %1
  %166 = and i64 %165, 9223372036854775792
  %diff.check140 = icmp eq i64 %166, 0
  br i1 %diff.check140, label %.lr.ph85.preheader175, label %vector.ph144

vector.ph144:                                     ; preds = %vector.memcheck139
  %n.vec146 = and i64 %164, -16
  %167 = shl i64 %n.vec146, 1
  %ind.end148 = getelementptr i8, ptr %161, i64 %167
  br label %vector.body150

vector.body150:                                   ; preds = %vector.body150, %vector.ph144
  %index151 = phi i64 [ 0, %vector.ph144 ], [ %index.next157, %vector.body150 ]
  %offset.idx152 = shl i64 %index151, 1
  %next.gep153 = getelementptr i8, ptr %161, i64 %offset.idx152
  %168 = getelementptr inbounds i16, ptr %next.gep153, i64 %158
  %169 = getelementptr inbounds i8, ptr %168, i64 16
  %wide.load155 = load <8 x i16>, ptr %168, align 2, !tbaa !19
  %wide.load156 = load <8 x i16>, ptr %169, align 2, !tbaa !19
  %170 = getelementptr i8, ptr %next.gep153, i64 16
  store <8 x i16> %wide.load155, ptr %next.gep153, align 2, !tbaa !19
  store <8 x i16> %wide.load156, ptr %170, align 2, !tbaa !19
  %index.next157 = add nuw i64 %index151, 16
  %171 = icmp eq i64 %index.next157, %n.vec146
  br i1 %171, label %middle.block141, label %vector.body150, !llvm.loop !34

middle.block141:                                  ; preds = %vector.body150
  %cmp.n158 = icmp eq i64 %164, %n.vec146
  br i1 %cmp.n158, label %.loopexit73, label %.lr.ph85.preheader175

.lr.ph85.preheader175:                            ; preds = %middle.block141, %vector.memcheck139, %.lr.ph85.preheader
  %.383.ph = phi i64 [ 0, %vector.memcheck139 ], [ 0, %.lr.ph85.preheader ], [ %n.vec146, %middle.block141 ]
  %.16082.ph = phi ptr [ %161, %vector.memcheck139 ], [ %161, %.lr.ph85.preheader ], [ %ind.end148, %middle.block141 ]
  br label %.lr.ph85

.lr.ph85:                                         ; preds = %.lr.ph85.preheader175, %.lr.ph85
  %.383 = phi i64 [ %175, %.lr.ph85 ], [ %.383.ph, %.lr.ph85.preheader175 ]
  %.16082 = phi ptr [ %174, %.lr.ph85 ], [ %.16082.ph, %.lr.ph85.preheader175 ]
  %172 = getelementptr inbounds i16, ptr %.16082, i64 %158
  %173 = load i16, ptr %172, align 2, !tbaa !19
  store i16 %173, ptr %.16082, align 2, !tbaa !19
  %174 = getelementptr inbounds i8, ptr %.16082, i64 2
  %175 = add nuw i64 %.383, 1
  %exitcond97.not = icmp eq i64 %175, %160
  br i1 %exitcond97.not, label %.loopexit73, label %.lr.ph85, !llvm.loop !35

.loopexit73:                                      ; preds = %.lr.ph85, %middle.block141, %._crit_edge81, %.loopexit74
  %176 = icmp eq i64 %4, %1
  br i1 %176, label %177, label %.loopexit

177:                                              ; preds = %.loopexit73
  %178 = getelementptr inbounds i8, ptr %120, i64 8
  %179 = load ptr, ptr %178, align 8, !tbaa !17
  %180 = ptrtoint ptr %179 to i64
  %181 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 64), align 8, !tbaa !18
  %182 = getelementptr i16, ptr %179, i64 %181
  %183 = getelementptr i8, ptr %182, i64 -2
  %.not92 = icmp eq i64 %1, 0
  br i1 %.not92, label %.loopexit, label %.lr.ph88.preheader

.lr.ph88.preheader:                               ; preds = %177
  %min.iters.check163 = icmp ult i64 %1, 16
  br i1 %min.iters.check163, label %.lr.ph88.preheader174, label %vector.memcheck159

vector.memcheck159:                               ; preds = %.lr.ph88.preheader
  %184 = shl i64 %181, 1
  %185 = add i64 %184, %180
  %186 = add i64 %185, -2
  %187 = sub i64 %186, %3
  %diff.check160 = icmp ult i64 %187, 32
  br i1 %diff.check160, label %.lr.ph88.preheader174, label %vector.ph164

vector.ph164:                                     ; preds = %vector.memcheck159
  %n.vec166 = and i64 %1, -16
  br label %vector.body168

vector.body168:                                   ; preds = %vector.body168, %vector.ph164
  %index169 = phi i64 [ 0, %vector.ph164 ], [ %index.next172, %vector.body168 ]
  %188 = getelementptr inbounds i16, ptr %0, i64 %index169
  %189 = getelementptr inbounds i8, ptr %188, i64 16
  %wide.load170 = load <8 x i16>, ptr %188, align 2, !tbaa !19
  %wide.load171 = load <8 x i16>, ptr %189, align 2, !tbaa !19
  %190 = getelementptr inbounds i16, ptr %183, i64 %index169
  %191 = getelementptr inbounds i8, ptr %190, i64 16
  store <8 x i16> %wide.load170, ptr %190, align 2, !tbaa !19
  store <8 x i16> %wide.load171, ptr %191, align 2, !tbaa !19
  %index.next172 = add nuw i64 %index169, 16
  %192 = icmp eq i64 %index.next172, %n.vec166
  br i1 %192, label %middle.block161, label %vector.body168, !llvm.loop !36

middle.block161:                                  ; preds = %vector.body168
  %cmp.n173 = icmp eq i64 %n.vec166, %1
  br i1 %cmp.n173, label %.loopexit, label %.lr.ph88.preheader174

.lr.ph88.preheader174:                            ; preds = %middle.block161, %vector.memcheck159, %.lr.ph88.preheader
  %.486.ph = phi i64 [ 0, %vector.memcheck159 ], [ 0, %.lr.ph88.preheader ], [ %n.vec166, %middle.block161 ]
  %xtraiter183 = and i64 %1, 3
  %lcmp.mod184.not = icmp eq i64 %xtraiter183, 0
  br i1 %lcmp.mod184.not, label %.lr.ph88.prol.loopexit, label %.lr.ph88.prol

.lr.ph88.prol:                                    ; preds = %.lr.ph88.preheader174, %.lr.ph88.prol
  %.486.prol = phi i64 [ %196, %.lr.ph88.prol ], [ %.486.ph, %.lr.ph88.preheader174 ]
  %prol.iter185 = phi i64 [ %prol.iter185.next, %.lr.ph88.prol ], [ 0, %.lr.ph88.preheader174 ]
  %193 = getelementptr inbounds i16, ptr %0, i64 %.486.prol
  %194 = load i16, ptr %193, align 2, !tbaa !19
  %195 = getelementptr inbounds i16, ptr %183, i64 %.486.prol
  store i16 %194, ptr %195, align 2, !tbaa !19
  %196 = add nuw i64 %.486.prol, 1
  %prol.iter185.next = add i64 %prol.iter185, 1
  %prol.iter185.cmp.not = icmp eq i64 %prol.iter185.next, %xtraiter183
  br i1 %prol.iter185.cmp.not, label %.lr.ph88.prol.loopexit, label %.lr.ph88.prol, !llvm.loop !37

.lr.ph88.prol.loopexit:                           ; preds = %.lr.ph88.prol, %.lr.ph88.preheader174
  %.486.unr = phi i64 [ %.486.ph, %.lr.ph88.preheader174 ], [ %196, %.lr.ph88.prol ]
  %197 = sub i64 %.486.ph, %1
  %198 = icmp ugt i64 %197, -4
  br i1 %198, label %.loopexit, label %.lr.ph88.preheader174.new

.lr.ph88.preheader174.new:                        ; preds = %.lr.ph88.prol.loopexit
  %invariant.gep192 = getelementptr i8, ptr %0, i64 2
  br label %.lr.ph88

.lr.ph88:                                         ; preds = %.lr.ph88, %.lr.ph88.preheader174.new
  %.486 = phi i64 [ %.486.unr, %.lr.ph88.preheader174.new ], [ %212, %.lr.ph88 ]
  %199 = getelementptr inbounds i16, ptr %0, i64 %.486
  %200 = load i16, ptr %199, align 2, !tbaa !19
  %201 = getelementptr inbounds i16, ptr %183, i64 %.486
  store i16 %200, ptr %201, align 2, !tbaa !19
  %gep193 = getelementptr i16, ptr %invariant.gep192, i64 %.486
  %202 = load i16, ptr %gep193, align 2, !tbaa !19
  %203 = getelementptr i16, ptr %182, i64 %.486
  store i16 %202, ptr %203, align 2, !tbaa !19
  %204 = add nuw i64 %.486, 2
  %205 = getelementptr inbounds i16, ptr %0, i64 %204
  %206 = load i16, ptr %205, align 2, !tbaa !19
  %207 = getelementptr inbounds i16, ptr %183, i64 %204
  store i16 %206, ptr %207, align 2, !tbaa !19
  %208 = add nuw i64 %.486, 3
  %209 = getelementptr inbounds i16, ptr %0, i64 %208
  %210 = load i16, ptr %209, align 2, !tbaa !19
  %211 = getelementptr inbounds i16, ptr %183, i64 %208
  store i16 %210, ptr %211, align 2, !tbaa !19
  %212 = add nuw i64 %.486, 4
  %exitcond98.not.3 = icmp eq i64 %212, %1
  br i1 %exitcond98.not.3, label %.loopexit, label %.lr.ph88, !llvm.loop !38

.loopexit:                                        ; preds = %.lr.ph88.prol.loopexit, %.lr.ph88, %middle.block161, %177, %.loopexit73
  %213 = getelementptr inbounds i8, ptr %120, i64 16
  %214 = add i64 %119, %9
  store i64 %214, ptr %213, align 8, !tbaa !13
  store i8 1, ptr @FileBufferOnlyLineNeedRefresh, align 1, !tbaa !39
  store i8 1, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 104), align 8, !tbaa !40
  %215 = load ptr, ptr @MainEditor, align 8, !tbaa !41
  %216 = load ptr, ptr %215, align 8, !tbaa !43
  %217 = getelementptr inbounds i8, ptr %215, i64 8
  %218 = load i32, ptr %217, align 8, !tbaa !44
  %219 = getelementptr inbounds i8, ptr %215, i64 106
  %220 = load i8, ptr %219, align 2, !tbaa !45
  %221 = getelementptr inbounds i8, ptr %215, i64 104
  %222 = load i8, ptr %221, align 8, !tbaa !40
  %223 = load i64, ptr getelementptr inbounds (i8, ptr @MainEditor, i64 24), align 8, !tbaa !46
  %224 = load i64, ptr getelementptr inbounds (i8, ptr @MainEditor, i64 16), align 8, !tbaa !47
  %225 = tail call i64 @MainTitleBarRefresh(ptr noundef %216, i32 noundef %218, i8 noundef zeroext %220, i8 noundef zeroext %222, i64 noundef %223, i64 noundef %224, i64 noundef 0, i64 noundef 0) #3
  %226 = tail call i64 @FileBufferRestorePosition()
  %227 = tail call i64 @FileBufferRefresh()
  br label %228

228:                                              ; preds = %26, %.loopexit
  %.0 = phi i64 [ 0, %.loopexit ], [ -9223372036854775799, %26 ]
  ret i64 %.0
}

declare i64 @StrLen(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #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 = { "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 speculatable willreturn memory(none) }
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 112}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !11, i64 32, !12, i64 40, !12, i64 56, !12, i64 72, !12, i64 88, !8, i64 104, !8, i64 105, !8, i64 106, !7, i64 112}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 8}
!13 = !{!14, !11, i64 16}
!14 = !{!"_EFI_EDITOR_LINE", !11, i64 0, !7, i64 8, !11, i64 16, !11, i64 24, !10, i64 32, !15, i64 40}
!15 = !{!"_LIST_ENTRY", !7, i64 0, !7, i64 8}
!16 = !{!14, !11, i64 24}
!17 = !{!14, !7, i64 8}
!18 = !{!6, !11, i64 64}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !8, i64 0}
!21 = distinct !{!21, !22, !23, !24}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.unroll.disable"}
!27 = distinct !{!27, !22, !23}
!28 = distinct !{!28, !22, !23, !24}
!29 = distinct !{!29, !26}
!30 = distinct !{!30, !22, !23}
!31 = distinct !{!31, !22, !23, !24}
!32 = distinct !{!32, !26}
!33 = distinct !{!33, !22, !23}
!34 = distinct !{!34, !22, !23, !24}
!35 = distinct !{!35, !22, !23}
!36 = distinct !{!36, !22, !23, !24}
!37 = distinct !{!37, !26}
!38 = distinct !{!38, !22, !23}
!39 = !{!8, !8, i64 0}
!40 = !{!6, !8, i64 104}
!41 = !{!42, !7, i64 0}
!42 = !{!"", !7, i64 0, !8, i64 8, !12, i64 16, !7, i64 32, !8, i64 40, !7, i64 48, !10, i64 56, !10, i64 60}
!43 = !{!6, !7, i64 0}
!44 = !{!6, !10, i64 8}
!45 = !{!6, !8, i64 106}
!46 = !{!42, !11, i64 24}
!47 = !{!42, !11, i64 16}


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