#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 */
int EOF;
int getchar();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(int);
int main() {
  int c;
  int new_line = 1;
  int number = 0;
  while ((c = getchar()) != EOF) {
    if (new_line == 1) {
      printf("%-5d ", ++number);
      new_line = 0;
    }
    putchar(c);
    if (c == '\n')
      new_line = 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     11aa <main+0x7a>
cmpl   $0x1,-0xc(%rbp)
jne    118c <main+0x5c>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
cmpl   $0xa,-0x8(%rbp)
jne    11a5 <main+0x75>
movl   $0x1,-0xc(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea2(%rip),%r15
cmp    (%r15),%eax
jne    1156 <main+0x26>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    $0x1,%ebx
lea    0xe9c(%rip),%r14
xor    %r12d,%r12d
jmp    118d <main+0x5d>
nopl   0x0(%rax)
mov    %ebp,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
cmp    $0xa,%ebp
sete   %bl
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     114b <main+0x1b>
cmp    $0x1,%ebx
jne    1170 <main+0x40>
add    $0x1,%r12d
mov    %r14,%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
jmp    1170 <main+0x40>

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

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