#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 /*<<< orphan*/ Print(int, int);
int /*<<< orphan*/ close(int /*<<< orphan*/);
int dup(int /*<<< orphan*/);
char getc();
int /*<<< orphan*/ gettty(char *);
int open(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putc(char);
int main(int argc, char *argv[]) {
  char c, tty[64];
  int fd;
  if (argc == 1) {
    fd = dup(0);
    close(0);
    gettty(tty);
    open(tty, 00);
  } else {
    fd = open(argv[1], 00);
  }
  if (fd < 0) {
    printf("More couldn't find the asked for file.\n");
    return -1;
  }
  while (1) {
    Print(fd, 20);
    while (1) {
      c = getc();
      switch (c) {
      case '\r':
      case '\n':
        Print(fd, 1);
        break;
      case ' ':
        Print(fd, 20);
        break;
      case 'q':
        putc('\n');
        return 0;
        break;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11ca <main+0x4a>
xor    %edi,%edi
call   1040 <dup@plt>
mov    %eax,-0x64(%rbp)
xor    %edi,%edi
call   1050 <close@plt>
lea    -0x60(%rbp),%rdi
call   1070 <gettty@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
call   1080 <open@plt>
jmp    11dc <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %esi,%esi
call   1080 <open@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    11fe <main+0x7e>
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a1 <main+0x121>
jmp    1203 <main+0x83>
mov    -0x64(%rbp),%edi
mov    $0x14,%esi
call   1090 <Print@plt>
xor    %eax,%eax
call   10a0 <getc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x68(%rbp)
sub    $0xa,%eax
je     1262 <main+0xe2>
jmp    122f <main+0xaf>
mov    -0x68(%rbp),%eax
sub    $0xd,%eax
je     1262 <main+0xe2>
jmp    1240 <main+0xc0>
mov    -0x68(%rbp),%eax
sub    $0x20,%eax
je     1274 <main+0xf4>
jmp    1251 <main+0xd1>
mov    -0x68(%rbp),%eax
sub    $0x71,%eax
je     1286 <main+0x106>
jmp    129c <main+0x11c>
mov    -0x64(%rbp),%edi
mov    $0x1,%esi
call   1090 <Print@plt>
jmp    129c <main+0x11c>
mov    -0x64(%rbp),%edi
mov    $0x14,%esi
call   1090 <Print@plt>
jmp    129c <main+0x11c>
mov    $0xa,%edi
call   1060 <putc@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a1 <main+0x121>
jmp    1210 <main+0x90>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
cmp    $0x1,%edi
jne    1215 <main+0x95>
xor    %edi,%edi
call   1040 <dup@plt>
mov    %eax,%ebx
xor    %edi,%edi
call   1050 <close@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1070 <gettty@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1080 <open@plt>
test   %ebx,%ebx
js     1226 <main+0xa6>
mov    $0x14,%esi
mov    %ebx,%edi
call   1090 <Print@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10a0 <getc@plt>
movsbl %al,%eax
cmp    $0x1f,%eax
jg     11f0 <main+0x70>
cmp    $0xa,%eax
je     1200 <main+0x80>
cmp    $0xd,%eax
jne    11d0 <main+0x50>
jmp    1200 <main+0x80>
nopl   0x0(%rax,%rax,1)
cmp    $0x71,%eax
je     1207 <main+0x87>
cmp    $0x20,%eax
jne    11d0 <main+0x50>
jmp    11b9 <main+0x39>
nopl   0x0(%rax)
mov    $0x1,%esi
jmp    11be <main+0x3e>
mov    $0xa,%edi
call   1060 <putc@plt>
xor    %eax,%eax
jmp    1237 <main+0xb7>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
call   1080 <open@plt>
mov    %eax,%ebx
test   %ebx,%ebx
jns    11b9 <main+0x39>
lea    0xdd3(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [40 x i8] c"More couldn't find the asked for file.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca [64 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = call i32 @dup(i32 0)
store i32 %12, i32* %8
%13 = call i32 @close(i32 0)
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%15 = call i32 @gettty(i8* %14)
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%17 = call i32 @open(i8* %16, i32 0)
br label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @open(i8* %21, i32 0)
store i32 %22, i32* %8
br label %23
23: ; preds = %18, %11
%24 = load i32, i32* %8
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %45
28: ; preds = %23
br label %29
29: ; preds = %28
%30 = load i32, i32* %8
%31 = call i32 @Print(i32 %30, i32 20)
br label %32
32: ; preds = %29, %44
%33 = call signext i8 (...) @getc()
store i8 %33, i8* %6
%34 = load i8, i8* %6
%35 = sext i8 %34 to i32
switch i32 %35, label %44 [
i32 13, label %36
i32 10, label %36
i32 32, label %39
i32 113, label %42
]
36: ; preds = %32, %32
%37 = load i32, i32* %8
%38 = call i32 @Print(i32 %37, i32 1)
br label %44
39: ; preds = %32
%40 = load i32, i32* %8
%41 = call i32 @Print(i32 %40, i32 20)
br label %44
42: ; preds = %32
%43 = call i32 @putc(i8 signext 10)
store i32 0, i32* %3
br label %45
44: ; preds = %32, %39, %36
br label %32
45: ; preds = %42, %26
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@str = [39 x i8] c"More couldn't find the asked for file.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = tail call i32 @dup(i32 0)
%8 = tail call i32 @close(i32 0)
%9 = call i32 @gettty(i8* %4)
%10 = call i32 @open(i8* %4, i32 0)
br label %15
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @open(i8* %13, i32 0)
br label %15
15: ; preds = %11, %6
%16 = phi i32 [ %7, %6 ], [ %14, %11 ]
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %31
20: ; preds = %15, %27
%21 = phi i32 [ %28, %27 ], [ 20, %15 ]
%22 = call i32 @Print(i32 %16, i32 %21)
br label %23
23: ; preds = %20, %23
%24 = call signext i8 (...) @getc()
%25 = sext i8 %24 to i32
switch i32 %25, label %23 [
i32 13, label %27
i32 10, label %27
i32 32, label %26
i32 113, label %29
]
26: ; preds = %23
br label %27
27: ; preds = %23, %23, %26
%28 = phi i32 [ 20, %26 ], [ 1, %23 ], [ 1, %23 ]
br label %20
29: ; preds = %23
%30 = call i32 @putc(i8 signext 10)
br label %31
31: ; preds = %29, %18
%32 = phi i32 [ -1, %18 ], [ 0, %29 ]
ret i32 %32
}