#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int, int, char *);
scalar_t__ scanf(char *, char *);
int main() {
  char buf[20];
  int c = 0, r = 0;
  while (scanf("%s", buf) != EOF) {
    printf("%d %d %s\n", c, r, buf);
    if (!(c = (c + 1) % 4000))
      r++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xeb8(%rip),%rdi
call   1040 <scanf@plt>
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%rax
je     119b <main+0x7b>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    -0x20(%rbp),%rcx
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    $0xfa0,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
cmp    $0x0,%edx
jne    1196 <main+0x76>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    0x2ea4(%rip),%r13
cmp    0x0(%r13),%rax
je     11a9 <main+0x89>
xor    %ebp,%ebp
lea    0xeb0(%rip),%r14
mov    %rsp,%r15
lea    0xea3(%rip),%r12
xor    %ebx,%ebx
nop
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15,%rcx
call   1030 <printf@plt>
add    $0x1,%ebx
movslq %ebx,%rbx
imul   $0x10624dd3,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x28,%rax
add    %ecx,%eax
imul   $0xfa0,%eax,%eax
xor    %ecx,%ecx
sub    %eax,%ebx
sete   %cl
add    %ecx,%ebp
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
cmp    0x0(%r13),%rax
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c"%d %d %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %22, %0
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i64, i64* @EOF
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %23
10: ; preds = %5
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12, i8* %13)
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
%17 = srem i32 %16, 4000
store i32 %17, i32* %3
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %10
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %22
22: ; preds = %19, %10
br label %5
23: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c"%d %d %s\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %18, label %6
6: ; preds = %0, %6
%7 = phi i32 [ %14, %6 ], [ 0, %0 ]
%8 = phi i32 [ %11, %6 ], [ 0, %0 ]
%9 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %7, i8* %2)
%10 = add nsw i32 %8, 1
%11 = srem i32 %10, 4000
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = add nuw nsw i32 %7, %13
%15 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%16 = load i64, i64* @EOF
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %6
18: ; preds = %6, %0
ret i32 0
}