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

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

@HBufferImage = external dso_local global %struct.HEFI_EDITOR_BUFFER_IMAGE, align 8
@HBufferImageMouseNeedRefresh = external dso_local global i8, align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @HBufferImageMovePosition(i64 noundef, i64 noundef, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @HBufferImageEnd() #1 {
  %1 = alloca ptr, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  store i8 1, ptr @HBufferImageMouseNeedRefresh, align 1, !tbaa !5
  %5 = load ptr, ptr getelementptr inbounds (%struct.HEFI_EDITOR_BUFFER_IMAGE, ptr @HBufferImage, i32 0, i32 3), align 8, !tbaa !8
  store ptr %5, ptr %1, align 8, !tbaa !14
  %6 = load i64, ptr getelementptr inbounds (%struct.HEFI_EDITOR_BUFFER_IMAGE, ptr @HBufferImage, i32 0, i32 6), align 8, !tbaa !15
  store i64 %6, ptr %2, align 8, !tbaa !16
  %7 = load ptr, ptr %1, align 8, !tbaa !14
  %8 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %7, i32 0, i32 2
  %9 = load i64, ptr %8, align 8, !tbaa !17
  %10 = icmp eq i64 %9, 16
  br i1 %10, label %11, label %15

11:                                               ; preds = %0
  %12 = load ptr, ptr %1, align 8, !tbaa !14
  %13 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %12, i32 0, i32 2
  %14 = load i64, ptr %13, align 8, !tbaa !17
  store i64 %14, ptr %3, align 8, !tbaa !16
  store i8 0, ptr %4, align 1, !tbaa !5
  br label %20

15:                                               ; preds = %0
  %16 = load ptr, ptr %1, align 8, !tbaa !14
  %17 = getelementptr inbounds %struct._HEFI_EDITOR_LINE, ptr %16, i32 0, i32 2
  %18 = load i64, ptr %17, align 8, !tbaa !17
  %19 = add i64 %18, 1
  store i64 %19, ptr %3, align 8, !tbaa !16
  store i8 1, ptr %4, align 1, !tbaa !5
  br label %20

20:                                               ; preds = %15, %11
  %21 = load i64, ptr %2, align 8, !tbaa !16
  %22 = load i64, ptr %3, align 8, !tbaa !16
  %23 = load i8, ptr %4, align 1, !tbaa !5
  call void @HBufferImageMovePosition(i64 noundef %21, i64 noundef %22, i8 noundef zeroext %23)
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  ret i64 0
}

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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 24}
!9 = !{!"", !10, i64 0, !10, i64 8, !11, i64 16, !10, i64 24, !12, i64 32, !12, i64 48, !12, i64 64, !11, i64 80, !6, i64 88, !6, i64 89, !13, i64 92, !10, i64 96, !10, i64 104, !10, i64 112}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"long long", !6, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 8}
!13 = !{!"int", !6, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{!9, !11, i64 64}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !11, i64 24}
!18 = !{!"_HEFI_EDITOR_LINE", !11, i64 0, !6, i64 8, !11, i64 24, !19, i64 32}
!19 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}


; 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_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 }

@HBufferImage = external dso_local local_unnamed_addr global %struct.HEFI_EDITOR_BUFFER_IMAGE, align 8
@HBufferImageMouseNeedRefresh = external dso_local local_unnamed_addr global i8, align 1

; Function Attrs: nounwind uwtable
declare dso_local void @HBufferImageMovePosition(i64 noundef, i64 noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i64 @HBufferImageEnd() local_unnamed_addr #0 {
  store i8 1, ptr @HBufferImageMouseNeedRefresh, align 1, !tbaa !5
  %1 = load ptr, ptr getelementptr inbounds (i8, ptr @HBufferImage, i64 24), align 8, !tbaa !8
  %2 = load i64, ptr getelementptr inbounds (i8, ptr @HBufferImage, i64 64), align 8, !tbaa !14
  %3 = getelementptr inbounds i8, ptr %1, i64 24
  %4 = load i64, ptr %3, align 8, !tbaa !15
  %5 = icmp ne i64 %4, 16
  %6 = add i64 %4, 1
  %.05 = select i1 %5, i64 %6, i64 16
  %.0 = zext i1 %5 to i8
  tail call void @HBufferImageMovePosition(i64 noundef %2, i64 noundef %.05, i8 noundef zeroext %.0)
  ret i64 0
}

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 24}
!9 = !{!"", !10, i64 0, !10, i64 8, !11, i64 16, !10, i64 24, !12, i64 32, !12, i64 48, !12, i64 64, !11, i64 80, !6, i64 88, !6, i64 89, !13, i64 92, !10, i64 96, !10, i64 104, !10, i64 112}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"long long", !6, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 8}
!13 = !{!"int", !6, i64 0}
!14 = !{!9, !11, i64 64}
!15 = !{!16, !11, i64 24}
!16 = !{!"_HEFI_EDITOR_LINE", !11, i64 0, !6, i64 8, !11, i64 24, !17, i64 32}
!17 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}


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