; LLVM IR from hoytech/vmtouch :: vmtouch (print_page_residency_chart)

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

@.str.44 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #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 i32 @is_mincore_page_resident(i8 noundef signext) #2

; Function Attrs: nounwind uwtable
define dso_local void @print_page_residency_chart(ptr noundef %0, ptr noundef %1, i64 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 0, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !9
  %12 = load i64, ptr %6, align 8, !tbaa !9
  %13 = icmp sle i64 %12, 60
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  store i64 1, ptr %8, align 8, !tbaa !9
  br label %19

15:                                               ; preds = %3
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = sdiv i64 %16, 60
  %18 = add nsw i64 %17, 1
  store i64 %18, ptr %8, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %15, %14
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.44) #4
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %63, %19
  %23 = load i64, ptr %9, align 8, !tbaa !9
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = icmp slt i64 %23, %24
  br i1 %25, label %26, label %66

26:                                               ; preds = %22
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %9, align 8, !tbaa !9
  %29 = getelementptr inbounds i8, ptr %27, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !11
  %31 = call i32 @is_mincore_page_resident(i8 noundef signext %30)
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %38

33:                                               ; preds = %26
  %34 = load i64, ptr %11, align 8, !tbaa !9
  %35 = add nsw i64 %34, 1
  store i64 %35, ptr %11, align 8, !tbaa !9
  %36 = load i64, ptr %7, align 8, !tbaa !9
  %37 = add nsw i64 %36, 1
  store i64 %37, ptr %7, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %33, %26
  %39 = load i64, ptr %10, align 8, !tbaa !9
  %40 = add nsw i64 %39, 1
  store i64 %40, ptr %10, align 8, !tbaa !9
  %41 = load i64, ptr %10, align 8, !tbaa !9
  %42 = load i64, ptr %8, align 8, !tbaa !9
  %43 = icmp eq i64 %41, %42
  br i1 %43, label %44, label %62

44:                                               ; preds = %38
  %45 = load i64, ptr %11, align 8, !tbaa !9
  %46 = load i64, ptr %8, align 8, !tbaa !9
  %47 = icmp eq i64 %45, %46
  br i1 %47, label %48, label %51

48:                                               ; preds = %44
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.45) #4
  br label %61

51:                                               ; preds = %44
  %52 = load i64, ptr %11, align 8, !tbaa !9
  %53 = icmp eq i64 %52, 0
  br i1 %53, label %54, label %57

54:                                               ; preds = %51
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.46) #4
  br label %60

57:                                               ; preds = %51
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str.47) #4
  br label %60

60:                                               ; preds = %57, %54
  br label %61

61:                                               ; preds = %60, %48
  store i64 0, ptr %11, align 8, !tbaa !9
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %61, %38
  br label %63

63:                                               ; preds = %62
  %64 = load i64, ptr %9, align 8, !tbaa !9
  %65 = add nsw i64 %64, 1
  store i64 %65, ptr %9, align 8, !tbaa !9
  br label %22, !llvm.loop !12

66:                                               ; preds = %22
  %67 = load i64, ptr %10, align 8, !tbaa !9
  %68 = icmp ne i64 %67, 0
  br i1 %68, label %69, label %87

69:                                               ; preds = %66
  %70 = load i64, ptr %11, align 8, !tbaa !9
  %71 = load i64, ptr %10, align 8, !tbaa !9
  %72 = icmp eq i64 %70, %71
  br i1 %72, label %73, label %76

73:                                               ; preds = %69
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %74, ptr noundef @.str.45) #4
  br label %86

76:                                               ; preds = %69
  %77 = load i64, ptr %11, align 8, !tbaa !9
  %78 = icmp eq i64 %77, 0
  br i1 %78, label %79, label %82

79:                                               ; preds = %76
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef @.str.46) #4
  br label %85

82:                                               ; preds = %76
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.47) #4
  br label %85

85:                                               ; preds = %82, %79
  br label %86

86:                                               ; preds = %85, %73
  br label %87

87:                                               ; preds = %86, %66
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = load i64, ptr %7, align 8, !tbaa !9
  %90 = load i64, ptr %6, align 8, !tbaa !9
  %91 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef @.str.48, i64 noundef %89, i64 noundef %90) #4
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = call i32 @fflush(ptr noundef %92)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, 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
  ret void
}

declare i32 @fflush(ptr noundef) #3

attributes #0 = { nounwind "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 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@.str.44 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @is_mincore_page_resident(i8 noundef signext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @print_page_residency_chart(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = icmp slt i64 %2, 61
  br i1 %4, label %8, label %.thread

.thread:                                          ; preds = %3
  %5 = udiv i64 %2, 60
  %6 = add nuw nsw i64 %5, 1
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.44) #2
  br label %.lr.ph.preheader

8:                                                ; preds = %3
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.44) #2
  %10 = icmp sgt i64 %2, 0
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge.thread

.lr.ph.preheader:                                 ; preds = %.thread, %8
  %.03246 = phi i64 [ %6, %.thread ], [ 1, %8 ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %20
  %.042 = phi i64 [ %.2, %20 ], [ 0, %.lr.ph.preheader ]
  %.02941 = phi i64 [ %.130, %20 ], [ 0, %.lr.ph.preheader ]
  %.03140 = phi i64 [ %21, %20 ], [ 0, %.lr.ph.preheader ]
  %.03339 = phi i64 [ %.134, %20 ], [ 0, %.lr.ph.preheader ]
  %11 = getelementptr inbounds i8, ptr %1, i64 %.03140
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = tail call i32 @is_mincore_page_resident(i8 noundef signext %12)
  %.not38 = icmp ne i32 %13, 0
  %14 = zext i1 %.not38 to i64
  %.134 = add nuw nsw i64 %.03339, %14
  %.1 = add nsw i64 %.042, %14
  %15 = add nsw i64 %.02941, 1
  %16 = icmp eq i64 %15, %.03246
  br i1 %16, label %.sink.split, label %20

.sink.split:                                      ; preds = %.lr.ph
  %17 = icmp eq i64 %.1, %.03246
  %18 = icmp eq i64 %.1, 0
  %.str.46..str.47 = select i1 %18, ptr @.str.46, ptr @.str.47
  %.str.45.sink = select i1 %17, ptr @.str.45, ptr %.str.46..str.47
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull %.str.45.sink) #2
  br label %20

20:                                               ; preds = %.sink.split, %.lr.ph
  %.130 = phi i64 [ %15, %.lr.ph ], [ 0, %.sink.split ]
  %.2 = phi i64 [ %.1, %.lr.ph ], [ 0, %.sink.split ]
  %21 = add nuw nsw i64 %.03140, 1
  %exitcond.not = icmp eq i64 %21, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %20
  %.not = icmp eq i64 %.130, 0
  br i1 %.not, label %._crit_edge.thread, label %._crit_edge.thread.sink.split

._crit_edge.thread.sink.split:                    ; preds = %._crit_edge
  %22 = icmp eq i64 %.2, %.130
  %23 = icmp eq i64 %.2, 0
  %.str.46..str.4753 = select i1 %23, ptr @.str.46, ptr @.str.47
  %.str.45.sink52 = select i1 %22, ptr @.str.45, ptr %.str.46..str.4753
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull %.str.45.sink52) #2
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %._crit_edge.thread.sink.split, %8, %._crit_edge
  %.033.lcssa51 = phi i64 [ %.134, %._crit_edge ], [ 0, %8 ], [ %.134, %._crit_edge.thread.sink.split ]
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.48, i64 noundef %.033.lcssa51, i64 noundef %2) #2
  %26 = tail call i32 @fflush(ptr noundef %0)
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #0

attributes #0 = { nofree nounwind "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 = { 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 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass