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

; 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 }
%struct.EFI_SYSTEM_TABLE = type { %struct.EFI_TABLE_HEADER, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }
%struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@FileBuffer = external dso_local global %struct.EFI_EDITOR_FILE_BUFFER, align 8
@FileBufferBackupVar = external dso_local global %struct.EFI_EDITOR_FILE_BUFFER, align 8
@FileBufferMouseNeedRefresh = external dso_local global i8, align 1
@MainEditor = external global %struct.EFI_EDITOR_GLOBAL_EDITOR, align 8
@EditorMouseAction = external global i8, align 1
@.str.3 = external hidden unnamed_addr constant [2 x i32], align 4
@.str.4 = external hidden unnamed_addr constant [3 x i32], align 4
@gST = external global ptr, align 8

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @MoveLine(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @FileBufferRestoreMousePosition() #2 {
  %1 = alloca i64, align 8
  %2 = alloca %union.EFI_EDITOR_COLOR_UNION, align 8
  %3 = alloca %union.EFI_EDITOR_COLOR_UNION, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i16, align 2
  %10 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr %9) #4
  store ptr null, ptr %8, align 8, !tbaa !5
  %11 = load i8, ptr getelementptr inbounds (%struct.EFI_EDITOR_GLOBAL_EDITOR, ptr @MainEditor, i32 0, i32 4), align 8, !tbaa !9
  %12 = icmp ne i8 %11, 0
  br i1 %12, label %13, label %187

13:                                               ; preds = %0
  %14 = load i8, ptr @FileBufferMouseNeedRefresh, align 1, !tbaa !14
  %15 = icmp ne i8 %14, 0
  br i1 %15, label %16, label %186

16:                                               ; preds = %13
  store i8 0, ptr @FileBufferMouseNeedRefresh, align 1, !tbaa !14
  %17 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 7), align 8, !tbaa !15
  %18 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBufferBackupVar, i32 0, i32 7), align 8, !tbaa !15
  %19 = icmp eq i64 %17, %18
  br i1 %19, label %20, label %29

20:                                               ; preds = %16
  %21 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 7), i32 0, i32 1), align 8, !tbaa !17
  %22 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBufferBackupVar, i32 0, i32 7), i32 0, i32 1), align 8, !tbaa !17
  %23 = icmp eq i64 %21, %22
  br i1 %23, label %24, label %29

24:                                               ; preds = %20
  %25 = load i8, ptr @EditorMouseAction, align 1, !tbaa !14
  %26 = zext i8 %25 to i32
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %24
  store i64 0, ptr %1, align 8
  store i32 1, ptr %10, align 4
  br label %188

29:                                               ; preds = %24, %20, %16
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %2, ptr align 8 getelementptr inbounds (%struct.EFI_EDITOR_GLOBAL_EDITOR, ptr @MainEditor, i32 0, i32 1), i64 8, i1 false), !tbaa.struct !18
  store i64 0, ptr %3, align 8, !tbaa !14
  %30 = load i8, ptr %2, align 8
  %31 = lshr i8 %30, 4
  %32 = zext i8 %31 to i32
  %33 = and i32 %32, 15
  %34 = trunc i32 %33 to i8
  %35 = load i8, ptr %3, align 8
  %36 = and i8 %34, 15
  %37 = and i8 %35, -16
  %38 = or i8 %37, %36
  store i8 %38, ptr %3, align 8
  %39 = zext i8 %36 to i32
  %40 = load i8, ptr %2, align 8
  %41 = and i8 %40, 15
  %42 = zext i8 %41 to i32
  %43 = and i32 %42, 7
  %44 = trunc i32 %43 to i8
  %45 = load i8, ptr %3, align 8
  %46 = and i8 %44, 15
  %47 = shl i8 %46, 4
  %48 = and i8 %45, 15
  %49 = or i8 %48, %47
  store i8 %49, ptr %3, align 8
  %50 = zext i8 %46 to i32
  %51 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 8), align 8, !tbaa !19
  %52 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBufferBackupVar, i32 0, i32 7), align 8, !tbaa !15
  %53 = add i64 %51, %52
  %54 = sub i64 %53, 2
  store i64 %54, ptr %4, align 8, !tbaa !20
  %55 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 8), i32 0, i32 1), align 8, !tbaa !21
  %56 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBufferBackupVar, i32 0, i32 7), i32 0, i32 1), align 8, !tbaa !17
  %57 = add i64 %55, %56
  %58 = sub i64 %57, 1
  store i64 %58, ptr %5, align 8, !tbaa !20
  store i8 1, ptr %6, align 1, !tbaa !14
  %59 = load i64, ptr %4, align 8, !tbaa !20
  %60 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 4), align 8, !tbaa !22
  %61 = icmp ugt i64 %59, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %29
  store i8 0, ptr %6, align 1, !tbaa !14
  br label %80

63:                                               ; preds = %29
  %64 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !23
  store ptr %64, ptr %7, align 8, !tbaa !5
  %65 = load i64, ptr %4, align 8, !tbaa !20
  %66 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 6), align 8, !tbaa !24
  %67 = sub i64 %65, %66
  %68 = call ptr @MoveLine(i64 noundef %67)
  store ptr %68, ptr %8, align 8, !tbaa !5
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = icmp eq ptr %69, null
  br i1 %70, label %77, label %71

71:                                               ; preds = %63
  %72 = load i64, ptr %5, align 8, !tbaa !20
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %73, i32 0, i32 2
  %75 = load i64, ptr %74, align 8, !tbaa !25
  %76 = icmp ugt i64 %72, %75
  br i1 %76, label %77, label %78

77:                                               ; preds = %71, %63
  store i8 0, ptr %6, align 1, !tbaa !14
  br label %78

78:                                               ; preds = %77, %71
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %79, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !23
  br label %80

80:                                               ; preds = %78, %62
  %81 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBufferBackupVar, i32 0, i32 7), i32 0, i32 1), align 8, !tbaa !17
  %82 = trunc i64 %81 to i32
  %83 = sub nsw i32 %82, 1
  %84 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBufferBackupVar, i32 0, i32 7), align 8, !tbaa !15
  %85 = trunc i64 %84 to i32
  %86 = sub nsw i32 %85, 1
  %87 = call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %83, i32 noundef %86, ptr noundef @.str.3)
  %88 = load i8, ptr %6, align 1, !tbaa !14
  %89 = icmp ne i8 %88, 0
  br i1 %89, label %90, label %107

90:                                               ; preds = %80
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %91, i32 0, i32 1
  %93 = load ptr, ptr %92, align 8, !tbaa !28
  %94 = load i64, ptr %5, align 8, !tbaa !20
  %95 = sub i64 %94, 1
  %96 = getelementptr inbounds i16, ptr %93, i64 %95
  %97 = load i16, ptr %96, align 2, !tbaa !29
  store i16 %97, ptr %9, align 2, !tbaa !29
  %98 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBufferBackupVar, i32 0, i32 7), i32 0, i32 1), align 8, !tbaa !17
  %99 = trunc i64 %98 to i32
  %100 = sub nsw i32 %99, 1
  %101 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBufferBackupVar, i32 0, i32 7), align 8, !tbaa !15
  %102 = trunc i64 %101 to i32
  %103 = sub nsw i32 %102, 1
  %104 = load i16, ptr %9, align 2, !tbaa !29
  %105 = zext i16 %104 to i32
  %106 = call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %100, i32 noundef %103, ptr noundef @.str.4, i32 noundef %105)
  br label %107

107:                                              ; preds = %90, %80
  %108 = load ptr, ptr @gST, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.EFI_SYSTEM_TABLE, ptr %108, i32 0, i32 6
  %110 = load ptr, ptr %109, align 8, !tbaa !31
  %111 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %110, i32 0, i32 5
  %112 = load ptr, ptr %111, align 8, !tbaa !34
  %113 = load ptr, ptr @gST, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.EFI_SYSTEM_TABLE, ptr %113, i32 0, i32 6
  %115 = load ptr, ptr %114, align 8, !tbaa !31
  %116 = load i64, ptr %3, align 8, !tbaa !14
  %117 = and i64 %116, 127
  %118 = call i64 %112(ptr noundef %115, i64 noundef %117)
  %119 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 8), align 8, !tbaa !19
  %120 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 7), align 8, !tbaa !15
  %121 = add i64 %119, %120
  %122 = sub i64 %121, 2
  store i64 %122, ptr %4, align 8, !tbaa !20
  %123 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 8), i32 0, i32 1), align 8, !tbaa !21
  %124 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 7), i32 0, i32 1), align 8, !tbaa !17
  %125 = add i64 %123, %124
  %126 = sub i64 %125, 1
  store i64 %126, ptr %5, align 8, !tbaa !20
  store i8 1, ptr %6, align 1, !tbaa !14
  %127 = load i64, ptr %4, align 8, !tbaa !20
  %128 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 4), align 8, !tbaa !22
  %129 = icmp ugt i64 %127, %128
  br i1 %129, label %130, label %131

130:                                              ; preds = %107
  store i8 0, ptr %6, align 1, !tbaa !14
  br label %148

131:                                              ; preds = %107
  %132 = load ptr, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !23
  store ptr %132, ptr %7, align 8, !tbaa !5
  %133 = load i64, ptr %4, align 8, !tbaa !20
  %134 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 6), align 8, !tbaa !24
  %135 = sub i64 %133, %134
  %136 = call ptr @MoveLine(i64 noundef %135)
  store ptr %136, ptr %8, align 8, !tbaa !5
  %137 = load ptr, ptr %8, align 8, !tbaa !5
  %138 = icmp eq ptr %137, null
  br i1 %138, label %145, label %139

139:                                              ; preds = %131
  %140 = load i64, ptr %5, align 8, !tbaa !20
  %141 = load ptr, ptr %8, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %141, i32 0, i32 2
  %143 = load i64, ptr %142, align 8, !tbaa !25
  %144 = icmp ugt i64 %140, %143
  br i1 %144, label %145, label %146

145:                                              ; preds = %139, %131
  store i8 0, ptr %6, align 1, !tbaa !14
  br label %146

146:                                              ; preds = %145, %139
  %147 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %147, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 12), align 8, !tbaa !23
  br label %148

148:                                              ; preds = %146, %130
  %149 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 7), i32 0, i32 1), align 8, !tbaa !17
  %150 = trunc i64 %149 to i32
  %151 = sub nsw i32 %150, 1
  %152 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 7), align 8, !tbaa !15
  %153 = trunc i64 %152 to i32
  %154 = sub nsw i32 %153, 1
  %155 = call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %151, i32 noundef %154, ptr noundef @.str.3)
  %156 = load i8, ptr %6, align 1, !tbaa !14
  %157 = icmp ne i8 %156, 0
  br i1 %157, label %158, label %175

158:                                              ; preds = %148
  %159 = load ptr, ptr %8, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct._EFI_EDITOR_LINE, ptr %159, i32 0, i32 1
  %161 = load ptr, ptr %160, align 8, !tbaa !28
  %162 = load i64, ptr %5, align 8, !tbaa !20
  %163 = sub i64 %162, 1
  %164 = getelementptr inbounds i16, ptr %161, i64 %163
  %165 = load i16, ptr %164, align 2, !tbaa !29
  store i16 %165, ptr %9, align 2, !tbaa !29
  %166 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_POSITION, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 7), i32 0, i32 1), align 8, !tbaa !17
  %167 = trunc i64 %166 to i32
  %168 = sub nsw i32 %167, 1
  %169 = load i64, ptr getelementptr inbounds (%struct.EFI_EDITOR_FILE_BUFFER, ptr @FileBuffer, i32 0, i32 7), align 8, !tbaa !15
  %170 = trunc i64 %169 to i32
  %171 = sub nsw i32 %170, 1
  %172 = load i16, ptr %9, align 2, !tbaa !29
  %173 = zext i16 %172 to i32
  %174 = call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %168, i32 noundef %171, ptr noundef @.str.4, i32 noundef %173)
  br label %175

175:                                              ; preds = %158, %148
  %176 = load ptr, ptr @gST, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.EFI_SYSTEM_TABLE, ptr %176, i32 0, i32 6
  %178 = load ptr, ptr %177, align 8, !tbaa !31
  %179 = getelementptr inbounds %struct._EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, ptr %178, i32 0, i32 5
  %180 = load ptr, ptr %179, align 8, !tbaa !34
  %181 = load ptr, ptr @gST, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.EFI_SYSTEM_TABLE, ptr %181, i32 0, i32 6
  %183 = load ptr, ptr %182, align 8, !tbaa !31
  %184 = load i64, ptr %2, align 8, !tbaa !14
  %185 = call i64 %180(ptr noundef %183, i64 noundef %184)
  br label %186

186:                                              ; preds = %175, %13
  br label %187

187:                                              ; preds = %186, %0
  store i64 0, ptr %1, align 8
  store i32 1, ptr %10, align 4
  br label %188

188:                                              ; preds = %187, %28
  call void @llvm.lifetime.end.p0(i64 2, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %189 = load i64, ptr %1, align 8
  ret i64 %189
}

declare i64 @ShellPrintEx(i32 noundef, i32 noundef, ptr noundef, ...) #3

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 #4 = { 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, !7, i64 40}
!10 = !{!"", !6, i64 0, !7, i64 8, !11, i64 16, !6, i64 32, !7, i64 40, !6, i64 48, !13, i64 56, !13, i64 60}
!11 = !{!"", !12, i64 0, !12, i64 8}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !12, i64 72}
!16 = !{!"", !6, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !11, i64 40, !11, i64 56, !11, i64 72, !11, i64 88, !7, i64 104, !7, i64 105, !7, i64 106, !6, i64 112}
!17 = !{!16, !12, i64 80}
!18 = !{i64 0, i64 8, !14}
!19 = !{!16, !12, i64 88}
!20 = !{!12, !12, i64 0}
!21 = !{!16, !12, i64 96}
!22 = !{!16, !12, i64 32}
!23 = !{!16, !6, i64 112}
!24 = !{!16, !12, i64 56}
!25 = !{!26, !12, i64 16}
!26 = !{!"_EFI_EDITOR_LINE", !12, i64 0, !6, i64 8, !12, i64 16, !12, i64 24, !13, i64 32, !27, i64 40}
!27 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!28 = !{!26, !6, i64 8}
!29 = !{!30, !30, i64 0}
!30 = !{!"short", !7, i64 0}
!31 = !{!32, !6, i64 64}
!32 = !{!"", !33, i64 0, !6, i64 24, !13, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !12, i64 104, !6, i64 112}
!33 = !{!"", !12, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20}
!34 = !{!35, !6, i64 40}
!35 = !{!"_EFI_SIMPLE_TEXT_OUTPUT_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, !6, i64 64, !6, i64 72}


; 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
@FileBufferBackupVar = external dso_local local_unnamed_addr global %struct.EFI_EDITOR_FILE_BUFFER, align 8
@FileBufferMouseNeedRefresh = external dso_local local_unnamed_addr global i8, align 1
@MainEditor = external local_unnamed_addr global %struct.EFI_EDITOR_GLOBAL_EDITOR, align 8
@EditorMouseAction = external local_unnamed_addr global i8, align 1
@.str.3 = external hidden unnamed_addr constant [2 x i32], align 4
@.str.4 = external hidden unnamed_addr constant [3 x i32], align 4
@gST = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: nounwind uwtable
define dso_local noundef i64 @FileBufferRestoreMousePosition() local_unnamed_addr #0 {
  %1 = load i8, ptr getelementptr inbounds (i8, ptr @MainEditor, i64 40), align 8, !tbaa !5
  %2 = icmp ne i8 %1, 0
  %3 = load i8, ptr @FileBufferMouseNeedRefresh, align 1
  %4 = icmp ne i8 %3, 0
  %or.cond4 = select i1 %2, i1 %4, i1 false
  br i1 %or.cond4, label %5, label %128

5:                                                ; preds = %0
  store i8 0, ptr @FileBufferMouseNeedRefresh, align 1, !tbaa !13
  %6 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 72), align 8, !tbaa !14
  %7 = load i64, ptr getelementptr inbounds (i8, ptr @FileBufferBackupVar, i64 72), align 8, !tbaa !14
  %8 = icmp eq i64 %6, %7
  %.pre = load i64, ptr getelementptr inbounds (i8, ptr @FileBufferBackupVar, i64 80), align 8, !tbaa !16
  br i1 %8, label %9, label %14

9:                                                ; preds = %5
  %10 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 80), align 8, !tbaa !16
  %11 = icmp eq i64 %10, %.pre
  %12 = load i8, ptr @EditorMouseAction, align 1
  %13 = icmp ne i8 %12, 0
  %or.cond = select i1 %11, i1 %13, i1 false
  br i1 %or.cond, label %128, label %14

14:                                               ; preds = %9, %5
  %.sroa.025.0.copyload = load i8, ptr getelementptr inbounds (i8, ptr @MainEditor, i64 8), align 8
  %.sroa.6.sroa.0.0.copyload = load i56, ptr getelementptr inbounds (i8, ptr @MainEditor, i64 9), align 1, !tbaa !13
  %15 = tail call i8 @llvm.fshl.i8(i8 %.sroa.025.0.copyload, i8 %.sroa.025.0.copyload, i8 4)
  %16 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 88), align 8, !tbaa !17
  %17 = add i64 %7, -2
  %18 = add i64 %17, %16
  %19 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 96), align 8, !tbaa !18
  %20 = add i64 %.pre, %19
  %21 = add i64 %20, -1
  %22 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 32), align 8, !tbaa !19
  %23 = icmp ugt i64 %18, %22
  br i1 %23, label %.thread, label %29

.thread:                                          ; preds = %14
  %24 = trunc i64 %.pre to i32
  %25 = add nsw i32 %24, -1
  %26 = trunc i64 %7 to i32
  %27 = add nsw i32 %26, -1
  %28 = tail call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %25, i32 noundef %27, ptr noundef nonnull @.str.3) #3
  br label %63

29:                                               ; preds = %14
  %30 = load ptr, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 112), align 8, !tbaa !20
  %31 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 56), align 8, !tbaa !21
  %32 = sub i64 %18, %31
  %33 = tail call ptr @MoveLine(i64 noundef %32)
  %34 = icmp eq ptr %33, null
  br i1 %34, label %.critedge, label %35

35:                                               ; preds = %29
  %36 = getelementptr inbounds i8, ptr %33, i64 16
  %37 = load i64, ptr %36, align 8, !tbaa !22
  %38 = icmp ugt i64 %21, %37
  br i1 %38, label %.critedge, label %44

.critedge:                                        ; preds = %35, %29
  store ptr %30, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 112), align 8, !tbaa !20
  %.pre36.c = load i64, ptr getelementptr inbounds (i8, ptr @FileBufferBackupVar, i64 80), align 8, !tbaa !16
  %.pre37.c = load i64, ptr getelementptr inbounds (i8, ptr @FileBufferBackupVar, i64 72), align 8, !tbaa !14
  %39 = trunc i64 %.pre36.c to i32
  %40 = add nsw i32 %39, -1
  %41 = trunc i64 %.pre37.c to i32
  %42 = add nsw i32 %41, -1
  %43 = tail call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %40, i32 noundef %42, ptr noundef nonnull @.str.3) #3
  br label %63

44:                                               ; preds = %35
  store ptr %30, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 112), align 8, !tbaa !20
  %.pre36 = load i64, ptr getelementptr inbounds (i8, ptr @FileBufferBackupVar, i64 80), align 8, !tbaa !16
  %.pre37 = load i64, ptr getelementptr inbounds (i8, ptr @FileBufferBackupVar, i64 72), align 8, !tbaa !14
  %45 = trunc i64 %.pre36 to i32
  %46 = add nsw i32 %45, -1
  %47 = trunc i64 %.pre37 to i32
  %48 = add nsw i32 %47, -1
  %49 = tail call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %46, i32 noundef %48, ptr noundef nonnull @.str.3) #3
  %50 = getelementptr inbounds i8, ptr %33, i64 8
  %51 = load ptr, ptr %50, align 8, !tbaa !25
  %52 = getelementptr i16, ptr %51, i64 %20
  %53 = getelementptr i8, ptr %52, i64 -4
  %54 = load i16, ptr %53, align 2, !tbaa !26
  %55 = load i64, ptr getelementptr inbounds (i8, ptr @FileBufferBackupVar, i64 80), align 8, !tbaa !16
  %56 = trunc i64 %55 to i32
  %57 = add nsw i32 %56, -1
  %58 = load i64, ptr getelementptr inbounds (i8, ptr @FileBufferBackupVar, i64 72), align 8, !tbaa !14
  %59 = trunc i64 %58 to i32
  %60 = add nsw i32 %59, -1
  %61 = zext i16 %54 to i32
  %62 = tail call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %57, i32 noundef %60, ptr noundef nonnull @.str.4, i32 noundef %61) #3
  br label %63

63:                                               ; preds = %.critedge, %.thread, %44
  %64 = load ptr, ptr @gST, align 8, !tbaa !28
  %65 = getelementptr inbounds i8, ptr %64, i64 64
  %66 = load ptr, ptr %65, align 8, !tbaa !29
  %67 = getelementptr inbounds i8, ptr %66, i64 40
  %68 = load ptr, ptr %67, align 8, !tbaa !32
  %69 = and i8 %15, 127
  %70 = zext nneg i8 %69 to i64
  %71 = tail call i64 %68(ptr noundef %66, i64 noundef %70) #3
  %72 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 88), align 8, !tbaa !17
  %73 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 72), align 8, !tbaa !14
  %74 = add i64 %72, -2
  %75 = add i64 %74, %73
  %76 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 96), align 8, !tbaa !18
  %77 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 80), align 8, !tbaa !16
  %78 = add i64 %77, %76
  %79 = add i64 %78, -1
  %80 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 32), align 8, !tbaa !19
  %81 = icmp ugt i64 %75, %80
  br i1 %81, label %.thread43, label %87

.thread43:                                        ; preds = %63
  %82 = trunc i64 %77 to i32
  %83 = add nsw i32 %82, -1
  %84 = trunc i64 %73 to i32
  %85 = add nsw i32 %84, -1
  %86 = tail call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %83, i32 noundef %85, ptr noundef nonnull @.str.3) #3
  br label %121

87:                                               ; preds = %63
  %88 = load ptr, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 112), align 8, !tbaa !20
  %89 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 56), align 8, !tbaa !21
  %90 = sub i64 %75, %89
  %91 = tail call ptr @MoveLine(i64 noundef %90)
  %92 = icmp eq ptr %91, null
  br i1 %92, label %.critedge47, label %93

93:                                               ; preds = %87
  %94 = getelementptr inbounds i8, ptr %91, i64 16
  %95 = load i64, ptr %94, align 8, !tbaa !22
  %96 = icmp ugt i64 %79, %95
  br i1 %96, label %.critedge47, label %102

.critedge47:                                      ; preds = %93, %87
  store ptr %88, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 112), align 8, !tbaa !20
  %.pre38.c = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 80), align 8, !tbaa !16
  %.pre39.c = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 72), align 8, !tbaa !14
  %97 = trunc i64 %.pre38.c to i32
  %98 = add nsw i32 %97, -1
  %99 = trunc i64 %.pre39.c to i32
  %100 = add nsw i32 %99, -1
  %101 = tail call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %98, i32 noundef %100, ptr noundef nonnull @.str.3) #3
  br label %121

102:                                              ; preds = %93
  store ptr %88, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 112), align 8, !tbaa !20
  %.pre38 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 80), align 8, !tbaa !16
  %.pre39 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 72), align 8, !tbaa !14
  %103 = trunc i64 %.pre38 to i32
  %104 = add nsw i32 %103, -1
  %105 = trunc i64 %.pre39 to i32
  %106 = add nsw i32 %105, -1
  %107 = tail call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %104, i32 noundef %106, ptr noundef nonnull @.str.3) #3
  %108 = getelementptr inbounds i8, ptr %91, i64 8
  %109 = load ptr, ptr %108, align 8, !tbaa !25
  %110 = getelementptr i16, ptr %109, i64 %78
  %111 = getelementptr i8, ptr %110, i64 -4
  %112 = load i16, ptr %111, align 2, !tbaa !26
  %113 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 80), align 8, !tbaa !16
  %114 = trunc i64 %113 to i32
  %115 = add nsw i32 %114, -1
  %116 = load i64, ptr getelementptr inbounds (i8, ptr @FileBuffer, i64 72), align 8, !tbaa !14
  %117 = trunc i64 %116 to i32
  %118 = add nsw i32 %117, -1
  %119 = zext i16 %112 to i32
  %120 = tail call i64 (i32, i32, ptr, ...) @ShellPrintEx(i32 noundef %115, i32 noundef %118, ptr noundef nonnull @.str.4, i32 noundef %119) #3
  br label %121

121:                                              ; preds = %.critedge47, %.thread43, %102
  %122 = load ptr, ptr @gST, align 8, !tbaa !28
  %123 = getelementptr inbounds i8, ptr %122, i64 64
  %124 = load ptr, ptr %123, align 8, !tbaa !29
  %125 = getelementptr inbounds i8, ptr %124, i64 40
  %126 = load ptr, ptr %125, align 8, !tbaa !32
  %.sroa.6.0.insert.ext = zext i56 %.sroa.6.sroa.0.0.copyload to i64
  %.sroa.6.0.insert.shift = shl nuw i64 %.sroa.6.0.insert.ext, 8
  %.sroa.025.0.insert.ext = zext i8 %.sroa.025.0.copyload to i64
  %.sroa.025.0.insert.insert = or disjoint i64 %.sroa.6.0.insert.shift, %.sroa.025.0.insert.ext
  %127 = tail call i64 %126(ptr noundef %124, i64 noundef %.sroa.025.0.insert.insert) #3
  br label %128

128:                                              ; preds = %0, %121, %9
  ret i64 0
}

declare i64 @ShellPrintEx(i32 noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i8 @llvm.fshl.i8(i8, i8, i8) #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, !8, i64 40}
!6 = !{!"", !7, i64 0, !8, i64 8, !10, i64 16, !7, i64 32, !8, i64 40, !7, i64 48, !12, i64 56, !12, i64 60}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !11, i64 8}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!15, !11, i64 72}
!15 = !{!"", !7, i64 0, !12, i64 8, !7, i64 16, !7, i64 24, !11, i64 32, !10, i64 40, !10, i64 56, !10, i64 72, !10, i64 88, !8, i64 104, !8, i64 105, !8, i64 106, !7, i64 112}
!16 = !{!15, !11, i64 80}
!17 = !{!15, !11, i64 88}
!18 = !{!15, !11, i64 96}
!19 = !{!15, !11, i64 32}
!20 = !{!15, !7, i64 112}
!21 = !{!15, !11, i64 56}
!22 = !{!23, !11, i64 16}
!23 = !{!"_EFI_EDITOR_LINE", !11, i64 0, !7, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !24, i64 40}
!24 = !{!"_LIST_ENTRY", !7, i64 0, !7, i64 8}
!25 = !{!23, !7, i64 8}
!26 = !{!27, !27, i64 0}
!27 = !{!"short", !8, i64 0}
!28 = !{!7, !7, i64 0}
!29 = !{!30, !7, i64 64}
!30 = !{!"", !31, i64 0, !7, i64 24, !12, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !11, i64 104, !7, i64 112}
!31 = !{!"", !11, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!32 = !{!33, !7, i64 40}
!33 = !{!"_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72}


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