#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 */
char EOF;
int /*<<< orphan*/ eval_command(char *, int);
char getchar();
int /*<<< orphan*/ printf(char *);
int main() {
  char c;
  char line[256];
  int i = 0;
  while (1) {
    c = getchar();
    if (c == '\n') {
      eval_command(line, i);
      i = 0;
    } else {
      if (c == EOF) {
        printf("\n");
        eval_command(line, i);
        break;
      }
      line[i++] = c;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x114(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    1184 <main+0x54>
lea    -0x110(%rbp),%rdi
mov    -0x114(%rbp),%esi
call   1040 <eval_command@plt>
movl   $0x0,-0x114(%rbp)
jmp    11da <main+0xaa>
movsbl -0x5(%rbp),%eax
mov    0x2e59(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11bd <main+0x8d>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x114(%rbp),%esi
call   1040 <eval_command@plt>
jmp    11df <main+0xaf>
mov    -0x5(%rbp),%cl
mov    -0x114(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x114(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
jmp    114c <main+0x1c>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsp,%r14
mov    0x2ea2(%rip),%r15
jmp    115a <main+0x2a>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <eval_command@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1150 <main+0x20>
cmp    (%r15),%al
je     1177 <main+0x47>
movslq %ebx,%rcx
add    $0x1,%ebx
mov    %al,(%rsp,%rcx,1)
jmp    115c <main+0x2c>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rsp,%rdi
mov    %ebx,%esi
call   1040 <eval_command@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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