; LLVM IR from DionysiosB/CodeForces :: 1500-1599 (1520B-OrdinaryNumbers)

; 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 [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 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 i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %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 = %47, %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 %50

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

16:                                               ; preds = %44, %14
  %17 = load i64, ptr %5, align 8, !tbaa !5
  %18 = icmp sle i64 %17, 9
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 4, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %47

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %21 = load i64, ptr %5, align 8, !tbaa !5
  store i64 %21, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 1, ptr %8, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %39, %20
  %23 = load i64, ptr %8, align 8, !tbaa !5
  %24 = icmp sle i64 %23, 10
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  store i32 7, ptr %6, align 4
  br label %42

26:                                               ; preds = %22
  %27 = load i64, ptr %7, align 8, !tbaa !5
  %28 = load i64, ptr %3, align 8, !tbaa !5
  %29 = icmp sle i64 %27, %28
  br i1 %29, label %30, label %33

30:                                               ; preds = %26
  %31 = load i64, ptr %4, align 8, !tbaa !5
  %32 = add nsw i64 %31, 1
  store i64 %32, ptr %4, align 8, !tbaa !5
  br label %34

33:                                               ; preds = %26
  store i32 7, ptr %6, align 4
  br label %42

34:                                               ; preds = %30
  %35 = load i64, ptr %7, align 8, !tbaa !5
  %36 = mul nsw i64 10, %35
  %37 = load i64, ptr %5, align 8, !tbaa !5
  %38 = add nsw i64 %36, %37
  store i64 %38, ptr %7, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %34
  %40 = load i64, ptr %8, align 8, !tbaa !5
  %41 = add nsw i64 %40, 1
  store i64 %41, ptr %8, align 8, !tbaa !5
  br label %22, !llvm.loop !9

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

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

44:                                               ; preds = %43
  %45 = load i64, ptr %5, align 8, !tbaa !5
  %46 = add nsw i64 %45, 1
  store i64 %46, ptr %5, align 8, !tbaa !5
  br label %16, !llvm.loop !11

47:                                               ; preds = %19
  %48 = load i64, ptr %4, align 8, !tbaa !5
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %48)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %10, !llvm.loop !12

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

; 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

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 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}
!12 = distinct !{!12, !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 [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 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 i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %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
  %.not21 = icmp eq i64 %4, 0
  br i1 %.not21, label %._crit_edge24, label %.lr.ph23

.lr.ph23:                                         ; preds = %0, %._crit_edge.8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %7 = load i64, ptr %2, align 8
  %.not1415 = icmp slt i64 %7, 1
  br i1 %.not1415, label %._crit_edge.8, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph23, %.lr.ph
  %.018 = phi i64 [ %11, %.lr.ph ], [ 1, %.lr.ph23 ]
  %.01117 = phi i64 [ %10, %.lr.ph ], [ 1, %.lr.ph23 ]
  %.116 = phi i64 [ %8, %.lr.ph ], [ 0, %.lr.ph23 ]
  %8 = add nuw nsw i64 %.116, 1
  %9 = mul nsw i64 %.01117, 10
  %10 = or disjoint i64 %9, 1
  %11 = add nuw nsw i64 %.018, 1
  %12 = icmp ugt i64 %.018, 9
  %.not14 = icmp sge i64 %9, %7
  %or.cond = select i1 %12, i1 true, i1 %.not14
  br i1 %or.cond, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph
  %.not1415.1 = icmp eq i64 %7, 1
  br i1 %.not1415.1, label %._crit_edge.8, label %.lr.ph.1

.lr.ph.1:                                         ; preds = %._crit_edge, %.lr.ph.1
  %.018.1 = phi i64 [ %16, %.lr.ph.1 ], [ 1, %._crit_edge ]
  %.01117.1 = phi i64 [ %15, %.lr.ph.1 ], [ 2, %._crit_edge ]
  %.116.1 = phi i64 [ %13, %.lr.ph.1 ], [ %8, %._crit_edge ]
  %13 = add nuw nsw i64 %.116.1, 1
  %14 = mul nsw i64 %.01117.1, 10
  %15 = add nsw i64 %14, 2
  %16 = add nuw nsw i64 %.018.1, 1
  %17 = icmp ugt i64 %.018.1, 9
  %.not14.1 = icmp sgt i64 %15, %7
  %or.cond.1 = select i1 %17, i1 true, i1 %.not14.1
  br i1 %or.cond.1, label %._crit_edge.1, label %.lr.ph.1, !llvm.loop !9

._crit_edge.1:                                    ; preds = %.lr.ph.1
  %.not1415.2 = icmp slt i64 %7, 3
  br i1 %.not1415.2, label %._crit_edge.8, label %.lr.ph.2

.lr.ph.2:                                         ; preds = %._crit_edge.1, %.lr.ph.2
  %.018.2 = phi i64 [ %21, %.lr.ph.2 ], [ 1, %._crit_edge.1 ]
  %.01117.2 = phi i64 [ %20, %.lr.ph.2 ], [ 3, %._crit_edge.1 ]
  %.116.2 = phi i64 [ %18, %.lr.ph.2 ], [ %13, %._crit_edge.1 ]
  %18 = add nuw nsw i64 %.116.2, 1
  %19 = mul nsw i64 %.01117.2, 10
  %20 = add nsw i64 %19, 3
  %21 = add nuw nsw i64 %.018.2, 1
  %22 = icmp ugt i64 %.018.2, 9
  %.not14.2 = icmp sgt i64 %20, %7
  %or.cond.2 = select i1 %22, i1 true, i1 %.not14.2
  br i1 %or.cond.2, label %._crit_edge.2, label %.lr.ph.2, !llvm.loop !9

._crit_edge.2:                                    ; preds = %.lr.ph.2
  %.not1415.3 = icmp eq i64 %7, 3
  br i1 %.not1415.3, label %._crit_edge.8, label %.lr.ph.3

.lr.ph.3:                                         ; preds = %._crit_edge.2, %.lr.ph.3
  %.018.3 = phi i64 [ %26, %.lr.ph.3 ], [ 1, %._crit_edge.2 ]
  %.01117.3 = phi i64 [ %25, %.lr.ph.3 ], [ 4, %._crit_edge.2 ]
  %.116.3 = phi i64 [ %23, %.lr.ph.3 ], [ %18, %._crit_edge.2 ]
  %23 = add nuw nsw i64 %.116.3, 1
  %24 = mul nsw i64 %.01117.3, 10
  %25 = add nsw i64 %24, 4
  %26 = add nuw nsw i64 %.018.3, 1
  %27 = icmp ugt i64 %.018.3, 9
  %.not14.3 = icmp sgt i64 %25, %7
  %or.cond.3 = select i1 %27, i1 true, i1 %.not14.3
  br i1 %or.cond.3, label %._crit_edge.3, label %.lr.ph.3, !llvm.loop !9

._crit_edge.3:                                    ; preds = %.lr.ph.3
  %.not1415.4 = icmp slt i64 %7, 5
  br i1 %.not1415.4, label %._crit_edge.8, label %.lr.ph.4

.lr.ph.4:                                         ; preds = %._crit_edge.3, %.lr.ph.4
  %.018.4 = phi i64 [ %31, %.lr.ph.4 ], [ 1, %._crit_edge.3 ]
  %.01117.4 = phi i64 [ %30, %.lr.ph.4 ], [ 5, %._crit_edge.3 ]
  %.116.4 = phi i64 [ %28, %.lr.ph.4 ], [ %23, %._crit_edge.3 ]
  %28 = add nuw nsw i64 %.116.4, 1
  %29 = mul nsw i64 %.01117.4, 10
  %30 = add nsw i64 %29, 5
  %31 = add nuw nsw i64 %.018.4, 1
  %32 = icmp ugt i64 %.018.4, 9
  %.not14.4 = icmp sgt i64 %30, %7
  %or.cond.4 = select i1 %32, i1 true, i1 %.not14.4
  br i1 %or.cond.4, label %._crit_edge.4, label %.lr.ph.4, !llvm.loop !9

._crit_edge.4:                                    ; preds = %.lr.ph.4
  %.not1415.5 = icmp eq i64 %7, 5
  br i1 %.not1415.5, label %._crit_edge.8, label %.lr.ph.5

.lr.ph.5:                                         ; preds = %._crit_edge.4, %.lr.ph.5
  %.018.5 = phi i64 [ %36, %.lr.ph.5 ], [ 1, %._crit_edge.4 ]
  %.01117.5 = phi i64 [ %35, %.lr.ph.5 ], [ 6, %._crit_edge.4 ]
  %.116.5 = phi i64 [ %33, %.lr.ph.5 ], [ %28, %._crit_edge.4 ]
  %33 = add nuw nsw i64 %.116.5, 1
  %34 = mul nsw i64 %.01117.5, 10
  %35 = add nsw i64 %34, 6
  %36 = add nuw nsw i64 %.018.5, 1
  %37 = icmp ugt i64 %.018.5, 9
  %.not14.5 = icmp sgt i64 %35, %7
  %or.cond.5 = select i1 %37, i1 true, i1 %.not14.5
  br i1 %or.cond.5, label %._crit_edge.5, label %.lr.ph.5, !llvm.loop !9

._crit_edge.5:                                    ; preds = %.lr.ph.5
  %.not1415.6 = icmp slt i64 %7, 7
  br i1 %.not1415.6, label %._crit_edge.8, label %.lr.ph.6

.lr.ph.6:                                         ; preds = %._crit_edge.5, %.lr.ph.6
  %.018.6 = phi i64 [ %41, %.lr.ph.6 ], [ 1, %._crit_edge.5 ]
  %.01117.6 = phi i64 [ %40, %.lr.ph.6 ], [ 7, %._crit_edge.5 ]
  %.116.6 = phi i64 [ %38, %.lr.ph.6 ], [ %33, %._crit_edge.5 ]
  %38 = add nuw nsw i64 %.116.6, 1
  %39 = mul nsw i64 %.01117.6, 10
  %40 = add nsw i64 %39, 7
  %41 = add nuw nsw i64 %.018.6, 1
  %42 = icmp ugt i64 %.018.6, 9
  %.not14.6 = icmp sgt i64 %40, %7
  %or.cond.6 = select i1 %42, i1 true, i1 %.not14.6
  br i1 %or.cond.6, label %._crit_edge.6, label %.lr.ph.6, !llvm.loop !9

._crit_edge.6:                                    ; preds = %.lr.ph.6
  %.not1415.7 = icmp eq i64 %7, 7
  br i1 %.not1415.7, label %._crit_edge.8, label %.lr.ph.7

.lr.ph.7:                                         ; preds = %._crit_edge.6, %.lr.ph.7
  %.018.7 = phi i64 [ %46, %.lr.ph.7 ], [ 1, %._crit_edge.6 ]
  %.01117.7 = phi i64 [ %45, %.lr.ph.7 ], [ 8, %._crit_edge.6 ]
  %.116.7 = phi i64 [ %43, %.lr.ph.7 ], [ %38, %._crit_edge.6 ]
  %43 = add nuw nsw i64 %.116.7, 1
  %44 = mul nsw i64 %.01117.7, 10
  %45 = add nsw i64 %44, 8
  %46 = add nuw nsw i64 %.018.7, 1
  %47 = icmp ugt i64 %.018.7, 9
  %.not14.7 = icmp sgt i64 %45, %7
  %or.cond.7 = select i1 %47, i1 true, i1 %.not14.7
  br i1 %or.cond.7, label %._crit_edge.7, label %.lr.ph.7, !llvm.loop !9

._crit_edge.7:                                    ; preds = %.lr.ph.7
  %.not1415.8 = icmp slt i64 %7, 9
  br i1 %.not1415.8, label %._crit_edge.8, label %.lr.ph.8

.lr.ph.8:                                         ; preds = %._crit_edge.7, %.lr.ph.8
  %.018.8 = phi i64 [ %51, %.lr.ph.8 ], [ 1, %._crit_edge.7 ]
  %.01117.8 = phi i64 [ %50, %.lr.ph.8 ], [ 9, %._crit_edge.7 ]
  %.116.8 = phi i64 [ %48, %.lr.ph.8 ], [ %43, %._crit_edge.7 ]
  %48 = add nuw nsw i64 %.116.8, 1
  %49 = mul nsw i64 %.01117.8, 10
  %50 = add nsw i64 %49, 9
  %51 = add nuw nsw i64 %.018.8, 1
  %52 = icmp ugt i64 %.018.8, 9
  %.not14.8 = icmp sgt i64 %50, %7
  %or.cond.8 = select i1 %52, i1 true, i1 %.not14.8
  br i1 %or.cond.8, label %._crit_edge.8, label %.lr.ph.8, !llvm.loop !9

._crit_edge.8:                                    ; preds = %.lr.ph.8, %.lr.ph23, %._crit_edge, %._crit_edge.1, %._crit_edge.2, %._crit_edge.3, %._crit_edge.4, %._crit_edge.5, %._crit_edge.6, %._crit_edge.7
  %.1.lcssa.8 = phi i64 [ %43, %._crit_edge.7 ], [ %38, %._crit_edge.6 ], [ %33, %._crit_edge.5 ], [ %28, %._crit_edge.4 ], [ %23, %._crit_edge.3 ], [ %18, %._crit_edge.2 ], [ %13, %._crit_edge.1 ], [ %8, %._crit_edge ], [ 0, %.lr.ph23 ], [ %48, %.lr.ph.8 ]
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.1.lcssa.8)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  %54 = load i64, ptr %1, align 8, !tbaa !5
  %55 = add nsw i64 %54, -1
  store i64 %55, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %54, 0
  br i1 %.not, label %._crit_edge24, label %.lr.ph23, !llvm.loop !11

._crit_edge24:                                    ; preds = %._crit_edge.8, %0
  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: 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

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 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: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass