; LLVM IR from tangjz/acm-icpc :: uvalive (7561)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solvev() #0

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

3:                                                ; preds = %43, %0
  %4 = load i32, ptr @t, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @t, align 4, !tbaa !5
  %6 = icmp ne i32 %4, 0
  br i1 %6, label %7, label %45

7:                                                ; preds = %3
  store i32 0, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 3), align 4, !tbaa !5
  store i32 0, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 2), align 8, !tbaa !5
  store i32 0, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 1), align 4, !tbaa !5
  store i32 0, ptr @c, align 16, !tbaa !5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.5, ptr noundef @n)
  br label %9

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

13:                                               ; preds = %9
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef @str)
  %15 = load ptr, ptr @buf, align 16, !tbaa !9
  %16 = call i32 @strcmp(ptr noundef @str, ptr noundef %15) #5
  %17 = icmp ne i32 %16, 0
  %18 = xor i1 %17, true
  %19 = zext i1 %18 to i32
  %20 = load i32, ptr @c, align 16, !tbaa !5
  %21 = add nsw i32 %20, %19
  store i32 %21, ptr @c, align 16, !tbaa !5
  %22 = load ptr, ptr getelementptr inbounds ([4 x ptr], ptr @buf, i64 0, i64 1), align 8, !tbaa !9
  %23 = call i32 @strcmp(ptr noundef @str, ptr noundef %22) #5
  %24 = icmp ne i32 %23, 0
  %25 = xor i1 %24, true
  %26 = zext i1 %25 to i32
  %27 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 1), align 4, !tbaa !5
  %28 = add nsw i32 %27, %26
  store i32 %28, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 1), align 4, !tbaa !5
  %29 = load ptr, ptr getelementptr inbounds ([4 x ptr], ptr @buf, i64 0, i64 2), align 16, !tbaa !9
  %30 = call i32 @strcmp(ptr noundef @str, ptr noundef %29) #5
  %31 = icmp ne i32 %30, 0
  %32 = xor i1 %31, true
  %33 = zext i1 %32 to i32
  %34 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 2), align 8, !tbaa !5
  %35 = add nsw i32 %34, %33
  store i32 %35, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 2), align 8, !tbaa !5
  %36 = load ptr, ptr getelementptr inbounds ([4 x ptr], ptr @buf, i64 0, i64 3), align 8, !tbaa !9
  %37 = call i32 @strcmp(ptr noundef @str, ptr noundef %36) #5
  %38 = icmp ne i32 %37, 0
  %39 = xor i1 %38, true
  %40 = zext i1 %39 to i32
  %41 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 3), align 4, !tbaa !5
  %42 = add nsw i32 %41, %40
  store i32 %42, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 3), align 4, !tbaa !5
  br label %9, !llvm.loop !11

43:                                               ; preds = %9
  call void @_Z5solvev()
  %44 = call i32 @putchar(i32 noundef 10)
  br label %3, !llvm.loop !13

45:                                               ; preds = %3
  ret i32 0
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #4

attributes #0 = { mustprogress 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 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 #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 willreturn memory(read) "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 = { inlinehint mustprogress 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 willreturn memory(read) }

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


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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5solvev() local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, 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
  %.not7 = icmp eq i32 %2, 0
  br i1 %.not7, label %._crit_edge10, label %.lr.ph9

.lr.ph9:                                          ; preds = %0, %._crit_edge
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) @c, i8 0, i64 16, i1 false)
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef nonnull @n)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr @n, align 4, !tbaa !5
  %.not16 = icmp eq i32 %5, 0
  br i1 %.not16, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph9, %.lr.ph
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull @str)
  %8 = load ptr, ptr @buf, align 16, !tbaa !9
  %9 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @str, ptr noundef nonnull dereferenceable(1) %8) #6
  %.not2 = icmp eq i32 %9, 0
  %10 = zext i1 %.not2 to i32
  %11 = load i32, ptr @c, align 16, !tbaa !5
  %12 = add nsw i32 %11, %10
  store i32 %12, ptr @c, align 16, !tbaa !5
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @buf, i64 8), align 8, !tbaa !9
  %14 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @str, ptr noundef nonnull dereferenceable(1) %13) #6
  %.not3 = icmp eq i32 %14, 0
  %15 = zext i1 %.not3 to i32
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @c, i64 4), align 4, !tbaa !5
  %17 = add nsw i32 %16, %15
  store i32 %17, ptr getelementptr inbounds (i8, ptr @c, i64 4), align 4, !tbaa !5
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @buf, i64 16), align 16, !tbaa !9
  %19 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @str, ptr noundef nonnull dereferenceable(1) %18) #6
  %.not4 = icmp eq i32 %19, 0
  %20 = zext i1 %.not4 to i32
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @c, i64 8), align 8, !tbaa !5
  %22 = add nsw i32 %21, %20
  store i32 %22, ptr getelementptr inbounds (i8, ptr @c, i64 8), align 8, !tbaa !5
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @buf, i64 24), align 8, !tbaa !9
  %24 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) @str, ptr noundef nonnull dereferenceable(1) %23) #6
  %.not5 = icmp eq i32 %24, 0
  %25 = zext i1 %.not5 to i32
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @c, i64 12), align 4, !tbaa !5
  %27 = add nsw i32 %26, %25
  store i32 %27, ptr getelementptr inbounds (i8, ptr @c, i64 12), align 4, !tbaa !5
  %28 = load i32, ptr @n, align 4, !tbaa !5
  %29 = add nsw i32 %28, -1
  store i32 %29, ptr @n, align 4, !tbaa !5
  %.not1 = icmp eq i32 %28, 0
  br i1 %.not1, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph9
  tail call void @_Z5solvev()
  %30 = tail call i32 @putchar(i32 noundef 10)
  %31 = load i32, ptr @t, align 4, !tbaa !5
  %32 = add nsw i32 %31, -1
  store i32 %32, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %._crit_edge10, label %.lr.ph9, !llvm.loop !13

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #4

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

attributes #0 = { mustprogress 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 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 #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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { inlinehint mustprogress nofree 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind willreturn memory(read) }

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


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass