#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*/ buff;

/* Variables and functions */
int /*<<< orphan*/ _errToWords();
int /*<<< orphan*/ eset(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ loadCode(char *);
int /*<<< orphan*/ loadMC(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ tcFclose(int);
int tcFgets(char *, int, int);
int tcFopen(char *, char *);
int doIncludes(char *fname) {
  int unit, len, lineno = 0, libCount = 0, loadCount = 0;
  char buff[200];
  unit = tcFopen(fname, "r");
  if (unit < 0) {
    eset(29);
    _errToWords();
    exit(unit);
  }
  while (1) {
    len = tcFgets(buff, sizeof(buff), unit);
    if (len < 0)
      return len;
    ++lineno;
    if (len > 0) {
      if (buff[len - 1] == '\n' || buff[len - 1] == 0x0d) {
        buff[len - 1] = 0;
        if (len > 1) {
          if (buff[len - 2] == '\n' || buff[len - 2] == 0x0d)
            buff[len - 2] = 0;
        }
      }
    }
    if (!strncmp(buff, "#include ", 9)) {
      loadCode(buff + 9);
      ++libCount;
    } else if (!strncmp(buff, "#loadMC ", 8)) {
      loadMC(buff + 8);
      ++loadCount;
    } else {
      break;
    }
  }
  tcFclose(unit);
  return libCount;
}


x86 assembly (clang, -O0):
<doIncludes>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1060 <tcFopen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11ea <doIncludes+0x5a>
mov    $0x1d,%edi
call   1050 <eset@plt>
mov    $0x0,%al
call   1080 <_errToWords@plt>
mov    -0x14(%rbp),%edi
call   10a0 <exit@plt>
jmp    11ef <doIncludes+0x5f>
lea    -0xf0(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0xc8,%esi
call   10b0 <tcFgets@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    121b <doIncludes+0x8b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1366 <doIncludes+0x1d6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    12cb <doIncludes+0x13b>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     1260 <doIncludes+0xd0>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
jne    12c6 <doIncludes+0x136>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0xf0(%rbp,%rax,1)
cmpl   $0x1,-0x18(%rbp)
jle    12c1 <doIncludes+0x131>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
cltq
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     12ac <doIncludes+0x11c>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
cltq
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
jne    12bc <doIncludes+0x12c>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
cltq
movb   $0x0,-0xf0(%rbp,%rax,1)
jmp    12c1 <doIncludes+0x131>
jmp    12c6 <doIncludes+0x136>
jmp    12cb <doIncludes+0x13b>
lea    -0xf0(%rbp),%rdi
lea    0xd29(%rip),%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    130a <doIncludes+0x17a>
lea    -0xf0(%rbp),%rdi
add    $0x9,%rdi
call   1070 <loadCode@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1353 <doIncludes+0x1c3>
lea    -0xf0(%rbp),%rdi
lea    0xcf4(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1349 <doIncludes+0x1b9>
lea    -0xf0(%rbp),%rdi
add    $0x8,%rdi
call   1090 <loadMC@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    134e <doIncludes+0x1be>
jmp    1358 <doIncludes+0x1c8>
jmp    1353 <doIncludes+0x1c3>
jmp    11ef <doIncludes+0x5f>
mov    -0x14(%rbp),%edi
call   1030 <tcFclose@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doIncludes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
lea    0xe58(%rip),%rsi
call   1060 <tcFopen@plt>
mov    %eax,%ebp
test   %eax,%eax
js     12a1 <doIncludes+0x111>
mov    %rsp,%rdi
mov    $0xc8,%esi
mov    %ebp,%edx
call   10b0 <tcFgets@plt>
test   %eax,%eax
js     128f <doIncludes+0xff>
lea    0x8(%rsp),%r14
xor    %r15d,%r15d
lea    0xe25(%rip),%r12
mov    %rsp,%rbx
lea    0xe25(%rip),%r13
jmp    1211 <doIncludes+0x81>
nopl   0x0(%rax)
lea    0x9(%rsp),%rdi
call   1070 <loadCode@plt>
add    $0x1,%r15d
mov    %rbx,%rdi
mov    $0xc8,%esi
mov    %ebp,%edx
call   10b0 <tcFgets@plt>
test   %eax,%eax
js     128f <doIncludes+0xff>
test   %eax,%eax
je     1250 <doIncludes+0xc0>
lea    -0x1(%rax),%ecx
movzbl (%rsp,%rcx,1),%edx
cmp    $0xd,%dl
je     1226 <doIncludes+0x96>
cmp    $0xa,%dl
jne    1250 <doIncludes+0xc0>
movb   $0x0,(%rsp,%rcx,1)
cmp    $0x2,%eax
jb     1250 <doIncludes+0xc0>
add    $0xfffffffe,%eax
movzbl (%rsp,%rax,1),%ecx
cmp    $0xd,%cl
je     1240 <doIncludes+0xb0>
cmp    $0xa,%cl
jne    1250 <doIncludes+0xc0>
movb   $0x0,(%rsp,%rax,1)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     11f0 <doIncludes+0x60>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
jne    1285 <doIncludes+0xf5>
mov    %r14,%rdi
call   1090 <loadMC@plt>
jmp    11fe <doIncludes+0x6e>
mov    %ebp,%edi
call   1030 <tcFclose@plt>
mov    %r15d,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1d,%edi
call   1050 <eset@plt>
xor    %eax,%eax
call   1080 <_errToWords@plt>
mov    %ebp,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"#include \00"
@.str.2 = [9 x i8] c"#loadMC \00"
define i32 @doIncludes(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [200 x i8]
store i8* %0, i8** %3
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%10 = load i8*, i8** %3
%11 = call i32 @tcFopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = call i32 @eset(i32 29)
%16 = call i32 (...) @_errToWords()
%17 = load i32, i32* %4
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %1
br label %20
20: ; preds = %19, %102
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%22 = load i32, i32* %4
%23 = call i32 @tcFgets(i8* %21, i32 200, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = load i32, i32* %5
store i32 %27, i32* %2
br label %107
28: ; preds = %20
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
%31 = load i32, i32* %5
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %80
33: ; preds = %28
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 10
br i1 %40, label %49, label %41
41: ; preds = %33
%42 = load i32, i32* %5
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 13
br i1 %48, label %49, label %79
49: ; preds = %41, %33
%50 = load i32, i32* %5
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 %52
store i8 0, i8* %53
%54 = load i32, i32* %5
%55 = icmp sgt i32 %54, 1
br i1 %55, label %56, label %78
56: ; preds = %49
%57 = load i32, i32* %5
%58 = sub nsw i32 %57, 2
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 10
br i1 %63, label %72, label %64
64: ; preds = %56
%65 = load i32, i32* %5
%66 = sub nsw i32 %65, 2
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 %67
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 13
br i1 %71, label %72, label %77
72: ; preds = %64, %56
%73 = load i32, i32* %5
%74 = sub nsw i32 %73, 2
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 %75
store i8 0, i8* %76
br label %77
77: ; preds = %72, %64
br label %78
78: ; preds = %77, %49
br label %79
79: ; preds = %78, %41
br label %80
80: ; preds = %79, %28
%81 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%82 = call i32 @strncmp(i8* %81, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9)
%83 = icmp ne i32 %82, 0
br i1 %83, label %90, label %84
84: ; preds = %80
%85 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%86 = getelementptr inbounds i8, i8* %85, i64 9
%87 = call i32 @loadCode(i8* %86)
%88 = load i32, i32* %7
%89 = add nsw i32 %88, 1
store i32 %89, i32* %7
br label %102
90: ; preds = %80
%91 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%92 = call i32 @strncmp(i8* %91, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%93 = icmp ne i32 %92, 0
br i1 %93, label %100, label %94
94: ; preds = %90
%95 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%96 = getelementptr inbounds i8, i8* %95, i64 8
%97 = call i32 @loadMC(i8* %96)
%98 = load i32, i32* %8
%99 = add nsw i32 %98, 1
store i32 %99, i32* %8
br label %101
100: ; preds = %90
br label %103
101: ; preds = %94
br label %102
102: ; preds = %101, %84
br label %20
103: ; preds = %100
%104 = load i32, i32* %4
%105 = call i32 @tcFclose(i32 %104)
%106 = load i32, i32* %7
store i32 %106, i32* %2
br label %107
107: ; preds = %103, %26
%108 = load i32, i32* %2
ret i32 %108
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [10 x i8] c"#include \00"
@.str.2 = [9 x i8] c"#loadMC \00"
define i32 @doIncludes(i8* %0) {
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @tcFopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp slt i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = call i32 @tcFgets(i8* %3, i32 200, i32 %4)
%8 = icmp slt i32 %7, 0
br i1 %8, label %50, label %9
9: ; preds = %6
%10 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 8
%11 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 9
br label %16
12: ; preds = %1
%13 = tail call i32 @eset(i32 29)
%14 = tail call i32 (...) @_errToWords()
%15 = tail call i32 @exit(i32 %4)
unreachable
16: ; preds = %9, %44
%17 = phi i32 [ %7, %9 ], [ %46, %44 ]
%18 = phi i32 [ 0, %9 ], [ %45, %44 ]
%19 = icmp eq i32 %17, 0
br i1 %19, label %33, label %20
20: ; preds = %16
%21 = add nsw i32 %17, -1
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %22
%24 = load i8, i8* %23
switch i8 %24, label %33 [
i8 10, label %25
i8 13, label %25
]
25: ; preds = %20, %20
store i8 0, i8* %23
%26 = icmp ugt i32 %17, 1
br i1 %26, label %27, label %33
27: ; preds = %25
%28 = add nsw i32 %17, -2
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
switch i8 %31, label %33 [
i8 10, label %32
i8 13, label %32
]
32: ; preds = %27, %27
store i8 0, i8* %30
br label %33
33: ; preds = %27, %20, %32, %25, %16
%34 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i32 @loadCode(i8* %11)
%38 = add nsw i32 %18, 1
br label %44
39: ; preds = %33
%40 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = call i32 @loadMC(i8* %10)
br label %44
44: ; preds = %42, %36
%45 = phi i32 [ %18, %42 ], [ %38, %36 ]
%46 = call i32 @tcFgets(i8* %3, i32 200, i32 %4)
%47 = icmp slt i32 %46, 0
br i1 %47, label %50, label %16
48: ; preds = %39
%49 = call i32 @tcFclose(i32 %4)
br label %50
50: ; preds = %44, %6, %48
%51 = phi i32 [ %18, %48 ], [ %7, %6 ], [ %46, %44 ]
ret i32 %51
}