#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 */
struct mlm_thing {
  int dummy;
};
struct mlm_symbol {
  int dummy;
};
typedef int ssize_t;

/* Variables and functions */
scalar_t__ check_section_end(char);
struct mlm_thing *eval_thing(struct mlm_thing *, struct mlm_symbol *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free_thing(struct mlm_thing *);
struct mlm_thing *parse_string(char *);
int /*<<< orphan*/ print_thing(struct mlm_thing *);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
struct mlm_thing *parse_file(int fd, struct mlm_symbol *symbols) {
  ssize_t count = 1;
  char *str, *c, buf[512];
  struct mlm_thing *parsed, *state = NULL;
  while (count) {
    if (!fd) {
      printf("> ");
      fflush(stdout);
    }
    c = str = buf;
    count = read(fd, c, sizeof(char));
    if (!count || (*c == '\n' || *c == '\t' || *c == '\r' || *c == ' '))
      continue;
    else if (*c == '#') {
      while (count && *c != '\n')
        count = read(fd, ++c, sizeof(char));
      continue;
    }
    while (count && !check_section_end(*c))
      count = read(fd, ++c, sizeof(char));
    if (!count && check_section_end(*c)) {
      fprintf(stderr, "Reached end of input without ending section!\n");
      return NULL;
    }
    *c = '\0';
    if (state)
      free_thing(state);
    parsed = parse_string(str);
    state = eval_thing(parsed, symbols);
    free_thing(parsed);
    if (!fd) {
      print_thing(state);
      printf("\n");
    }
  }
  return state;
}


x86 assembly (clang, -O0):
<parse_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movq   $0x0,-0x240(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     13ef <parse_file+0x25f>
cmpl   $0x0,-0xc(%rbp)
jne    11e2 <parse_file+0x52>
lea    0xe31(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    -0x230(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     124f <parse_file+0xbf>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     124f <parse_file+0xbf>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     124f <parse_file+0xbf>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     124f <parse_file+0xbf>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1254 <parse_file+0xc4>
jmp    11b4 <parse_file+0x24>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    12c7 <parse_file+0x137>
jmp    1269 <parse_file+0xd9>
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x241(%rbp)
je     128e <parse_file+0xfe>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x241(%rbp)
mov    -0x241(%rbp),%al
test   $0x1,%al
jne    12a1 <parse_file+0x111>
jmp    12c2 <parse_file+0x132>
mov    -0xc(%rbp),%edi
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x30(%rbp)
mov    $0x1,%edx
call   1060 <read@plt>
mov    %eax,-0x1c(%rbp)
jmp    1269 <parse_file+0xd9>
jmp    11b4 <parse_file+0x24>
jmp    12cc <parse_file+0x13c>
jmp    12d1 <parse_file+0x141>
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x242(%rbp)
je     12fe <parse_file+0x16e>
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   10a0 <check_section_end@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x242(%rbp)
mov    -0x242(%rbp),%al
test   $0x1,%al
jne    1311 <parse_file+0x181>
jmp    1332 <parse_file+0x1a2>
mov    -0xc(%rbp),%edi
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x30(%rbp)
mov    $0x1,%edx
call   1060 <read@plt>
mov    %eax,-0x1c(%rbp)
jmp    12d1 <parse_file+0x141>
cmpl   $0x0,-0x1c(%rbp)
jne    1374 <parse_file+0x1e4>
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   10a0 <check_section_end@plt>
cmp    $0x0,%rax
je     1374 <parse_file+0x1e4>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
lea    0xca1(%rip),%rsi
call   1070 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    13fa <parse_file+0x26a>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
cmpq   $0x0,-0x240(%rbp)
je     1395 <parse_file+0x205>
mov    -0x240(%rbp),%rdi
call   1080 <free_thing@plt>
mov    -0x28(%rbp),%rdi
call   1030 <parse_string@plt>
mov    %rax,-0x238(%rbp)
mov    -0x238(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <eval_thing@plt>
mov    %rax,-0x240(%rbp)
mov    -0x238(%rbp),%rdi
call   1080 <free_thing@plt>
cmpl   $0x0,-0xc(%rbp)
jne    13ea <parse_file+0x25a>
mov    -0x240(%rbp),%rdi
call   10b0 <print_thing@plt>
lea    0xc4a(%rip),%rdi
call   1050 <printf@plt>
jmp    11b4 <parse_file+0x24>
mov    -0x240(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
xor    %r12d,%r12d
lea    0x10(%rsp),%r13
movabs $0x100002600,%r15
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
jne    11ee <parse_file+0x4e>
lea    0xe25(%rip),%rdi
call   1060 <printf@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
test   %eax,%eax
je     131c <parse_file+0x17c>
movzbl 0x10(%rsp),%eax
cmp    $0x23,%rax
ja     1255 <parse_file+0xb5>
bt     %rax,%r15
jb     11d0 <parse_file+0x30>
cmp    $0x23,%rax
jne    1255 <parse_file+0xb5>
lea    0x11(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
test   %eax,%eax
je     131c <parse_file+0x17c>
cmpb   $0xa,(%rbx)
lea    0x1(%rbx),%rbx
jne    1230 <parse_file+0x90>
jmp    11d0 <parse_file+0x30>
movsbl %al,%edi
call   10b0 <check_section_end@plt>
test   %rax,%rax
sete   0x7(%rsp)
je     126c <parse_file+0xcc>
mov    %r13,%rbx
jmp    12ca <parse_file+0x12a>
mov    %r14,0x8(%rsp)
lea    0x11(%rsp),%rdx
cs nopw 0x0(%rax,%rax,1)
mov    %rdx,%rbx
mov    %ebp,%edi
mov    %rdx,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
mov    %eax,%r14d
movsbl (%rbx),%edi
call   10b0 <check_section_end@plt>
test   %rax,%rax
sete   %cl
test   %r14d,%r14d
je     12c0 <parse_file+0x120>
lea    0x1(%rbx),%rdx
mov    %cl,0x7(%rsp)
test   %rax,%rax
je     1280 <parse_file+0xe0>
mov    %cl,0x7(%rsp)
mov    0x8(%rsp),%r14
jmp    12ca <parse_file+0x12a>
test   %rax,%rax
mov    0x8(%rsp),%r14
jne    1331 <parse_file+0x191>
movb   $0x0,(%rbx)
test   %r12,%r12
je     12da <parse_file+0x13a>
mov    %r12,%rdi
call   1090 <free_thing@plt>
mov    %r13,%rdi
call   1030 <parse_string@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <eval_thing@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1090 <free_thing@plt>
test   %ebp,%ebp
jne    1311 <parse_file+0x171>
mov    %r12,%rdi
call   10c0 <print_thing@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
testb  $0x1,0x7(%rsp)
je     11d0 <parse_file+0x30>
mov    %r12,%rax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
lea    0xcc2(%rip),%rsi
call   1080 <fprintf@plt>
xor    %r12d,%r12d
jmp    131c <parse_file+0x17c>

LLVM IR (-O0):
%struct.mlm_thing = type { i32 }
%struct.mlm_symbol = type { i32 }
@.str = [3 x i8] c"> \00"
@stdout = global i32 0
@stderr = global i32 0
@.str.1 = [46 x i8] c"Reached end of input without ending section!\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define %struct.mlm_thing* @parse_file(i32 %0, %struct.mlm_symbol* %1) {
%3 = alloca %struct.mlm_thing*
%4 = alloca i32
%5 = alloca %struct.mlm_symbol*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [512 x i8]
%10 = alloca %struct.mlm_thing*
%11 = alloca %struct.mlm_thing*
store i32 %0, i32* %4
store %struct.mlm_symbol* %1, %struct.mlm_symbol** %5
store i32 1, i32* %6
store %struct.mlm_thing* null, %struct.mlm_thing** %11
br label %12
12: ; preds = %122, %71, %49, %2
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %123
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* @stdout
%21 = call i32 @fflush(i32 %20)
br label %22
22: ; preds = %18, %15
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
store i8* %23, i8** %7
store i8* %23, i8** %8
%24 = load i32, i32* %4
%25 = load i8*, i8** %8
%26 = call i32 @read(i32 %24, i8* %25, i32 1)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %49
29: ; preds = %22
%30 = load i8*, i8** %8
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %49, label %34
34: ; preds = %29
%35 = load i8*, i8** %8
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 9
br i1 %38, label %49, label %39
39: ; preds = %34
%40 = load i8*, i8** %8
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 13
br i1 %43, label %49, label %44
44: ; preds = %39
%45 = load i8*, i8** %8
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 32
br i1 %48, label %49, label %50
49: ; preds = %44, %39, %34, %29, %22
br label %12
50: ; preds = %44
%51 = load i8*, i8** %8
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 35
br i1 %54, label %55, label %72
55: ; preds = %50
br label %56
56: ; preds = %66, %55
%57 = load i32, i32* %6
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %56
%60 = load i8*, i8** %8
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp ne i32 %62, 10
br label %64
64: ; preds = %59, %56
%65 = phi i1 [ false, %56 ], [ %63, %59 ]
br i1 %65, label %66, label %71
66: ; preds = %64
%67 = load i32, i32* %4
%68 = load i8*, i8** %8
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %8
%70 = call i32 @read(i32 %67, i8* %69, i32 1)
store i32 %70, i32* %6
br label %56
71: ; preds = %64
br label %12
72: ; preds = %50
br label %73
73: ; preds = %72
br label %74
74: ; preds = %85, %73
%75 = load i32, i32* %6
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %83
77: ; preds = %74
%78 = load i8*, i8** %8
%79 = load i8, i8* %78
%80 = call i64 @check_section_end(i8 signext %79)
%81 = icmp ne i64 %80, 0
%82 = xor i1 %81, true
br label %83
83: ; preds = %77, %74
%84 = phi i1 [ false, %74 ], [ %82, %77 ]
br i1 %84, label %85, label %90
85: ; preds = %83
%86 = load i32, i32* %4
%87 = load i8*, i8** %8
%88 = getelementptr inbounds i8, i8* %87, i32 1
store i8* %88, i8** %8
%89 = call i32 @read(i32 %86, i8* %88, i32 1)
store i32 %89, i32* %6
br label %74
90: ; preds = %83
%91 = load i32, i32* %6
%92 = icmp ne i32 %91, 0
br i1 %92, label %101, label %93
93: ; preds = %90
%94 = load i8*, i8** %8
%95 = load i8, i8* %94
%96 = call i64 @check_section_end(i8 signext %95)
%97 = icmp ne i64 %96, 0
br i1 %97, label %98, label %101
98: ; preds = %93
%99 = load i32, i32* @stderr
%100 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
store %struct.mlm_thing* null, %struct.mlm_thing** %3
br label %125
101: ; preds = %93, %90
%102 = load i8*, i8** %8
store i8 0, i8* %102
%103 = load %struct.mlm_thing*, %struct.mlm_thing** %11
%104 = icmp ne %struct.mlm_thing* %103, null
br i1 %104, label %105, label %108
105: ; preds = %101
%106 = load %struct.mlm_thing*, %struct.mlm_thing** %11
%107 = call i32 @free_thing(%struct.mlm_thing* %106)
br label %108
108: ; preds = %105, %101
%109 = load i8*, i8** %7
%110 = call %struct.mlm_thing* @parse_string(i8* %109)
store %struct.mlm_thing* %110, %struct.mlm_thing** %10
%111 = load %struct.mlm_thing*, %struct.mlm_thing** %10
%112 = load %struct.mlm_symbol*, %struct.mlm_symbol** %5
%113 = call %struct.mlm_thing* @eval_thing(%struct.mlm_thing* %111, %struct.mlm_symbol* %112)
store %struct.mlm_thing* %113, %struct.mlm_thing** %11
%114 = load %struct.mlm_thing*, %struct.mlm_thing** %10
%115 = call i32 @free_thing(%struct.mlm_thing* %114)
%116 = load i32, i32* %4
%117 = icmp ne i32 %116, 0
br i1 %117, label %122, label %118
118: ; preds = %108
%119 = load %struct.mlm_thing*, %struct.mlm_thing** %11
%120 = call i32 @print_thing(%struct.mlm_thing* %119)
%121 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %122
122: ; preds = %118, %108
br label %12
123: ; preds = %12
%124 = load %struct.mlm_thing*, %struct.mlm_thing** %11
store %struct.mlm_thing* %124, %struct.mlm_thing** %3
br label %125
125: ; preds = %123, %98
%126 = load %struct.mlm_thing*, %struct.mlm_thing** %3
ret %struct.mlm_thing* %126
}

LLVM IR (-O2):
%struct.mlm_thing = type { i32 }
%struct.mlm_symbol = type { i32 }
@.str = [3 x i8] c"> \00"
@stdout = global i32 0
@stderr = global i32 0
@.str.1 = [46 x i8] c"Reached end of input without ending section!\0A\00"
define %struct.mlm_thing* @parse_file(i32 %0, %struct.mlm_symbol* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 0
br label %6
6: ; preds = %2, %57
%7 = phi %struct.mlm_thing* [ null, %2 ], [ %52, %57 ]
br label %8
8: ; preds = %18, %6
br i1 %5, label %9, label %13
9: ; preds = %8
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stdout
%12 = call i32 @fflush(i32 %11)
br label %13
13: ; preds = %9, %8
%14 = call i32 @read(i32 %0, i8* %4, i32 1)
%15 = icmp eq i32 %14, 0
br i1 %15, label %58, label %16
16: ; preds = %13
%17 = load i8, i8* %4
switch i8 %17, label %19 [
i8 10, label %18
i8 9, label %18
i8 13, label %18
i8 32, label %18
i8 35, label %22
]
18: ; preds = %27, %16, %16, %16, %16
br label %8
19: ; preds = %16
%20 = call i64 @check_section_end(i8 signext %17)
%21 = icmp eq i64 %20, 0
br i1 %21, label %30, label %44
22: ; preds = %16, %27
%23 = phi i8* [ %24, %27 ], [ %4, %16 ]
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i32 @read(i32 %0, i8* %24, i32 1)
%26 = icmp eq i32 %25, 0
br i1 %26, label %58, label %27
27: ; preds = %22
%28 = load i8, i8* %24
%29 = icmp eq i8 %28, 10
br i1 %29, label %18, label %22
30: ; preds = %19, %39
%31 = phi i1 [ %38, %39 ], [ %21, %19 ]
%32 = phi i8* [ %33, %39 ], [ %4, %19 ]
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i32 @read(i32 %0, i8* %33, i32 1)
%35 = icmp eq i32 %34, 0
%36 = load i8, i8* %33
%37 = call i64 @check_section_end(i8 signext %36)
%38 = icmp eq i64 %37, 0
br i1 %35, label %40, label %39
39: ; preds = %30
br i1 %38, label %30, label %44
40: ; preds = %30
br i1 %38, label %44, label %41
41: ; preds = %40
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
br label %58
44: ; preds = %39, %19, %40
%45 = phi i1 [ %31, %40 ], [ %21, %19 ], [ %38, %39 ]
%46 = phi i8* [ %33, %40 ], [ %4, %19 ], [ %33, %39 ]
store i8 0, i8* %46
%47 = icmp eq %struct.mlm_thing* %7, null
br i1 %47, label %50, label %48
48: ; preds = %44
%49 = call i32 @free_thing(%struct.mlm_thing* %7)
br label %50
50: ; preds = %48, %44
%51 = call %struct.mlm_thing* @parse_string(i8* %4)
%52 = call %struct.mlm_thing* @eval_thing(%struct.mlm_thing* %51, %struct.mlm_symbol* %1)
%53 = call i32 @free_thing(%struct.mlm_thing* %51)
br i1 %5, label %54, label %57
54: ; preds = %50
%55 = call i32 @print_thing(%struct.mlm_thing* %52)
%56 = call i32 @putchar(i32 10)
br label %57
57: ; preds = %54, %50
br i1 %45, label %58, label %6
58: ; preds = %57, %13, %22, %41
%59 = phi %struct.mlm_thing* [ null, %41 ], [ %7, %22 ], [ %7, %13 ], [ %52, %57 ]
ret %struct.mlm_thing* %59
}