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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0xa,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     119a <main+0x6a>
cmpl   $0xa,-0xc(%rbp)
jne    1187 <main+0x57>
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-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    $0xa,%ebp
mov    $0x1,%r12d
lea    0xe98(%rip),%r14
jmp    1183 <main+0x53>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r15),%eax
je     114b <main+0x1b>
mov    %ebp,%ecx
mov    %eax,%ebp
cmp    $0xa,%ecx
jne    1170 <main+0x40>
lea    0x1(%r12),%ebx
mov    %r14,%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
mov    %ebx,%r12d
jmp    1170 <main+0x40>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"%3d \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* %4
store i32 10, i32* %3
br label %5
5: ; preds = %16, %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 %20
9: ; preds = %5
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 10
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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %16
16: ; preds = %12, %9
%17 = load i32, i32* %2
%18 = call i32 @putchar(i32 %17)
%19 = load i32, i32* %2
store i32 %19, i32* %3
br label %5
20: ; preds = %5
ret i32 0
}

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