; LLVM IR from tangjz/acm-icpc :: codeforces/complete (1335D)

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

@t = external dso_local global i32, align 4
@buf = external dso_local global [9 x [11 x i8]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %10

10:                                               ; preds = %85, %0
  %11 = load i32, ptr @t, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @t, align 4, !tbaa !5
  %13 = icmp ne i32 %11, 0
  br i1 %13, label %14, label %86

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

15:                                               ; preds = %25, %14
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 9
  br i1 %17, label %19, label %18

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

19:                                               ; preds = %15
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [9 x [11 x i8]], ptr @buf, i64 0, i64 %21
  %23 = getelementptr inbounds [11 x i8], ptr %22, i64 0, i64 0
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %23)
  br label %25

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

28:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %68, %28
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = icmp slt i32 %30, 3
  br i1 %31, label %33, label %32

32:                                               ; preds = %29
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %71

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %64, %33
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 3
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %67

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = mul nsw i32 %39, 3
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = add nsw i32 %40, %41
  store i32 %42, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = mul nsw i32 %43, 3
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = add nsw i32 %44, %45
  store i32 %46, ptr %7, align 4, !tbaa !5
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [9 x [11 x i8]], ptr @buf, i64 0, i64 %48
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [11 x i8], ptr %49, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 49
  %56 = zext i1 %55 to i64
  %57 = select i1 %55, i8 50, i8 49
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [9 x [11 x i8]], ptr @buf, i64 0, i64 %59
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [11 x i8], ptr %60, i64 0, i64 %62
  store i8 %57, ptr %63, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %64

64:                                               ; preds = %38
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %5, align 4, !tbaa !5
  br label %34, !llvm.loop !12

67:                                               ; preds = %37
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !13

71:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %82, %71
  %73 = load i32, ptr %8, align 4, !tbaa !5
  %74 = icmp slt i32 %73, 9
  br i1 %74, label %76, label %75

75:                                               ; preds = %72
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %85

76:                                               ; preds = %72
  %77 = load i32, ptr %8, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [9 x [11 x i8]], ptr @buf, i64 0, i64 %78
  %80 = getelementptr inbounds [11 x i8], ptr %79, i64 0, i64 0
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %80)
  br label %82

82:                                               ; preds = %76
  %83 = load i32, ptr %8, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %8, align 4, !tbaa !5
  br label %72, !llvm.loop !14

85:                                               ; preds = %75
  br label %10, !llvm.loop !15

86:                                               ; preds = %10
  ret i32 0
}

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

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

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

declare i32 @printf(ptr noundef, ...) #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!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"

@t = external dso_local global i32, align 4
@buf = external dso_local global [9 x [11 x i8]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not28 = icmp eq i32 %2, 0
  br i1 %.not28, label %._crit_edge, label %.preheader23

.preheader23:                                     ; preds = %0, %.preheader23
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @buf)
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 11))
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 22))
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 33))
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 44))
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 55))
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 66))
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 77))
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 88))
  %13 = load i8, ptr @buf, align 16, !tbaa !9
  %14 = icmp eq i8 %13, 49
  %15 = select i1 %14, i8 50, i8 49
  store i8 %15, ptr @buf, align 16, !tbaa !9
  %16 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 14), align 2, !tbaa !9
  %17 = icmp eq i8 %16, 49
  %18 = select i1 %17, i8 50, i8 49
  store i8 %18, ptr getelementptr inbounds (i8, ptr @buf, i64 14), align 2, !tbaa !9
  %19 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 28), align 4, !tbaa !9
  %20 = icmp eq i8 %19, 49
  %21 = select i1 %20, i8 50, i8 49
  store i8 %21, ptr getelementptr inbounds (i8, ptr @buf, i64 28), align 4, !tbaa !9
  %22 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 34), align 2, !tbaa !9
  %23 = icmp eq i8 %22, 49
  %24 = select i1 %23, i8 50, i8 49
  store i8 %24, ptr getelementptr inbounds (i8, ptr @buf, i64 34), align 2, !tbaa !9
  %25 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 48), align 16, !tbaa !9
  %26 = icmp eq i8 %25, 49
  %27 = select i1 %26, i8 50, i8 49
  store i8 %27, ptr getelementptr inbounds (i8, ptr @buf, i64 48), align 16, !tbaa !9
  %28 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 62), align 2, !tbaa !9
  %29 = icmp eq i8 %28, 49
  %30 = select i1 %29, i8 50, i8 49
  store i8 %30, ptr getelementptr inbounds (i8, ptr @buf, i64 62), align 2, !tbaa !9
  %31 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 68), align 4, !tbaa !9
  %32 = icmp eq i8 %31, 49
  %33 = select i1 %32, i8 50, i8 49
  store i8 %33, ptr getelementptr inbounds (i8, ptr @buf, i64 68), align 4, !tbaa !9
  %34 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 82), align 2, !tbaa !9
  %35 = icmp eq i8 %34, 49
  %36 = select i1 %35, i8 50, i8 49
  store i8 %36, ptr getelementptr inbounds (i8, ptr @buf, i64 82), align 2, !tbaa !9
  %37 = load i8, ptr getelementptr inbounds (i8, ptr @buf, i64 96), align 16, !tbaa !9
  %38 = icmp eq i8 %37, 49
  %39 = select i1 %38, i8 50, i8 49
  store i8 %39, ptr getelementptr inbounds (i8, ptr @buf, i64 96), align 16, !tbaa !9
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull @buf)
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 11))
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 22))
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 33))
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 44))
  %45 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 55))
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 66))
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 77))
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull getelementptr inbounds (i8, ptr @buf, i64 88))
  %49 = load i32, ptr @t, align 4, !tbaa !5
  %50 = add nsw i32 %49, -1
  store i32 %50, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %49, 0
  br i1 %.not, label %._crit_edge, label %.preheader23, !llvm.loop !10

._crit_edge:                                      ; preds = %.preheader23, %0
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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" }

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


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