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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x8(%rbp)
xor    %eax,%eax
mov    0x2e8d(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xd(%rbp)
je     1170 <main+0x40>
cmpl   $0xa,-0x8(%rbp)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1180 <main+0x50>
jmp    119f <main+0x6f>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
jmp    1146 <main+0x16>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
je     1180 <main+0x50>
mov    0x2ea0(%rip),%r15
cmp    (%r15),%eax
je     1180 <main+0x50>
mov    $0x1,%ebx
lea    0xea7(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
je     1180 <main+0x50>
add    $0x1,%ebx
cmp    (%r15),%eax
jne    1160 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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