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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e7a(%rip),%rcx
cmp    (%rcx),%eax
je     11a4 <main+0x74>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
cmpl   $0xa,-0x8(%rbp)
jne    119f <main+0x6f>
mov    -0xc(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
jmp    115d <main+0x2d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e92(%rip),%r15
cmp    (%r15),%eax
jne    1168 <main+0x38>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    $0x2,%ebx
lea    0xe8a(%rip),%r14
jmp    118e <main+0x5e>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     115b <main+0x2b>
mov    %ebp,%edi
call   1030 <putchar@plt>
cmp    $0xa,%ebp
jne    1180 <main+0x50>
lea    0x1(%rbx),%ebp
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %ebp,%ebx
jmp    1180 <main+0x50>

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

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