#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 /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ *my_open(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  FILE *stack[256];
  int sp;
  char line[4096];
  char *directory;
  sp = 0;
  if (argc < 3) {
    fprintf(stderr, "Usage: %s directory root texi file\n", argv[0]);
    exit(1);
  }
  directory = argv[1];
  stack[sp++] = my_open(directory, argv[2]);
  while (sp) {
    if (fgets(line, 4095, stack[sp - 1])) {
      line[strlen(line) - 1] = '\0';
      if (!strncmp(line, "@input", 6)) {
        stack[sp++] = my_open(directory, line + 7);
        continue;
      }
      if (!strncmp(line, "@include", 8)) {
        stack[sp++] = my_open(directory, line + 9);
        continue;
      }
      puts(line);
    } else
      sp--;
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x814(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11c3 <main+0x53>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4c(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x1828(%rbp)
mov    -0x1828(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1070 <my_open@plt>
mov    %rax,%rcx
mov    -0x814(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x814(%rbp)
cltq
mov    %rcx,-0x810(%rbp,%rax,8)
ff
cmpl   $0x0,-0x814(%rbp)
je     1333 <main+0x1c3>
lea    -0x1820(%rbp),%rdi
mov    -0x814(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x810(%rbp,%rax,8),%rdx
ff
mov    $0xfff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     131f <main+0x1af>
lea    -0x1820(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x1820(%rbp,%rax,1)
lea    -0x1820(%rbp),%rdi
lea    0xdbe(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12b3 <main+0x143>
mov    -0x1828(%rbp),%rdi
lea    -0x1820(%rbp),%rsi
add    $0x7,%rsi
call   1070 <my_open@plt>
mov    %rax,%rcx
mov    -0x814(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x814(%rbp)
cltq
mov    %rcx,-0x810(%rbp,%rax,8)
ff
jmp    1204 <main+0x94>
lea    -0x1820(%rbp),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    130e <main+0x19e>
mov    -0x1828(%rbp),%rdi
lea    -0x1820(%rbp),%rsi
add    $0x9,%rsi
call   1070 <my_open@plt>
mov    %rax,%rcx
mov    -0x814(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x814(%rbp)
cltq
mov    %rcx,-0x810(%rbp,%rax,8)
ff
jmp    1204 <main+0x94>
lea    -0x1820(%rbp),%rdi
call   1040 <puts@plt>
jmp    132e <main+0x1be>
mov    -0x814(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x814(%rbp)
jmp    1204 <main+0x94>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1818,%rsp
cmp    $0x2,%edi
jg     11a8 <main+0x38>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe67(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
mov    %rdi,0x8(%rsp)
call   1070 <my_open@plt>
mov    %rax,0x10(%rsp)
mov    $0x1,%ebp
lea    0x810(%rsp),%rbx
lea    0xe51(%rip),%r15
lea    0xe51(%rip),%r12
jmp    11ff <main+0x8f>
nopl   0x0(%rax)
lea    0x817(%rsp),%rsi
mov    0x8(%rsp),%rdi
call   1070 <my_open@plt>
lea    0x1(%r14),%ebp
mov    %rax,0x10(%rsp,%r14,8)
test   %ebp,%ebp
je     127d <main+0x10d>
movslq %ebp,%r14
add    $0xffffffff,%ebp
mov    0x8(%rsp,%r14,8),%r13
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0xfff,%esi
mov    %r13,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11fb <main+0x8b>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11e0 <main+0x70>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1270 <main+0x100>
mov    %rbx,%rdi
call   1040 <puts@plt>
jmp    1210 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
lea    0x819(%rsp),%rsi
jmp    11e8 <main+0x78>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Usage: %s directory root texi file\0A\00"
@.str.1 = [7 x i8] c"@input\00"
@.str.2 = [9 x i8] c"@include\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i32*]
%7 = alloca i32
%8 = alloca [4096 x i8]
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %9
%23 = load i8*, i8** %9
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32* @my_open(i8* %23, i8* %26)
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds [256 x i32*], [256 x i32*]* %6, i64 0, i64 %30
store i32* %27, i32** %31
br label %32
32: ; preds = %81, %66, %53, %19
%33 = load i32, i32* %7
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %82
35: ; preds = %32
%36 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%37 = load i32, i32* %7
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [256 x i32*], [256 x i32*]* %6, i64 0, i64 %39
%41 = load i32*, i32** %40
%42 = call i64 @fgets(i8* %36, i32 4095, i32* %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %78
44: ; preds = %35
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%46 = call i32 @strlen(i8* %45)
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 %48
store i8 0, i8* %49
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%51 = call i32 @strncmp(i8* %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%52 = icmp ne i32 %51, 0
br i1 %52, label %62, label %53
53: ; preds = %44
%54 = load i8*, i8** %9
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%56 = getelementptr inbounds i8, i8* %55, i64 7
%57 = call i32* @my_open(i8* %54, i8* %56)
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds [256 x i32*], [256 x i32*]* %6, i64 0, i64 %60
store i32* %57, i32** %61
br label %32
62: ; preds = %44
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%64 = call i32 @strncmp(i8* %63, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%65 = icmp ne i32 %64, 0
br i1 %65, label %75, label %66
66: ; preds = %62
%67 = load i8*, i8** %9
%68 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%69 = getelementptr inbounds i8, i8* %68, i64 9
%70 = call i32* @my_open(i8* %67, i8* %69)
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
%73 = sext i32 %71 to i64
%74 = getelementptr inbounds [256 x i32*], [256 x i32*]* %6, i64 0, i64 %73
store i32* %70, i32** %74
br label %32
75: ; preds = %62
%76 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%77 = call i32 @puts(i8* %76)
br label %81
78: ; preds = %35
%79 = load i32, i32* %7
%80 = add nsw i32 %79, -1
store i32 %80, i32* %7
br label %81
81: ; preds = %78, %75
br label %32
82: ; preds = %32
%83 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Usage: %s directory root texi file\0A\00"
@.str.1 = [7 x i8] c"@input\00"
@.str.2 = [9 x i8] c"@include\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i32*]
%4 = alloca [4096 x i8]
%5 = bitcast [256 x i32*]* %3 to i8*
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32* @my_open(i8* %15, i8* %17)
%19 = getelementptr inbounds [256 x i32*], [256 x i32*]* %3, i64 0, i64 0
store i32* %18, i32** %19
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 9
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 7
br label %22
22: ; preds = %44, %13
%23 = phi i32 [ %45, %44 ], [ 1, %13 ]
%24 = add nsw i32 %23, -1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [256 x i32*], [256 x i32*]* %3, i64 0, i64 %25
%27 = load i32*, i32** %26
br label %28
28: ; preds = %22, %50
%29 = call i64 @fgets(i8* %6, i32 4095, i32* %27)
%30 = icmp eq i64 %29, 0
br i1 %30, label %44, label %31
31: ; preds = %28
%32 = call i32 @strlen(i8* %6)
%33 = add nsw i32 %32, -1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %34
store i8 0, i8* %35
%36 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %31, %47
%39 = phi i8* [ %20, %47 ], [ %21, %31 ]
%40 = call i32* @my_open(i8* %15, i8* %39)
%41 = add nsw i32 %23, 1
%42 = sext i32 %23 to i64
%43 = getelementptr inbounds [256 x i32*], [256 x i32*]* %3, i64 0, i64 %42
store i32* %40, i32** %43
br label %44
44: ; preds = %28, %38
%45 = phi i32 [ %41, %38 ], [ %24, %28 ]
%46 = icmp eq i32 %45, 0
br i1 %46, label %52, label %22
47: ; preds = %31
%48 = call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%49 = icmp eq i32 %48, 0
br i1 %49, label %38, label %50
50: ; preds = %47
%51 = call i32 @puts(i8* %6)
br label %28
52: ; preds = %44
%53 = call i32 @exit(i32 0)
unreachable
}