; LLVM IR from DionysiosB/CodeForces :: 1200-1299 (1250H-HappyBirthday)

; 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 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [1 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 i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %10

10:                                               ; preds = %67, %0
  %11 = load i64, ptr %2, align 8, !tbaa !5
  %12 = add nsw i64 %11, -1
  store i64 %12, ptr %2, align 8, !tbaa !5
  %13 = icmp ne i64 %11, 0
  br i1 %13, label %14, label %69

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 80, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %24, %14
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %17 = icmp slt i64 %16, 10
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %27

19:                                               ; preds = %15
  %20 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 0
  %21 = load i64, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %20, i64 %21
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %22)
  br label %24

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

27:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %28 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 0
  %29 = load i64, ptr %28, align 16, !tbaa !5
  store i64 %29, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 9, ptr %7, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %47, %27
  %31 = load i64, ptr %7, align 8, !tbaa !5
  %32 = icmp sge i64 %31, 1
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %50

34:                                               ; preds = %30
  %35 = load i64, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = load i64, ptr %6, align 8, !tbaa !5
  %39 = icmp sle i64 %37, %38
  br i1 %39, label %40, label %46

40:                                               ; preds = %34
  %41 = load i64, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds [10 x i64], ptr %3, i64 0, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !5
  store i64 %43, ptr %6, align 8, !tbaa !5
  %44 = load i64, ptr %7, align 8, !tbaa !5
  %45 = trunc i64 %44 to i32
  store i32 %45, ptr %5, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %40, %34
  br label %47

47:                                               ; preds = %46
  %48 = load i64, ptr %7, align 8, !tbaa !5
  %49 = add nsw i64 %48, -1
  store i64 %49, ptr %7, align 8, !tbaa !5
  br label %30, !llvm.loop !13

50:                                               ; preds = %33
  %51 = load i32, ptr %5, align 4, !tbaa !11
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %55

53:                                               ; preds = %50
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %55

55:                                               ; preds = %53, %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %64, %55
  %57 = load i64, ptr %8, align 8, !tbaa !5
  %58 = load i64, ptr %6, align 8, !tbaa !5
  %59 = icmp sle i64 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %67

61:                                               ; preds = %56
  %62 = load i32, ptr %5, align 4, !tbaa !11
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %62)
  br label %64

64:                                               ; preds = %61
  %65 = load i64, ptr %8, align 8, !tbaa !5
  %66 = add nsw i64 %65, 1
  store i64 %66, ptr %8, align 8, !tbaa !5
  br label %56, !llvm.loop !14

67:                                               ; preds = %60
  %68 = call i32 @puts(ptr noundef @.str.3)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 80, ptr %3) #3
  br label %10, !llvm.loop !15

69:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  ret i32 0
}

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

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

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

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

declare i32 @puts(ptr noundef) #2

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 = { "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"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


; 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 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [1 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
  %2 = alloca [10 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = add nsw i64 %4, -1
  store i64 %5, ptr %1, align 8, !tbaa !5
  %.not29 = icmp eq i64 %4, 0
  br i1 %.not29, label %._crit_edge32, label %.lr.ph31.preheader

.lr.ph31.preheader:                               ; preds = %0
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = getelementptr inbounds i8, ptr %2, i64 16
  %8 = getelementptr inbounds i8, ptr %2, i64 24
  %9 = getelementptr inbounds i8, ptr %2, i64 32
  %10 = getelementptr inbounds i8, ptr %2, i64 40
  %11 = getelementptr inbounds i8, ptr %2, i64 48
  %12 = getelementptr inbounds i8, ptr %2, i64 56
  %13 = getelementptr inbounds i8, ptr %2, i64 64
  %14 = getelementptr inbounds i8, ptr %2, i64 72
  br label %.lr.ph31

.lr.ph31:                                         ; preds = %.lr.ph31.preheader, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %2) #4
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %6)
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %7)
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %8)
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %9)
  %20 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %10)
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %11)
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %12)
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %13)
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %14)
  %25 = load i64, ptr %2, align 16, !tbaa !5
  %26 = load i64, ptr %14, align 8, !tbaa !5
  %.not21 = icmp sgt i64 %26, %25
  %spec.select = select i1 %.not21, i32 0, i32 9
  %spec.select22 = call i64 @llvm.smin.i64(i64 %26, i64 %25)
  %27 = load i64, ptr %13, align 16, !tbaa !5
  %.not21.1 = icmp sgt i64 %27, %spec.select22
  %spec.select.1 = select i1 %.not21.1, i32 %spec.select, i32 8
  %spec.select22.1 = call i64 @llvm.smin.i64(i64 %27, i64 %spec.select22)
  %28 = load i64, ptr %12, align 8, !tbaa !5
  %.not21.2 = icmp sgt i64 %28, %spec.select22.1
  %spec.select.2 = select i1 %.not21.2, i32 %spec.select.1, i32 7
  %spec.select22.2 = call i64 @llvm.smin.i64(i64 %28, i64 %spec.select22.1)
  %29 = load i64, ptr %11, align 16, !tbaa !5
  %.not21.3 = icmp sgt i64 %29, %spec.select22.2
  %spec.select.3 = select i1 %.not21.3, i32 %spec.select.2, i32 6
  %spec.select22.3 = call i64 @llvm.smin.i64(i64 %29, i64 %spec.select22.2)
  %30 = load i64, ptr %10, align 8, !tbaa !5
  %.not21.4 = icmp sgt i64 %30, %spec.select22.3
  %spec.select.4 = select i1 %.not21.4, i32 %spec.select.3, i32 5
  %spec.select22.4 = call i64 @llvm.smin.i64(i64 %30, i64 %spec.select22.3)
  %31 = load i64, ptr %9, align 16, !tbaa !5
  %.not21.5 = icmp sgt i64 %31, %spec.select22.4
  %spec.select.5 = select i1 %.not21.5, i32 %spec.select.4, i32 4
  %spec.select22.5 = call i64 @llvm.smin.i64(i64 %31, i64 %spec.select22.4)
  %32 = load i64, ptr %8, align 8, !tbaa !5
  %.not21.6 = icmp sgt i64 %32, %spec.select22.5
  %spec.select.6 = select i1 %.not21.6, i32 %spec.select.5, i32 3
  %spec.select22.6 = call i64 @llvm.smin.i64(i64 %32, i64 %spec.select22.5)
  %33 = load i64, ptr %7, align 16, !tbaa !5
  %.not21.7 = icmp sgt i64 %33, %spec.select22.6
  %spec.select.7 = select i1 %.not21.7, i32 %spec.select.6, i32 2
  %spec.select22.7 = call i64 @llvm.smin.i64(i64 %33, i64 %spec.select22.6)
  %34 = load i64, ptr %6, align 8, !tbaa !5
  %.not21.8 = icmp sgt i64 %34, %spec.select22.7
  %spec.select.8 = select i1 %.not21.8, i32 %spec.select.7, i32 1
  %spec.select22.8 = call i64 @llvm.smin.i64(i64 %34, i64 %spec.select22.7)
  %35 = icmp eq i32 %spec.select.8, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %.lr.ph31
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %38

38:                                               ; preds = %36, %.lr.ph31
  %.not2027 = icmp slt i64 %spec.select22.8, 0
  br i1 %.not2027, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %38
  %39 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #4
  %40 = load i64, ptr %1, align 8, !tbaa !5
  %41 = add nsw i64 %40, -1
  store i64 %41, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %40, 0
  br i1 %.not, label %._crit_edge32, label %.lr.ph31, !llvm.loop !9

.lr.ph:                                           ; preds = %38, %.lr.ph
  %.028 = phi i64 [ %43, %.lr.ph ], [ 0, %38 ]
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %spec.select.8)
  %43 = add nuw i64 %.028, 1
  %exitcond.not = icmp eq i64 %.028, %spec.select22.8
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge32:                                    ; preds = %._crit_edge, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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"}
!11 = distinct !{!11, !10}


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