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

; 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
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@c = external dso_local global [200001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = 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
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %9

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

13:                                               ; preds = %9
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  store i32 0, ptr @m, align 4, !tbaa !5
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = mul i64 %16, 4
  call void @llvm.memset.p0.i64(ptr align 4 getelementptr inbounds (i32, ptr @c, i64 1), i8 0, i64 %17, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %39, %13
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @n, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [200001 x i32], ptr @c, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = icmp ne i32 %28, 0
  %30 = xor i1 %29, true
  %31 = zext i1 %30 to i32
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %33 = add nsw i32 %32, %31
  store i32 %33, ptr @m, align 4, !tbaa !5
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [200001 x i32], ptr @c, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %36, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %39

39:                                               ; preds = %23
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !9

42:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %72, %42
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = load i32, ptr @n, align 4, !tbaa !5
  %46 = icmp sle i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %75

48:                                               ; preds = %43
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [200001 x i32], ptr @c, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %55, label %54

54:                                               ; preds = %48
  br label %72

55:                                               ; preds = %48
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [200001 x i32], ptr @c, i64 0, i64 %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %59 = load i32, ptr @m, align 4, !tbaa !5
  %60 = sub nsw i32 %59, 1
  store i32 %60, ptr %6, align 4, !tbaa !5
  %61 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %58, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %62 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %61)
  %63 = load i32, ptr %62, align 4, !tbaa !5
  store i32 %63, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [200001 x i32], ptr @c, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = sub nsw i32 %67, 1
  store i32 %68, ptr %7, align 4, !tbaa !5
  %69 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %70 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %69)
  %71 = load i32, ptr %70, align 4, !tbaa !5
  store i32 %71, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %72

72:                                               ; preds = %55, %54
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %5, align 4, !tbaa !5
  br label %43, !llvm.loop !11

75:                                               ; preds = %47
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %76)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %9, !llvm.loop !12

78:                                               ; preds = %9
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

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 nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress 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 #5 = { 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 = 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"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@c = external dso_local global [200001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

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

.lr.ph19:                                         ; preds = %0, %._crit_edge16
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  store i32 0, ptr @m, align 4, !tbaa !5
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = shl nsw i64 %10, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @c, i64 4), i8 0, i64 %11, i1 false)
  %12 = icmp sgt i32 %9, 0
  br i1 %12, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %.lr.ph19
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %._crit_edge16

._crit_edge:                                      ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  %.not812 = icmp slt i32 %23, 1
  br i1 %.not812, label %._crit_edge16, label %.lr.ph15

.lr.ph:                                           ; preds = %.lr.ph19, %.lr.ph
  %.0711 = phi i32 [ %22, %.lr.ph ], [ 0, %.lr.ph19 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [200001 x i32], ptr @c, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %.not10 = icmp eq i32 %17, 0
  %18 = zext i1 %.not10 to i32
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = add nsw i32 %19, %18
  store i32 %20, ptr @m, align 4, !tbaa !5
  %21 = add nsw i32 %17, 1
  store i32 %21, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %22 = add nuw nsw i32 %.0711, 1
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge16:                                    ; preds = %44, %._crit_edge.thread, %._crit_edge
  %25 = phi i32 [ 0, %._crit_edge ], [ 0, %._crit_edge.thread ], [ %45, %44 ]
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %25)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %27 = load i32, ptr @t, align 4, !tbaa !5
  %28 = add nsw i32 %27, -1
  store i32 %28, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %27, 0
  br i1 %.not, label %._crit_edge20, label %.lr.ph19, !llvm.loop !11

.lr.ph15:                                         ; preds = %._crit_edge, %44
  %29 = phi i32 [ %45, %44 ], [ 0, %._crit_edge ]
  %30 = phi i32 [ %46, %44 ], [ %23, %._crit_edge ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %44 ], [ 1, %._crit_edge ]
  %31 = getelementptr inbounds [200001 x i32], ptr @c, i64 0, i64 %indvars.iv
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %.not9 = icmp eq i32 %32, 0
  br i1 %.not9, label %44, label %33

33:                                               ; preds = %.lr.ph15
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %34 = load i32, ptr @m, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %3, align 4, !tbaa !5
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %31, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %36)
  %38 = load i32, ptr %37, align 4, !tbaa !5
  store i32 %38, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %39 = load i32, ptr %31, align 4, !tbaa !5
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr %4, align 4, !tbaa !5
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %41)
  %43 = load i32, ptr %42, align 4, !tbaa !5
  store i32 %43, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %.lr.ph15, %33
  %45 = phi i32 [ %29, %.lr.ph15 ], [ %43, %33 ]
  %46 = phi i32 [ %30, %.lr.ph15 ], [ %.pre, %33 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %47 = sext i32 %46 to i64
  %.not8.not = icmp slt i64 %indvars.iv, %47
  br i1 %.not8.not, label %.lr.ph15, label %._crit_edge16, !llvm.loop !12

._crit_edge20:                                    ; preds = %._crit_edge16, %0
  ret i32 0
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

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

attributes #0 = { mustprogress 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" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress 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 #5 = { 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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