#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 */
char *check_alloc(int, int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
char *strchr(char *, char);
char *readtree(FILE *treef, int nbsp) {
  char *line;
  char *ctree, *ctreefin, *prov;
  int i;
  line = (char *)check_alloc(1000000 + 1, sizeof(char));
  ctree = check_alloc(3 * 100 * nbsp, sizeof(char));
  ctreefin = ctree;
  line[0] = '\n';
  while (line[0] == '\n')
    fgets(line, 1000000, treef);
  i = 0;
  while (line[i] == ' ' || line[i] == '\t')
    i++;
  if (line[i] != '(' && line[i] != '[') {
    printf("Tree first character should be '[' or '('\n");
    return NULL;
  }
  if (line[i] == '[') {
    while ((prov = strchr(line, ']')) == NULL) {
      if (!fgets(line, 1000000, treef)) {
        printf("Unterminated comment in tree ('[' missing)\n");
        return NULL;
      }
    }
    prov++;
    while (*prov == ' ' || *prov == '\t')
      prov++;
    if (*prov == '\n') {
      line[0] = '\n';
      while (line[0] == '\n' && fgets(line, 1000000, treef))
        ;
      prov = line;
      while (*prov == ' ' || *prov == '\t')
        prov++;
    }
    if (*prov != '(') {
      printf("Comments should be followed by '('\n");
      return NULL;
    }
  } else {
    prov = line + i;
  }
  sprintf(ctree, "%s", prov);
  while (*ctreefin != '\n' && *ctreefin != ';' && *ctreefin)
    ctreefin++;
  if (*ctreefin == ';')
    return ctree;
  while (fgets(line, 1000000, treef)) {
    sprintf(ctreefin, "%s", line);
    if (prov == strchr(line, ';')) {
      *(prov + 1) = 0;
      return ctree;
    }
    while (*ctreefin != '\n' && *ctreefin)
      ctreefin++;
  }
  *ctreefin = 0;
  free(line);
  return ctree;
}


x86 assembly (clang, -O0):
<readtree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    $0xf4241,%edi
mov    $0x1,%esi
call   1080 <check_alloc@plt>
mov    %rax,-0x20(%rbp)
imul   $0x12c,-0x14(%rbp),%edi
mov    $0x1,%esi
call   1080 <check_alloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11cd <readtree+0x6d>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xf4240,%esi
call   1060 <fgets@plt>
jmp    11a6 <readtree+0x46>
movl   $0x0,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x3d(%rbp)
je     1203 <readtree+0xa3>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
test   $0x1,%al
jne    1213 <readtree+0xb3>
jmp    1221 <readtree+0xc1>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d4 <readtree+0x74>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x28,%eax
je     1264 <readtree+0x104>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5b,%eax
je     1264 <readtree+0x104>
lea    0xdae(%rip),%rdi
call   1050 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1577 <readtree+0x417>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5b,%eax
jne    1404 <readtree+0x2a4>
jmp    127e <readtree+0x11e>
mov    -0x20(%rbp),%rdi
mov    $0x5d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    12d4 <readtree+0x174>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xf4240,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    12cf <readtree+0x16f>
lea    0xd6e(%rip),%rdi
call   1050 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1577 <readtree+0x417>
jmp    127e <readtree+0x11e>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x3e(%rbp)
je     1305 <readtree+0x1a5>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x3e(%rbp)
mov    -0x3e(%rbp),%al
test   $0x1,%al
jne    1315 <readtree+0x1b5>
jmp    1326 <readtree+0x1c6>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    12e0 <readtree+0x180>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    13d6 <readtree+0x276>
mov    -0x20(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x3f(%rbp)
jne    136e <readtree+0x20e>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xf4240,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x3f(%rbp)
mov    -0x3f(%rbp),%al
test   $0x1,%al
jne    137e <readtree+0x21e>
jmp    1383 <readtree+0x223>
jmp    133d <readtree+0x1dd>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x40(%rbp)
je     13b0 <readtree+0x250>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x40(%rbp)
mov    -0x40(%rbp),%al
test   $0x1,%al
jne    13c0 <readtree+0x260>
jmp    13d1 <readtree+0x271>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    138b <readtree+0x22b>
jmp    13d6 <readtree+0x276>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x28,%eax
je     13ff <readtree+0x29f>
lea    0xc6a(%rip),%rdi
call   1050 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1577 <readtree+0x417>
jmp    1413 <readtree+0x2b3>
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xc59(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x41(%rbp)
je     1461 <readtree+0x301>
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3b,%ecx
mov    %al,-0x41(%rbp)
je     1461 <readtree+0x301>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1471 <readtree+0x311>
jmp    1482 <readtree+0x322>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1427 <readtree+0x2c7>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
jne    149f <readtree+0x33f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1577 <readtree+0x417>
jmp    14a4 <readtree+0x344>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xf4240,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     155f <readtree+0x3ff>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xbac(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
jne    150f <readtree+0x3af>
mov    -0x38(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1577 <readtree+0x417>
jmp    1514 <readtree+0x3b4>
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x51(%rbp)
je     1539 <readtree+0x3d9>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1549 <readtree+0x3e9>
jmp    155a <readtree+0x3fa>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1514 <readtree+0x3b4>
jmp    14a4 <readtree+0x344>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readtree>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r15
mov    $0xf4241,%edi
mov    $0x1,%esi
call   1080 <check_alloc@plt>
mov    %rax,%r13
imul   $0x12c,%ebx,%edi
mov    $0x1,%esi
call   1080 <check_alloc@plt>
mov    %rax,%r14
movb   $0xa,0x0(%r13)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0xf4240,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
movzbl 0x0(%r13),%ecx
cmp    $0xa,%cl
je     11a0 <readtree+0x40>
xor    %eax,%eax
jmp    11cf <readtree+0x6f>
xchg   %ax,%ax
cmp    $0x9,%cl
jne    122d <readtree+0xcd>
movzbl 0x1(%r13,%rax,1),%ecx
add    $0x1,%rax
cmp    $0x1f,%cl
jle    11c0 <readtree+0x60>
cmp    $0x20,%cl
je     11c5 <readtree+0x65>
cmp    $0x28,%cl
je     1223 <readtree+0xc3>
cmp    $0x5b,%cl
jne    122d <readtree+0xcd>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    $0x5d,%esi
call   1060 <strchr@plt>
test   %rax,%rax
jne    1239 <readtree+0xd9>
mov    %r13,%rdi
mov    $0xf4240,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    11f0 <readtree+0x90>
lea    0xe05(%rip),%rdi
jmp    1349 <readtree+0x1e9>
mov    %eax,%eax
mov    %r13,%r12
add    %rax,%r12
jmp    12a9 <readtree+0x149>
lea    0xe1a(%rip),%rdi
jmp    1349 <readtree+0x1e9>
mov    %rax,%r12
nopl   0x0(%rax)
add    $0x1,%r12
movzbl (%r12),%eax
cmp    $0x9,%al
je     1240 <readtree+0xe0>
cmp    $0x20,%al
je     1240 <readtree+0xe0>
cmp    $0xa,%al
jne    12a1 <readtree+0x141>
movb   $0xa,0x0(%r13)
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0xf4240,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     127c <readtree+0x11c>
cmpb   $0xa,0x0(%r13)
je     1260 <readtree+0x100>
mov    %r13,%r12
jmp    1294 <readtree+0x134>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
movzbl (%r12),%eax
cmp    $0x20,%al
je     1290 <readtree+0x130>
cmp    $0x9,%al
je     1290 <readtree+0x130>
cmp    $0x28,%al
jne    1342 <readtree+0x1e2>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
test   %al,%al
je     1320 <readtree+0x1c0>
cmp    $0x3b,%al
je     1351 <readtree+0x1f1>
cmp    $0xa,%al
je     1320 <readtree+0x1c0>
add    $0x1,%rbx
jmp    12c0 <readtree+0x160>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
mov    %r13,%rdi
mov    $0x3b,%esi
call   1060 <strchr@plt>
cmp    %rax,%r12
je     135e <readtree+0x1fe>
nopl   (%rax)
movzbl (%rbx),%eax
test   %al,%al
je     1320 <readtree+0x1c0>
cmp    $0xa,%al
je     1320 <readtree+0x1c0>
add    $0x1,%rbx
jmp    1300 <readtree+0x1a0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0xf4240,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    12e0 <readtree+0x180>
movb   $0x0,(%rbx)
mov    %r13,%rdi
call   1030 <free@plt>
jmp    1351 <readtree+0x1f1>
lea    0xcb7(%rip),%rdi
call   1050 <puts@plt>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
movb   $0x0,0x1(%r12)
jmp    1351 <readtree+0x1f1>

LLVM IR (-O0):
@.str = [43 x i8] c"Tree first character should be '[' or '('\0A\00"
@.str.1 = [44 x i8] c"Unterminated comment in tree ('[' missing)\0A\00"
@.str.2 = [36 x i8] c"Comments should be followed by '('\0A\00"
@.str.3 = [3 x i8] c"%s\00"
define i8* @readtree(i32* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%11 = call i8* @check_alloc(i32 1000001, i32 1)
store i8* %11, i8** %6
%12 = load i32, i32* %5
%13 = mul nsw i32 300, %12
%14 = call i8* @check_alloc(i32 %13, i32 1)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
store i8* %15, i8** %8
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 10, i8* %17
br label %18
18: ; preds = %24, %2
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = load i8*, i8** %6
%26 = load i32*, i32** %4
%27 = call i64 @fgets(i8* %25, i32 1000000, i32* %26)
br label %18
28: ; preds = %18
store i32 0, i32* %10
br label %29
29: ; preds = %47, %28
%30 = load i8*, i8** %6
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 32
br i1 %36, label %45, label %37
37: ; preds = %29
%38 = load i8*, i8** %6
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 9
br label %45
45: ; preds = %37, %29
%46 = phi i1 [ true, %29 ], [ %44, %37 ]
br i1 %46, label %47, label %50
47: ; preds = %45
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
br label %29
50: ; preds = %45
%51 = load i8*, i8** %6
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %56, 40
br i1 %57, label %58, label %68
58: ; preds = %50
%59 = load i8*, i8** %6
%60 = load i32, i32* %10
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 91
br i1 %65, label %66, label %68
66: ; preds = %58
%67 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %3
br label %231
68: ; preds = %58, %50
%69 = load i8*, i8** %6
%70 = load i32, i32* %10
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 91
br i1 %75, label %76, label %155
76: ; preds = %68
br label %77
77: ; preds = %88, %76
%78 = load i8*, i8** %6
%79 = call i8* @strchr(i8* %78, i8 signext 93)
store i8* %79, i8** %9
%80 = icmp eq i8* %79, null
br i1 %80, label %81, label %89
81: ; preds = %77
%82 = load i8*, i8** %6
%83 = load i32*, i32** %4
%84 = call i64 @fgets(i8* %82, i32 1000000, i32* %83)
%85 = icmp ne i64 %84, 0
br i1 %85, label %88, label %86
86: ; preds = %81
%87 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %3
br label %231
88: ; preds = %81
br label %77
89: ; preds = %77
%90 = load i8*, i8** %9
%91 = getelementptr inbounds i8, i8* %90, i32 1
store i8* %91, i8** %9
br label %92
92: ; preds = %104, %89
%93 = load i8*, i8** %9
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 32
br i1 %96, label %102, label %97
97: ; preds = %92
%98 = load i8*, i8** %9
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp eq i32 %100, 9
br label %102
102: ; preds = %97, %92
%103 = phi i1 [ true, %92 ], [ %101, %97 ]
br i1 %103, label %104, label %107
104: ; preds = %102
%105 = load i8*, i8** %9
%106 = getelementptr inbounds i8, i8* %105, i32 1
store i8* %106, i8** %9
br label %92
107: ; preds = %102
%108 = load i8*, i8** %9
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp eq i32 %110, 10
br i1 %111, label %112, label %147
112: ; preds = %107
%113 = load i8*, i8** %6
%114 = getelementptr inbounds i8, i8* %113, i64 0
store i8 10, i8* %114
br label %115
115: ; preds = %128, %112
%116 = load i8*, i8** %6
%117 = getelementptr inbounds i8, i8* %116, i64 0
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = icmp eq i32 %119, 10
br i1 %120, label %121, label %126
121: ; preds = %115
%122 = load i8*, i8** %6
%123 = load i32*, i32** %4
%124 = call i64 @fgets(i8* %122, i32 1000000, i32* %123)
%125 = icmp ne i64 %124, 0
br label %126
126: ; preds = %121, %115
%127 = phi i1 [ false, %115 ], [ %125, %121 ]
br i1 %127, label %128, label %129
128: ; preds = %126
br label %115
129: ; preds = %126
%130 = load i8*, i8** %6
store i8* %130, i8** %9
br label %131
131: ; preds = %143, %129
%132 = load i8*, i8** %9
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp eq i32 %134, 32
br i1 %135, label %141, label %136
136: ; preds = %131
%137 = load i8*, i8** %9
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = icmp eq i32 %139, 9
br label %141
141: ; preds = %136, %131
%142 = phi i1 [ true, %131 ], [ %140, %136 ]
br i1 %142, label %143, label %146
143: ; preds = %141
%144 = load i8*, i8** %9
%145 = getelementptr inbounds i8, i8* %144, i32 1
store i8* %145, i8** %9
br label %131
146: ; preds = %141
br label %147
147: ; preds = %146, %107
%148 = load i8*, i8** %9
%149 = load i8, i8* %148
%150 = sext i8 %149 to i32
%151 = icmp ne i32 %150, 40
br i1 %151, label %152, label %154
152: ; preds = %147
%153 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %3
br label %231
154: ; preds = %147
br label %160
155: ; preds = %68
%156 = load i8*, i8** %6
%157 = load i32, i32* %10
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i8, i8* %156, i64 %158
store i8* %159, i8** %9
br label %160
160: ; preds = %155, %154
%161 = load i8*, i8** %7
%162 = load i8*, i8** %9
%163 = call i32 @sprintf(i8* %161, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %162)
br label %164
164: ; preds = %181, %160
%165 = load i8*, i8** %8
%166 = load i8, i8* %165
%167 = sext i8 %166 to i32
%168 = icmp ne i32 %167, 10
br i1 %168, label %169, label %179
169: ; preds = %164
%170 = load i8*, i8** %8
%171 = load i8, i8* %170
%172 = sext i8 %171 to i32
%173 = icmp ne i32 %172, 59
br i1 %173, label %174, label %179
174: ; preds = %169
%175 = load i8*, i8** %8
%176 = load i8, i8* %175
%177 = sext i8 %176 to i32
%178 = icmp ne i32 %177, 0
br label %179
179: ; preds = %174, %169, %164
%180 = phi i1 [ false, %169 ], [ false, %164 ], [ %178, %174 ]
br i1 %180, label %181, label %184
181: ; preds = %179
%182 = load i8*, i8** %8
%183 = getelementptr inbounds i8, i8* %182, i32 1
store i8* %183, i8** %8
br label %164
184: ; preds = %179
%185 = load i8*, i8** %8
%186 = load i8, i8* %185
%187 = sext i8 %186 to i32
%188 = icmp eq i32 %187, 59
br i1 %188, label %189, label %191
189: ; preds = %184
%190 = load i8*, i8** %7
store i8* %190, i8** %3
br label %231
191: ; preds = %184
br label %192
192: ; preds = %225, %191
%193 = load i8*, i8** %6
%194 = load i32*, i32** %4
%195 = call i64 @fgets(i8* %193, i32 1000000, i32* %194)
%196 = icmp ne i64 %195, 0
br i1 %196, label %197, label %226
197: ; preds = %192
%198 = load i8*, i8** %8
%199 = load i8*, i8** %6
%200 = call i32 @sprintf(i8* %198, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %199)
%201 = load i8*, i8** %9
%202 = load i8*, i8** %6
%203 = call i8* @strchr(i8* %202, i8 signext 59)
%204 = icmp eq i8* %201, %203
br i1 %204, label %205, label %209
205: ; preds = %197
%206 = load i8*, i8** %9
%207 = getelementptr inbounds i8, i8* %206, i64 1
store i8 0, i8* %207
%208 = load i8*, i8** %7
store i8* %208, i8** %3
br label %231
209: ; preds = %197
br label %210
210: ; preds = %222, %209
%211 = load i8*, i8** %8
%212 = load i8, i8* %211
%213 = sext i8 %212 to i32
%214 = icmp ne i32 %213, 10
br i1 %214, label %215, label %220
215: ; preds = %210
%216 = load i8*, i8** %8
%217 = load i8, i8* %216
%218 = sext i8 %217 to i32
%219 = icmp ne i32 %218, 0
br label %220
220: ; preds = %215, %210
%221 = phi i1 [ false, %210 ], [ %219, %215 ]
br i1 %221, label %222, label %225
222: ; preds = %220
%223 = load i8*, i8** %8
%224 = getelementptr inbounds i8, i8* %223, i32 1
store i8* %224, i8** %8
br label %210
225: ; preds = %220
br label %192
226: ; preds = %192
%227 = load i8*, i8** %8
store i8 0, i8* %227
%228 = load i8*, i8** %6
%229 = call i32 @free(i8* %228)
%230 = load i8*, i8** %7
store i8* %230, i8** %3
br label %231
231: ; preds = %226, %205, %189, %152, %86, %66
%232 = load i8*, i8** %3
ret i8* %232
}

LLVM IR (-O2):
@str = [35 x i8] c"Comments should be followed by '('\00"
@str.4 = [43 x i8] c"Unterminated comment in tree ('[' missing)\00"
@str.5 = [42 x i8] c"Tree first character should be '[' or '('\00"
define i8* @readtree(i32* nocapture %0, i32 %1) {
%3 = tail call i8* @check_alloc(i32 1000001, i32 1)
%4 = mul nsw i32 %1, 300
%5 = tail call i8* @check_alloc(i32 %4, i32 1)
store i8 10, i8* %3
br label %6
6: ; preds = %2, %6
%7 = tail call i64 @fgets(i8* %3, i32 1000000, i32* %0)
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 10
br i1 %9, label %6, label %10
10: ; preds = %6, %13
%11 = phi i8 [ %16, %13 ], [ %8, %6 ]
%12 = phi i64 [ %14, %13 ], [ 0, %6 ]
switch i8 %11, label %17 [
i8 32, label %13
i8 9, label %13
i8 91, label %19
i8 40, label %51
]
13: ; preds = %10, %10
%14 = add nuw i64 %12, 1
%15 = getelementptr inbounds i8, i8* %3, i64 %14
%16 = load i8, i8* %15
br label %10
17: ; preds = %10
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.5, i64 0, i64 0))
br label %83
19: ; preds = %10, %22
%20 = tail call i8* @strchr(i8* %3, i8 signext 93)
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = tail call i64 @fgets(i8* %3, i32 1000000, i32* %0)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %19
25: ; preds = %22
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.4, i64 0, i64 0))
br label %83
27: ; preds = %19, %31
%28 = phi i8* [ %29, %31 ], [ %20, %19 ]
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
switch i8 %30, label %45 [
i8 32, label %31
i8 9, label %31
i8 10, label %32
]
31: ; preds = %27, %27
br label %27
32: ; preds = %27
store i8 10, i8* %3
br label %36
33: ; preds = %36
%34 = load i8, i8* %3
%35 = icmp eq i8 %34, 10
br i1 %35, label %36, label %39
36: ; preds = %32, %33
%37 = tail call i64 @fgets(i8* %3, i32 1000000, i32* %0)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %33
39: ; preds = %33, %36
br label %40
40: ; preds = %39, %43
%41 = phi i8* [ %44, %43 ], [ %3, %39 ]
%42 = load i8, i8* %41
switch i8 %42, label %45 [
i8 32, label %43
i8 9, label %43
]
43: ; preds = %40, %40
%44 = getelementptr inbounds i8, i8* %41, i64 1
br label %40
45: ; preds = %27, %40
%46 = phi i8 [ %42, %40 ], [ %30, %27 ]
%47 = phi i8* [ %41, %40 ], [ %29, %27 ]
%48 = icmp eq i8 %46, 40
br i1 %48, label %54, label %49
49: ; preds = %45
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %83
51: ; preds = %10
%52 = and i64 %12, 4294967295
%53 = getelementptr inbounds i8, i8* %3, i64 %52
br label %54
54: ; preds = %51, %45
%55 = phi i8* [ %47, %45 ], [ %53, %51 ]
%56 = tail call i8* @strcpy(i8* dereferenceable(1) %5, i8* %55)
br label %57
57: ; preds = %63, %54
%58 = phi i8* [ %5, %54 ], [ %64, %63 ]
%59 = load i8, i8* %58
switch i8 %59, label %63 [
i8 59, label %83
i8 0, label %60
i8 10, label %60
]
60: ; preds = %57, %57
%61 = tail call i64 @fgets(i8* %3, i32 1000000, i32* %0)
%62 = icmp eq i64 %61, 0
br i1 %62, label %80, label %65
63: ; preds = %57
%64 = getelementptr inbounds i8, i8* %58, i64 1
br label %57
65: ; preds = %60, %77
%66 = phi i8* [ %73, %77 ], [ %58, %60 ]
%67 = tail call i8* @strcpy(i8* %66, i8* %3)
%68 = tail call i8* @strchr(i8* %3, i8 signext 59)
%69 = icmp eq i8* %55, %68
br i1 %69, label %70, label %72
70: ; preds = %65
%71 = getelementptr inbounds i8, i8* %55, i64 1
store i8 0, i8* %71
br label %83
72: ; preds = %65, %75
%73 = phi i8* [ %76, %75 ], [ %66, %65 ]
%74 = load i8, i8* %73
switch i8 %74, label %75 [
i8 10, label %77
i8 0, label %77
]
75: ; preds = %72
%76 = getelementptr inbounds i8, i8* %73, i64 1
br label %72
77: ; preds = %72, %72
%78 = tail call i64 @fgets(i8* %3, i32 1000000, i32* %0)
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %65
80: ; preds = %77, %60
%81 = phi i8* [ %58, %60 ], [ %73, %77 ]
store i8 0, i8* %81
%82 = tail call i32 @free(i8* %3)
br label %83
83: ; preds = %57, %80, %70, %49, %25, %17
%84 = phi i8* [ null, %17 ], [ null, %25 ], [ null, %49 ], [ %5, %70 ], [ %5, %80 ], [ %5, %57 ]
ret i8* %84
}