#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ tty_getchar();
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr,
            "Usage: %s $FileName\nWhere $FileName is the name of the paper "
            "tape of the program being run\n",
            argv[0]);
    return EXIT_FAILURE;
  }
  FILE *source_file = fopen(argv[1], "r");
  int c = fgetc(source_file);
  int count = 10;
  while (EOF != c) {
    fprintf(stdout, "%c", c);
    if (10 == c) {
      count = count - 1;
    }
    if (0 == count) {
      tty_getchar();
      count = 10;
    }
    c = fgetc(source_file);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119d <main+0x4d>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
movl   $0xa,-0x20(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
cmp    -0x1c(%rbp),%eax
je     1235 <main+0xe5>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0xa,%eax
cmp    -0x1c(%rbp),%eax
jne    120b <main+0xbb>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%eax
jne    1224 <main+0xd4>
mov    $0x0,%al
call   1050 <tty_getchar@plt>
movl   $0xa,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
jmp    11c8 <main+0x78>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1192 <main+0x42>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe8d(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsi),%rdi
lea    0xebf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1030 <fgetc@plt>
mov    0x2e34(%rip),%r15
cmp    %eax,(%r15)
jne    11c7 <main+0x77>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    %eax,%ebp
mov    $0xa,%ebx
mov    0x2df3(%rip),%r12
lea    0xe82(%rip),%r14
jmp    11ef <main+0x9f>
xchg   %ax,%ax
mov    %r13,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
cmp    %eax,(%r15)
je     11b9 <main+0x69>
mov    (%r12),%edi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
cmp    $0xa,%ebp
sete   %al
sub    %eax,%ebx
jne    11e0 <main+0x90>
xor    %eax,%eax
call   1050 <tty_getchar@plt>
mov    $0xa,%ebx
jmp    11e0 <main+0x90>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [92 x i8] c"Usage: %s $FileName\0AWhere $FileName is the name of the paper tape of the program being run\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
@stdout = global i32 0
@.str.2 = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%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 slt i32 %9, 2
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
ret i32 %17
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = call i32 @fgetc(i32* %23)
store i32 %24, i32* %7
store i32 10, i32* %8
br label %25
25: ; preds = %43, %18
%26 = load i32, i32* @EOF
%27 = load i32, i32* %7
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %46
29: ; preds = %25
%30 = load i32, i32* @stdout
%31 = load i32, i32* %7
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %7
%34 = icmp eq i32 10, %33
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = load i32, i32* %8
%37 = sub nsw i32 %36, 1
store i32 %37, i32* %8
br label %38
38: ; preds = %35, %29
%39 = load i32, i32* %8
%40 = icmp eq i32 0, %39
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 (...) @tty_getchar()
store i32 10, i32* %8
br label %43
43: ; preds = %41, %38
%44 = load i32*, i32** %6
%45 = call i32 @fgetc(i32* %44)
store i32 %45, i32* %7
br label %25
46: ; preds = %25
%47 = load i32, i32* @EXIT_SUCCESS
%48 = call i32 @exit(i32 %47)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [92 x i8] c"Usage: %s $FileName\0AWhere $FileName is the name of the paper tape of the program being run\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
@stdout = global i32 0
@.str.2 = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
ret i32 %8
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @fgetc(i32* %12)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %14, %13
br i1 %15, label %32, label %16
16: ; preds = %9, %27
%17 = phi i32 [ %28, %27 ], [ 10, %9 ]
%18 = phi i32 [ %29, %27 ], [ %13, %9 ]
%19 = load i32, i32* @stdout
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%21 = icmp eq i32 %18, 10
%22 = sext i1 %21 to i32
%23 = add nsw i32 %17, %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %16
%26 = tail call i32 (...) @tty_getchar()
br label %27
27: ; preds = %25, %16
%28 = phi i32 [ 10, %25 ], [ %23, %16 ]
%29 = tail call i32 @fgetc(i32* %12)
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %30, %29
br i1 %31, label %32, label %16
32: ; preds = %27, %9
%33 = load i32, i32* @EXIT_SUCCESS
%34 = tail call i32 @exit(i32 %33)
unreachable
}