; LLVM IR from alekras/ao.rtos.cpp :: Library/Display/display.ll (ZN7Display11clearScreenEi)

; 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"

%class.Display = type { i32, i32, i32, i32, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Display11clearScreenEi(ptr noundef nonnull align 4 dereferenceable(24) %0, i32 noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %9 = getelementptr inbounds %class.Display, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !11
  store i32 %10, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %11 = getelementptr inbounds %class.Display, ptr %8, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !13
  store i32 %12, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %25, %2
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = getelementptr inbounds %class.Display, ptr %8, i32 0, i32 2
  %16 = load i32, ptr %15, align 4, !tbaa !14
  %17 = getelementptr inbounds %class.Display, ptr %8, i32 0, i32 3
  %18 = load i32, ptr %17, align 4, !tbaa !15
  %19 = mul nsw i32 %16, %18
  %20 = icmp slt i32 %14, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %28

22:                                               ; preds = %13
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = trunc i32 %23 to i8
  call void @_ZN7Display5printEc(ptr noundef nonnull align 4 dereferenceable(24) %8, i8 noundef signext %24)
  br label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %7, align 4, !tbaa !9
  br label %13, !llvm.loop !16

28:                                               ; preds = %21
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = getelementptr inbounds %class.Display, ptr %8, i32 0, i32 0
  store i32 %29, ptr %30, align 4, !tbaa !11
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = getelementptr inbounds %class.Display, ptr %8, i32 0, i32 1
  store i32 %31, ptr %32, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Display5printEc(ptr noundef nonnull align 4 dereferenceable(24), i8 noundef signext) #0 align 2

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

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS7Display", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; 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"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Display11clearScreenEi(ptr noundef nonnull align 4 dereferenceable(24) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = load <2 x i32>, ptr %0, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = load i32, ptr %4, align 4, !tbaa !9
  %7 = load i32, ptr %5, align 4, !tbaa !11
  %8 = mul nsw i32 %7, %6
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %10 = trunc i32 %1 to i8
  br label %11

._crit_edge:                                      ; preds = %11, %2
  store <2 x i32> %3, ptr %0, align 4, !tbaa !5
  ret void

11:                                               ; preds = %.lr.ph, %11
  %.05 = phi i32 [ 0, %.lr.ph ], [ %12, %11 ]
  tail call void @_ZN7Display5printEc(ptr noundef nonnull align 4 dereferenceable(24) %0, i8 noundef signext %10)
  %12 = add nuw nsw i32 %.05, 1
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = load i32, ptr %5, align 4, !tbaa !11
  %15 = mul nsw i32 %14, %13
  %16 = icmp slt i32 %12, %15
  br i1 %16, label %11, label %._crit_edge, !llvm.loop !12
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Display5printEc(ptr noundef nonnull align 4 dereferenceable(24), i8 noundef signext) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTS7Display", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20}
!11 = !{!10, !6, i64 12}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass