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

/* Variables and functions */
scalar_t__ even(int);
int /*<<< orphan*/ free(char *);
char getTexChar();
scalar_t__ malloc(int);
char *my_strdup(char *);
scalar_t__ strncmp(char *, char *, int);
char *SlurpDollarEquation(void) {
  int brace = 0;
  int slash = 0;
  int i;
  char *s, *t, *u;
  s = (char *)malloc(1024 * sizeof(char));
  t = s;
  for (i = 0; i < 1024; i++) {
    *t = getTexChar();
    if (*t == '\\')
      slash++;
    else if (*t == '{' && even(slash) &&
             !(i > 5 && strncmp(t - 5, "\\left{", 6) == 0) &&
             !(i > 6 && strncmp(t - 6, "\\right{", 7) == 0))
      brace++;
    else if (*t == '}' && even(slash) &&
             !(i > 5 && !strncmp(t - 5, "\\left}", 6)) &&
             !(i > 6 && !strncmp(t - 6, "\\right}", 7)))
      brace--;
    else if (*t == '$' && even(slash) && brace == 0) {
      break;
    } else
      slash = 0;
    t++;
  }
  *t = '\0';
  u = my_strdup(s);
  free(s);
  return u;
}


x86 assembly (clang, -O0):
<SlurpDollarEquation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x400,-0xc(%rbp)
jge    1342 <SlurpDollarEquation+0x1e2>
mov    $0x0,%al
call   1050 <getTexChar@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11cd <SlurpDollarEquation+0x6d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1328 <SlurpDollarEquation+0x1c8>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7b,%eax
jne    1257 <SlurpDollarEquation+0xf7>
mov    -0x8(%rbp),%edi
call   1060 <even@plt>
cmp    $0x0,%rax
je     1257 <SlurpDollarEquation+0xf7>
cmpl   $0x5,-0xc(%rbp)
jle    121c <SlurpDollarEquation+0xbc>
mov    -0x20(%rbp),%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xdf8(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1257 <SlurpDollarEquation+0xf7>
cmpl   $0x6,-0xc(%rbp)
jle    1249 <SlurpDollarEquation+0xe9>
mov    -0x20(%rbp),%rdi
add    $0xfffffffffffffffa,%rdi
lea    0xdd2(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1257 <SlurpDollarEquation+0xf7>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1323 <SlurpDollarEquation+0x1c3>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7d,%eax
jne    12e1 <SlurpDollarEquation+0x181>
mov    -0x8(%rbp),%edi
call   1060 <even@plt>
cmp    $0x0,%rax
je     12e1 <SlurpDollarEquation+0x181>
cmpl   $0x5,-0xc(%rbp)
jle    12a6 <SlurpDollarEquation+0x146>
mov    -0x20(%rbp),%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xd7d(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     12e1 <SlurpDollarEquation+0x181>
cmpl   $0x6,-0xc(%rbp)
jle    12d3 <SlurpDollarEquation+0x173>
mov    -0x20(%rbp),%rdi
add    $0xfffffffffffffffa,%rdi
lea    0xd57(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     12e1 <SlurpDollarEquation+0x181>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    131e <SlurpDollarEquation+0x1be>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    1312 <SlurpDollarEquation+0x1b2>
mov    -0x8(%rbp),%edi
call   1060 <even@plt>
cmp    $0x0,%rax
je     1312 <SlurpDollarEquation+0x1b2>
cmpl   $0x0,-0x4(%rbp)
jne    1312 <SlurpDollarEquation+0x1b2>
jmp    1342 <SlurpDollarEquation+0x1e2>
movl   $0x0,-0x8(%rbp)
jmp    131e <SlurpDollarEquation+0x1be>
jmp    1323 <SlurpDollarEquation+0x1c3>
jmp    1328 <SlurpDollarEquation+0x1c8>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1193 <SlurpDollarEquation+0x33>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1080 <my_strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SlurpDollarEquation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
lea    0xe81(%rip),%r14
xor    %r15d,%r15d
mov    %rax,%rbx
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    11a8 <SlurpDollarEquation+0x48>
nopl   0x0(%rax)
add    $0x1,%ebp
add    $0x1,%rbx
add    $0x1,%r12d
cmp    $0x400,%r12d
je     12b7 <SlurpDollarEquation+0x157>
xor    %eax,%eax
call   1050 <getTexChar@plt>
mov    %al,(%rbx)
cmp    $0x7b,%al
je     11d0 <SlurpDollarEquation+0x70>
cmp    $0x5c,%al
je     1190 <SlurpDollarEquation+0x30>
cmp    $0x7d,%al
je     1228 <SlurpDollarEquation+0xc8>
jmp    1280 <SlurpDollarEquation+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
call   1060 <even@plt>
test   %rax,%rax
je     1221 <SlurpDollarEquation+0xc1>
cmp    $0x6,%r12d
jb     1218 <SlurpDollarEquation+0xb8>
lea    -0x5(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1221 <SlurpDollarEquation+0xc1>
cmp    $0x7,%r12d
jb     1218 <SlurpDollarEquation+0xb8>
lea    -0x6(%rbx),%rdi
lea    0xdfe(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1221 <SlurpDollarEquation+0xc1>
add    $0x1,%r15d
jmp    1193 <SlurpDollarEquation+0x33>
movzbl (%rbx),%eax
cmp    $0x7d,%al
jne    1280 <SlurpDollarEquation+0x120>
mov    %ebp,%edi
call   1060 <even@plt>
test   %rax,%rax
je     1280 <SlurpDollarEquation+0x120>
cmp    $0x6,%r12d
jb     1274 <SlurpDollarEquation+0x114>
lea    -0x5(%rbx),%rdi
lea    0xdca(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1280 <SlurpDollarEquation+0x120>
cmp    $0x7,%r12d
jb     1274 <SlurpDollarEquation+0x114>
lea    -0x6(%rbx),%rdi
lea    0xdb1(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1280 <SlurpDollarEquation+0x120>
add    $0xffffffff,%r15d
jmp    1193 <SlurpDollarEquation+0x33>
nopl   (%rax)
cmpb   $0x24,(%rbx)
jne    12b0 <SlurpDollarEquation+0x150>
mov    %ebp,%edi
call   1060 <even@plt>
test   %rax,%rax
je     12b0 <SlurpDollarEquation+0x150>
mov    $0x0,%ebp
test   %r15d,%r15d
jne    1193 <SlurpDollarEquation+0x33>
jmp    12b7 <SlurpDollarEquation+0x157>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
jmp    1193 <SlurpDollarEquation+0x33>
movb   $0x0,(%rbx)
mov    %r13,%rdi
call   1080 <my_strdup@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"\\left{\00"
@.str.1 = [8 x i8] c"\\right{\00"
@.str.2 = [7 x i8] c"\\left}\00"
@.str.3 = [8 x i8] c"\\right}\00"
define i8* @SlurpDollarEquation() {
%1 = tail call i64 @malloc(i32 1024)
%2 = inttoptr i64 %1 to i8*
br label %3
3: ; preds = %0, %58
%4 = phi i32 [ 0, %0 ], [ %60, %58 ]
%5 = phi i8* [ %2, %0 ], [ %61, %58 ]
%6 = phi i32 [ 0, %0 ], [ %59, %58 ]
%7 = phi i32 [ 0, %0 ], [ %62, %58 ]
%8 = tail call signext i8 (...) @getTexChar()
store i8 %8, i8* %5
switch i8 %8, label %30 [
i8 92, label %9
i8 123, label %11
]
9: ; preds = %3
%10 = add nsw i32 %6, 1
br label %58
11: ; preds = %3
%12 = tail call i64 @even(i32 %6)
%13 = icmp eq i64 %12, 0
br i1 %13, label %28, label %14
14: ; preds = %11
%15 = icmp ugt i32 %7, 5
br i1 %15, label %16, label %26
16: ; preds = %14
%17 = getelementptr inbounds i8, i8* %5, i64 -5
%18 = tail call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %16
%21 = icmp ugt i32 %7, 6
br i1 %21, label %22, label %26
22: ; preds = %20
%23 = getelementptr inbounds i8, i8* %5, i64 -6
%24 = tail call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %14, %22, %20
%27 = add nsw i32 %4, 1
br label %58
28: ; preds = %11, %16, %22
%29 = load i8, i8* %5
br label %30
30: ; preds = %28, %3
%31 = phi i8 [ %29, %28 ], [ %8, %3 ]
%32 = icmp eq i8 %31, 125
br i1 %32, label %33, label %50
33: ; preds = %30
%34 = tail call i64 @even(i32 %6)
%35 = icmp eq i64 %34, 0
br i1 %35, label %50, label %36
36: ; preds = %33
%37 = icmp ugt i32 %7, 5
br i1 %37, label %38, label %48
38: ; preds = %36
%39 = getelementptr inbounds i8, i8* %5, i64 -5
%40 = tail call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%41 = icmp eq i64 %40, 0
br i1 %41, label %50, label %42
42: ; preds = %38
%43 = icmp ugt i32 %7, 6
br i1 %43, label %44, label %48
44: ; preds = %42
%45 = getelementptr inbounds i8, i8* %5, i64 -6
%46 = tail call i64 @strncmp(i8* %45, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%47 = icmp eq i64 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %36, %44, %42
%49 = add nsw i32 %4, -1
br label %58
50: ; preds = %44, %38, %33, %30
%51 = load i8, i8* %5
%52 = icmp eq i8 %51, 36
br i1 %52, label %53, label %58
53: ; preds = %50
%54 = tail call i64 @even(i32 %6)
%55 = icmp ne i64 %54, 0
%56 = icmp eq i32 %4, 0
%57 = select i1 %55, i1 %56, i1 false
br i1 %57, label %64, label %58
58: ; preds = %50, %53, %26, %48, %9
%59 = phi i32 [ %10, %9 ], [ %6, %48 ], [ %6, %26 ], [ 0, %53 ], [ 0, %50 ]
%60 = phi i32 [ %4, %9 ], [ %49, %48 ], [ %27, %26 ], [ %4, %53 ], [ %4, %50 ]
%61 = getelementptr inbounds i8, i8* %5, i64 1
%62 = add nuw nsw i32 %7, 1
%63 = icmp eq i32 %62, 1024
br i1 %63, label %64, label %3
64: ; preds = %53, %58
%65 = phi i8* [ %5, %53 ], [ %61, %58 ]
store i8 0, i8* %65
%66 = tail call i8* @my_strdup(i8* %2)
%67 = tail call i32 @free(i8* %2)
ret i8* %66
}