; LLVM IR from DionysiosB/CodeForces :: 1600-1699 (1663B-MikesSequence)

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

@__const.main.w = external hidden unnamed_addr constant [10 x i64], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca [10 x i64], align 16
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store i64 10, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80, ptr %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const.main.w, i64 80, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 9, ptr %5, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %25, %0
  %9 = load i64, ptr %5, align 8, !tbaa !5
  %10 = icmp sgt i64 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %6, align 4
  br label %28

12:                                               ; preds = %8
  %13 = load i64, ptr %4, align 8, !tbaa !5
  %14 = load i64, ptr %5, align 8, !tbaa !5
  %15 = sub nsw i64 %14, 1
  %16 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %18 = icmp sge i64 %13, %17
  br i1 %18, label %19, label %24

19:                                               ; preds = %12
  %20 = load i64, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !5
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %22)
  store i32 2, ptr %6, align 4
  br label %28

24:                                               ; preds = %12
  br label %25

25:                                               ; preds = %24
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = add nsw i64 %26, -1
  store i64 %27, ptr %5, align 8, !tbaa !5
  br label %8, !llvm.loop !9

28:                                               ; preds = %19, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %29

29:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %30 = load i32, ptr %1, align 4
  ret i32 %30
}

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

declare i32 @printf(ptr noundef, ...) #3

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

attributes #0 = { mustprogress norecurse 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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"

@__const.main.w = external hidden unnamed_addr constant [10 x i64], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = load i64, ptr getelementptr inbounds (i8, ptr @__const.main.w, i64 64), align 16, !tbaa !5
  %.not = icmp slt i64 %3, %4
  br i1 %.not, label %5, label %21, !llvm.loop !9

5:                                                ; preds = %0
  %6 = load i64, ptr getelementptr inbounds (i8, ptr @__const.main.w, i64 56), align 8, !tbaa !5
  %.not.1 = icmp slt i64 %3, %6
  br i1 %.not.1, label %7, label %21, !llvm.loop !9

7:                                                ; preds = %5
  %8 = load i64, ptr getelementptr inbounds (i8, ptr @__const.main.w, i64 48), align 16, !tbaa !5
  %.not.2 = icmp slt i64 %3, %8
  br i1 %.not.2, label %9, label %21, !llvm.loop !9

9:                                                ; preds = %7
  %10 = load i64, ptr getelementptr inbounds (i8, ptr @__const.main.w, i64 40), align 8, !tbaa !5
  %.not.3 = icmp slt i64 %3, %10
  br i1 %.not.3, label %11, label %21, !llvm.loop !9

11:                                               ; preds = %9
  %12 = load i64, ptr getelementptr inbounds (i8, ptr @__const.main.w, i64 32), align 16, !tbaa !5
  %.not.4 = icmp slt i64 %3, %12
  br i1 %.not.4, label %13, label %21, !llvm.loop !9

13:                                               ; preds = %11
  %14 = load i64, ptr getelementptr inbounds (i8, ptr @__const.main.w, i64 24), align 8, !tbaa !5
  %.not.5 = icmp slt i64 %3, %14
  br i1 %.not.5, label %15, label %21, !llvm.loop !9

15:                                               ; preds = %13
  %16 = load i64, ptr getelementptr inbounds (i8, ptr @__const.main.w, i64 16), align 16, !tbaa !5
  %.not.6 = icmp slt i64 %3, %16
  br i1 %.not.6, label %17, label %21, !llvm.loop !9

17:                                               ; preds = %15
  %18 = load i64, ptr getelementptr inbounds (i8, ptr @__const.main.w, i64 8), align 8, !tbaa !5
  %.not.7 = icmp slt i64 %3, %18
  br i1 %.not.7, label %19, label %21, !llvm.loop !9

19:                                               ; preds = %17
  %20 = load i64, ptr @__const.main.w, align 16, !tbaa !5
  %.not.8 = icmp slt i64 %3, %20
  br i1 %.not.8, label %.loopexit, label %21, !llvm.loop !9

21:                                               ; preds = %19, %17, %15, %13, %11, %9, %7, %5, %0
  %.0.lcssa6 = phi i64 [ 9, %0 ], [ 8, %5 ], [ 7, %7 ], [ 6, %9 ], [ 5, %11 ], [ 4, %13 ], [ 3, %15 ], [ 2, %17 ], [ 1, %19 ]
  %22 = getelementptr inbounds [10 x i64], ptr @__const.main.w, i64 0, i64 %.0.lcssa6
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %23)
  br label %.loopexit

.loopexit:                                        ; preds = %19, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret i32 0
}

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

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

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

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

attributes #0 = { mustprogress nofree norecurse 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass