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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

15:                                               ; preds = %26, %3
  %16 = getelementptr inbounds %class.Display, ptr %9, i32 0, i32 1
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %18 = getelementptr inbounds %class.Display, ptr %9, i32 0, i32 3
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = icmp slt i32 %17, %19
  br i1 %20, label %21, label %30

21:                                               ; preds = %15
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = getelementptr inbounds %class.Display, ptr %9, i32 0, i32 0
  store i32 %22, ptr %23, align 4, !tbaa !11
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = trunc i32 %24 to i8
  call void @_ZN7Display5printEc(ptr noundef nonnull align 4 dereferenceable(24) %9, i8 noundef signext %25)
  br label %26

26:                                               ; preds = %21
  %27 = getelementptr inbounds %class.Display, ptr %9, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !13
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %27, align 4, !tbaa !13
  br label %15, !llvm.loop !15

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 12}
!15 = distinct !{!15, !16}
!16 = !{!"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
declare dso_local void @_ZN7Display5printEc(ptr noundef nonnull align 4 dereferenceable(24), i8 noundef signext) local_unnamed_addr #0 align 2

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

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

10:                                               ; preds = %.lr.ph, %10
  store i32 %2, ptr %0, align 4, !tbaa !12
  tail call void @_ZN7Display5printEc(ptr noundef nonnull align 4 dereferenceable(24) %0, i8 noundef signext %9)
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = add nsw i32 %11, 1
  store i32 %12, ptr %4, align 4, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !11
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %10, label %._crit_edge, !llvm.loop !13

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

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 4}
!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 = !{!10, !6, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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