#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 */
int WRDE_BADCHAR;
int WRDE_NOSPACE;
int WRDE_SYNTAX;
int /*<<< orphan*/ _itoa(long, char *);
int /*<<< orphan*/ eval_expr(char *, long *);
int /*<<< orphan*/ free(char *);
int parse_backtick(char **, size_t *, size_t *, char const *, size_t *, int,
                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *);
int parse_dollars(char **, size_t *, size_t *, char const *, size_t *, int,
                  int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                  int /*<<< orphan*/ *, int);
int parse_qtd_backslash(char **, size_t *, size_t *, char const *, size_t *);
char *w_addchar(char *, size_t *, size_t *, char const);
char *w_addstr(char *, size_t *, size_t *, int /*<<< orphan*/);
char *w_newword(size_t *, size_t *);
int parse_arith(char **word, size_t *word_length, size_t *max_length,
                const char *words, size_t *offset, int flags, int bracket) {
  int error;
  int paren_depth = 1;
  size_t expr_length;
  size_t expr_maxlen;
  char *expr;
  expr = w_newword(&expr_length, &expr_maxlen);
  for (; words[*offset]; ++(*offset)) {
    switch (words[*offset]) {
    case '$':
      error = parse_dollars(&expr, &expr_length, &expr_maxlen, words, offset,
                            flags, NULL, NULL, NULL, 1);
      if (error) {
        free(expr);
        return error;
      }
      break;
    case '`':
      (*offset)++;
      error = parse_backtick(&expr, &expr_length, &expr_maxlen, words, offset,
                             flags, NULL, NULL, NULL);
      if (error) {
        free(expr);
        return error;
      }
      break;
    case '\\':
      error =
          parse_qtd_backslash(&expr, &expr_length, &expr_maxlen, words, offset);
      if (error) {
        free(expr);
        return error;
      }
      break;
    case ')':
      if (--paren_depth == 0) {
        char result[21];
        long int numresult = 0;
        long long int convertme;
        if (bracket || words[1 + *offset] != ')') {
          free(expr);
          return WRDE_SYNTAX;
        }
        ++(*offset);
        if (*expr && eval_expr(expr, &numresult) != 0) {
          free(expr);
          return WRDE_SYNTAX;
        }
        if (numresult < 0) {
          convertme = -numresult;
          *word = w_addchar(*word, word_length, max_length, '-');
          if (!*word) {
            free(expr);
            return WRDE_NOSPACE;
          }
        } else
          convertme = numresult;
        result[20] = '\0';
        *word = w_addstr(*word, word_length, max_length,
                         _itoa(convertme, &result[20]));
        free(expr);
        return *word ? 0 : WRDE_NOSPACE;
      }
      expr = w_addchar(expr, &expr_length, &expr_maxlen, words[*offset]);
      if (expr == NULL)
        return WRDE_NOSPACE;
      break;
    case ']':
      if (bracket && paren_depth == 1) {
        char result[21];
        long int numresult = 0;
        if (*expr && eval_expr(expr, &numresult) != 0) {
          free(expr);
          return WRDE_SYNTAX;
        }
        result[20] = '\0';
        *word = w_addstr(*word, word_length, max_length,
                         _itoa(numresult, &result[20]));
        free(expr);
        return *word ? 0 : WRDE_NOSPACE;
      }
      free(expr);
      return WRDE_SYNTAX;
    case '\n':
    case ';':
    case '{':
    case '}':
      free(expr);
      return WRDE_BADCHAR;
    case '(':
      ++paren_depth;
    default:
      expr = w_addchar(expr, &expr_length, &expr_maxlen, words[*offset]);
      if (expr == NULL)
        return WRDE_NOSPACE;
    }
  }
  free(expr);
  return WRDE_SYNTAX;
}


x86 assembly (clang, -O0):
<parse_arith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
movl   $0x1,-0x3c(%rbp)
lea    -0x48(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1080 <w_newword@plt>
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     176c <parse_arith+0x5dc>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0xac(%rbp)
sub    $0xa,%eax
je     16ec <parse_arith+0x55c>
jmp    1206 <parse_arith+0x76>
mov    -0xac(%rbp),%eax
sub    $0x24,%eax
je     12ba <parse_arith+0x12a>
jmp    121a <parse_arith+0x8a>
mov    -0xac(%rbp),%eax
sub    $0x28,%eax
je     1706 <parse_arith+0x576>
jmp    122e <parse_arith+0x9e>
mov    -0xac(%rbp),%eax
sub    $0x29,%eax
je     13cd <parse_arith+0x23d>
jmp    1242 <parse_arith+0xb2>
mov    -0xac(%rbp),%eax
sub    $0x3b,%eax
je     16ec <parse_arith+0x55c>
jmp    1256 <parse_arith+0xc6>
mov    -0xac(%rbp),%eax
sub    $0x5c,%eax
je     138e <parse_arith+0x1fe>
jmp    126a <parse_arith+0xda>
mov    -0xac(%rbp),%eax
sub    $0x5d,%eax
je     15c7 <parse_arith+0x437>
jmp    127e <parse_arith+0xee>
mov    -0xac(%rbp),%eax
sub    $0x60,%eax
je     1321 <parse_arith+0x191>
jmp    1292 <parse_arith+0x102>
mov    -0xac(%rbp),%eax
sub    $0x7b,%eax
je     16ec <parse_arith+0x55c>
jmp    12a6 <parse_arith+0x116>
mov    -0xac(%rbp),%eax
sub    $0x7d,%eax
je     16ec <parse_arith+0x55c>
jmp    170f <parse_arith+0x57f>
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
lea    -0x58(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
xor    %eax,%eax
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
movl   $0x1,0x18(%rsp)
call   1070 <parse_dollars@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     131c <parse_arith+0x18c>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
jmp    1754 <parse_arith+0x5c4>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
lea    -0x58(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
xor    %eax,%eax
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1050 <parse_backtick@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     1389 <parse_arith+0x1f9>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
jmp    1754 <parse_arith+0x5c4>
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    -0x58(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1030 <parse_qtd_backslash@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     13c8 <parse_arith+0x238>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
jmp    1754 <parse_arith+0x5c4>
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jne    1582 <parse_arith+0x3f2>
movq   $0x0,-0x78(%rbp)
cmpl   $0x0,0x10(%rbp)
jne    140d <parse_arith+0x27d>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
add    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x29,%eax
je     1427 <parse_arith+0x297>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x2bcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1475 <parse_arith+0x2e5>
mov    -0x58(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   10a0 <eval_expr@plt>
cmp    $0x0,%eax
je     1475 <parse_arith+0x2e5>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x2b7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
cmpq   $0x0,-0x78(%rbp)
jge    14da <parse_arith+0x34a>
xor    %eax,%eax
sub    -0x78(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    $0x2d,%ecx
call   1060 <w_addchar@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    14d5 <parse_arith+0x345>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x2b15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
jmp    14e2 <parse_arith+0x352>
mov    -0x78(%rbp),%rax
mov    %rax,-0x80(%rbp)
movb   $0x0,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x80(%rbp),%rdi
lea    -0x70(%rbp),%rsi
add    $0x14,%rsi
call   10b0 <_itoa@plt>
mov    -0xc8(%rbp),%rdi
mov    -0xc0(%rbp),%rsi
mov    -0xb8(%rbp),%rdx
mov    %eax,%ecx
call   1090 <w_addstr@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1565 <parse_arith+0x3d5>
xor    %eax,%eax
mov    %eax,-0xcc(%rbp)
jmp    1574 <parse_arith+0x3e4>
mov    0x2a74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
movsbl (%rax,%rcx,1),%ecx
call   1060 <w_addchar@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    15c2 <parse_arith+0x432>
mov    0x2a28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
jmp    1754 <parse_arith+0x5c4>
cmpl   $0x0,0x10(%rbp)
je     16d2 <parse_arith+0x542>
cmpl   $0x1,-0x3c(%rbp)
jne    16d2 <parse_arith+0x542>
movq   $0x0,-0xa8(%rbp)
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1629 <parse_arith+0x499>
mov    -0x58(%rbp),%rdi
lea    -0xa8(%rbp),%rsi
call   10a0 <eval_expr@plt>
cmp    $0x0,%eax
je     1629 <parse_arith+0x499>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x29c9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
movb   $0x0,-0x8c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0xa8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
add    $0x14,%rsi
call   10b0 <_itoa@plt>
mov    -0xe8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    -0xd8(%rbp),%rdx
mov    %eax,%ecx
call   1090 <w_addstr@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     16b5 <parse_arith+0x525>
xor    %eax,%eax
mov    %eax,-0xec(%rbp)
jmp    16c4 <parse_arith+0x534>
mov    0x2924(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xec(%rbp)
mov    -0xec(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x2906(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x28dc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
movsbl (%rax,%rcx,1),%ecx
call   1060 <w_addchar@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    174f <parse_arith+0x5bf>
mov    0x289b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1781 <parse_arith+0x5f1>
jmp    1754 <parse_arith+0x5c4>
jmp    1759 <parse_arith+0x5c9>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    11ce <parse_arith+0x3e>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x286c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_arith>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9d,0x3c(%rsp)
mov    %r8,%rbx
mov    %rcx,%r13
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0x30(%rsp),%rdi
lea    0x58(%rsp),%rsi
call   1080 <w_newword@plt>
mov    %rax,0x20(%rsp)
mov    (%rbx),%rdx
mov    0x0(%r13,%rdx,1),%cl
test   %cl,%cl
je     12fe <parse_arith+0x16e>
mov    %r15,0x50(%rsp)
mov    %r14,0x40(%rsp)
mov    %rbp,0x48(%rsp)
mov    $0x1,%ebp
lea    0x58(%rsp),%r15
lea    0xe1a(%rip),%r14
jmp    124d <parse_arith+0xbd>
xorps  %xmm0,%xmm0
movups %xmm0,(%rsp)
movl   $0x1,0x18(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x20(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    %r15,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    0x3c(%rsp),%r9d
call   1070 <parse_dollars@plt>
test   %eax,%eax
jne    1335 <parse_arith+0x1a5>
mov    (%rbx),%rax
lea    0x1(%rax),%rdx
mov    %rdx,(%rbx)
movzbl 0x1(%r13,%rax,1),%ecx
test   %cl,%cl
je     12f9 <parse_arith+0x169>
movsbl %cl,%ecx
lea    -0x24(%rcx),%eax
cmp    $0x59,%eax
ja     12c3 <parse_arith+0x133>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
add    $0x1,%ebp
jmp    12d0 <parse_arith+0x140>
add    $0xffffffff,%ebp
jne    12d0 <parse_arith+0x140>
jmp    1391 <parse_arith+0x201>
lea    0x20(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    %r15,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1030 <parse_qtd_backslash@plt>
jmp    122d <parse_arith+0x9d>
add    $0x1,%rdx
mov    %rdx,(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x20(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    %r15,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    0x3c(%rsp),%r9d
call   1050 <parse_backtick@plt>
jmp    122d <parse_arith+0x9d>
cmp    $0xa,%ecx
je     1322 <parse_arith+0x192>
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    %r15,%rdx
call   1060 <w_addchar@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
jne    1235 <parse_arith+0xa5>
mov    0x2ce9(%rip),%rax
jmp    130d <parse_arith+0x17d>
mov    0x20(%rsp),%rax
mov    %rax,%rdi
call   1040 <free@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%r12d
mov    %r12d,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x20(%rsp),%rdi
call   1040 <free@plt>
mov    0x2ca5(%rip),%rax
jmp    130d <parse_arith+0x17d>
mov    %eax,%r12d
mov    0x20(%rsp),%rdi
call   1040 <free@plt>
jmp    1310 <parse_arith+0x180>
cmpl   $0x0,0xb0(%rsp)
je     13d5 <parse_arith+0x245>
cmp    $0x1,%ebp
jne    13d5 <parse_arith+0x245>
movq   $0x0,0x28(%rsp)
mov    0x20(%rsp),%rdi
xor    %r12d,%r12d
cmpb   $0x0,(%rdi)
je     13df <parse_arith+0x24f>
lea    0x28(%rsp),%rsi
call   10a0 <eval_expr@plt>
test   %eax,%eax
mov    0x48(%rsp),%rbp
mov    0x40(%rsp),%r14
mov    0x50(%rsp),%r15
jne    13d5 <parse_arith+0x245>
mov    0x28(%rsp),%rdi
jmp    13f0 <parse_arith+0x260>
movq   $0x0,0x28(%rsp)
cmpl   $0x0,0xb0(%rsp)
mov    0x50(%rsp),%rbp
jne    13d5 <parse_arith+0x245>
cmpb   $0x29,0x1(%r13,%rdx,1)
jne    13d5 <parse_arith+0x245>
add    $0x1,%rdx
mov    %rdx,(%rbx)
mov    0x20(%rsp),%rdi
cmpb   $0x0,(%rdi)
je     1431 <parse_arith+0x2a1>
lea    0x28(%rsp),%rsi
call   10a0 <eval_expr@plt>
test   %eax,%eax
mov    0x48(%rsp),%rbx
je     143e <parse_arith+0x2ae>
mov    0x20(%rsp),%rdi
jmp    1301 <parse_arith+0x171>
xor    %edi,%edi
mov    0x48(%rsp),%rbp
mov    0x40(%rsp),%r14
mov    0x50(%rsp),%r15
lea    0x74(%rsp),%rsi
movb   $0x0,0x74(%rsp)
mov    0x0(%rbp),%rbx
call   10b0 <_itoa@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %eax,%ecx
call   1090 <w_addstr@plt>
mov    %rax,0x0(%rbp)
mov    0x20(%rsp),%rdi
call   1040 <free@plt>
cmpq   $0x0,0x0(%rbp)
jne    1310 <parse_arith+0x180>
jmp    12f0 <parse_arith+0x160>
xor    %r14d,%r14d
mov    0x48(%rsp),%rbx
mov    (%rbx),%r15
jmp    1470 <parse_arith+0x2e0>
mov    0x28(%rsp),%r14
test   %r14,%r14
js     144d <parse_arith+0x2bd>
mov    (%rbx),%r15
jmp    1470 <parse_arith+0x2e0>
mov    (%rbx),%rdi
mov    %rbp,%rsi
mov    0x40(%rsp),%rdx
mov    $0x2d,%ecx
call   1060 <w_addchar@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     14b3 <parse_arith+0x323>
mov    %rax,%r15
neg    %r14
lea    0x74(%rsp),%rsi
movb   $0x0,0x74(%rsp)
mov    %r14,%rdi
call   10b0 <_itoa@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    0x40(%rsp),%rdx
mov    %eax,%ecx
call   1090 <w_addstr@plt>
mov    %rax,(%rbx)
mov    0x20(%rsp),%rdi
call   1040 <free@plt>
xor    %r12d,%r12d
cmpq   $0x0,(%rbx)
jne    1310 <parse_arith+0x180>
jmp    12f0 <parse_arith+0x160>
mov    0x20(%rsp),%rdi
call   1040 <free@plt>
mov    0x2b1c(%rip),%rax
jmp    130d <parse_arith+0x17d>

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

LLVM IR (-O2):
@WRDE_SYNTAX = global i32 0
@WRDE_NOSPACE = global i32 0
@WRDE_BADCHAR = global i32 0
define i32 @parse_arith(i8** nocapture %0, i64* %1, i64* %2, i8* %3, i64* %4, i32 %5, i32 %6) {
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca [21 x i8]
%12 = alloca i64
%13 = alloca [21 x i8]
%14 = alloca i64
%15 = bitcast i64* %8 to i8*
%16 = bitcast i64* %9 to i8*
%17 = bitcast i8** %10 to i8*
%18 = call i8* @w_newword(i64* %8, i64* %9)
store i8* %18, i8** %10
%19 = load i64, i64* %4
%20 = getelementptr inbounds i8, i8* %3, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %168, label %23
23: ; preds = %7, %159
%24 = phi i8 [ %164, %159 ], [ %21, %7 ]
%25 = phi i64 [ %162, %159 ], [ %19, %7 ]
%26 = phi i32 [ %160, %159 ], [ 1, %7 ]
%27 = sext i8 %24 to i32
switch i32 %27, label %152 [
i32 36, label %28
i32 96, label %34
i32 92, label %41
i32 41, label %47
i32 93, label %109
i32 10, label %146
i32 59, label %146
i32 123, label %146
i32 125, label %146
i32 40, label %150
]
28: ; preds = %23
%29 = call i32 @parse_dollars(i8** %10, i64* %8, i64* %9, i8* %3, i64* %4, i32 %5, i32* null, i32* null, i32* null, i32 1)
%30 = icmp eq i32 %29, 0
br i1 %30, label %159, label %31
31: ; preds = %28
%32 = load i8*, i8** %10
%33 = call i32 @free(i8* %32)
br label %172
34: ; preds = %23
%35 = add i64 %25, 1
store i64 %35, i64* %4
%36 = call i32 @parse_backtick(i8** %10, i64* %8, i64* %9, i8* %3, i64* %4, i32 %5, i32* null, i32* null, i32* null)
%37 = icmp eq i32 %36, 0
br i1 %37, label %159, label %38
38: ; preds = %34
%39 = load i8*, i8** %10
%40 = call i32 @free(i8* %39)
br label %172
41: ; preds = %23
%42 = call i32 @parse_qtd_backslash(i8** %10, i64* %8, i64* %9, i8* %3, i64* %4)
%43 = icmp eq i32 %42, 0
br i1 %43, label %159, label %44
44: ; preds = %41
%45 = load i8*, i8** %10
%46 = call i32 @free(i8* %45)
br label %172
47: ; preds = %23
%48 = add nsw i32 %26, -1
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %103
50: ; preds = %47
%51 = getelementptr inbounds [21 x i8], [21 x i8]* %11, i64 0, i64 0
%52 = bitcast i64* %12 to i8*
store i64 0, i64* %12
%53 = icmp eq i32 %6, 0
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = add i64 %25, 1
%56 = getelementptr inbounds i8, i8* %3, i64 %55
%57 = load i8, i8* %56
%58 = icmp eq i8 %57, 41
br i1 %58, label %63, label %59
59: ; preds = %54, %50
%60 = load i8*, i8** %10
%61 = call i32 @free(i8* %60)
%62 = load i32, i32* @WRDE_SYNTAX
br label %101
63: ; preds = %54
store i64 %55, i64* %4
%64 = load i8*, i8** %10
%65 = load i8, i8* %64
%66 = icmp eq i8 %65, 0
br i1 %66, label %77, label %67
67: ; preds = %63
%68 = call i32 @eval_expr(i8* %64, i64* %12)
%69 = icmp eq i32 %68, 0
br i1 %69, label %74, label %70
70: ; preds = %67
%71 = load i8*, i8** %10
%72 = call i32 @free(i8* %71)
%73 = load i32, i32* @WRDE_SYNTAX
br label %101
74: ; preds = %67
%75 = load i64, i64* %12
%76 = icmp slt i64 %75, 0
br i1 %76, label %80, label %77
77: ; preds = %63, %74
%78 = phi i64 [ %75, %74 ], [ 0, %63 ]
%79 = load i8*, i8** %0
br label %89
80: ; preds = %74
%81 = sub nsw i64 0, %75
%82 = load i8*, i8** %0
%83 = call i8* @w_addchar(i8* %82, i64* %1, i64* %2, i8 signext 45)
store i8* %83, i8** %0
%84 = icmp eq i8* %83, null
br i1 %84, label %85, label %89
85: ; preds = %80
%86 = load i8*, i8** %10
%87 = call i32 @free(i8* %86)
%88 = load i32, i32* @WRDE_NOSPACE
br label %101
89: ; preds = %77, %80
%90 = phi i8* [ %83, %80 ], [ %79, %77 ]
%91 = phi i64 [ %81, %80 ], [ %78, %77 ]
%92 = getelementptr inbounds [21 x i8], [21 x i8]* %11, i64 0, i64 20
store i8 0, i8* %92
%93 = call i32 @_itoa(i64 %91, i8* %92)
%94 = call i8* @w_addstr(i8* %90, i64* %1, i64* %2, i32 %93)
store i8* %94, i8** %0
%95 = load i8*, i8** %10
%96 = call i32 @free(i8* %95)
%97 = load i8*, i8** %0
%98 = icmp eq i8* %97, null
%99 = load i32, i32* @WRDE_NOSPACE
%100 = select i1 %98, i32 %99, i32 0
br label %101
101: ; preds = %89, %85, %70, %59
%102 = phi i32 [ %62, %59 ], [ %73, %70 ], [ %100, %89 ], [ %88, %85 ]
br label %172
103: ; preds = %47
%104 = load i8*, i8** %10
%105 = call i8* @w_addchar(i8* %104, i64* %8, i64* %9, i8 signext %24)
store i8* %105, i8** %10
%106 = icmp eq i8* %105, null
br i1 %106, label %107, label %159
107: ; preds = %103
%108 = load i32, i32* @WRDE_NOSPACE
br label %172
109: ; preds = %23
%110 = icmp ne i32 %6, 0
%111 = icmp eq i32 %26, 1
%112 = select i1 %110, i1 %111, i1 false
br i1 %112, label %113, label %142
113: ; preds = %109
%114 = getelementptr inbounds [21 x i8], [21 x i8]* %13, i64 0, i64 0
%115 = bitcast i64* %14 to i8*
store i64 0, i64* %14
%116 = load i8*, i8** %10
%117 = load i8, i8* %116
%118 = icmp eq i8 %117, 0
br i1 %118, label %128, label %119
119: ; preds = %113
%120 = call i32 @eval_expr(i8* %116, i64* %14)
%121 = icmp eq i32 %120, 0
br i1 %121, label %122, label %124
122: ; preds = %119
%123 = load i64, i64* %14
br label %128
124: ; preds = %119
%125 = load i8*, i8** %10
%126 = call i32 @free(i8* %125)
%127 = load i32, i32* @WRDE_SYNTAX
br label %140
128: ; preds = %122, %113
%129 = phi i64 [ %123, %122 ], [ 0, %113 ]
%130 = getelementptr inbounds [21 x i8], [21 x i8]* %13, i64 0, i64 20
store i8 0, i8* %130
%131 = load i8*, i8** %0
%132 = call i32 @_itoa(i64 %129, i8* %130)
%133 = call i8* @w_addstr(i8* %131, i64* %1, i64* %2, i32 %132)
store i8* %133, i8** %0
%134 = load i8*, i8** %10
%135 = call i32 @free(i8* %134)
%136 = load i8*, i8** %0
%137 = icmp eq i8* %136, null
%138 = load i32, i32* @WRDE_NOSPACE
%139 = select i1 %137, i32 %138, i32 0
br label %140
140: ; preds = %128, %124
%141 = phi i32 [ %127, %124 ], [ %139, %128 ]
br label %172
142: ; preds = %109
%143 = load i8*, i8** %10
%144 = call i32 @free(i8* %143)
%145 = load i32, i32* @WRDE_SYNTAX
br label %172
146: ; preds = %23, %23, %23, %23
%147 = load i8*, i8** %10
%148 = call i32 @free(i8* %147)
%149 = load i32, i32* @WRDE_BADCHAR
br label %172
150: ; preds = %23
%151 = add nsw i32 %26, 1
br label %152
152: ; preds = %23, %150
%153 = phi i32 [ %26, %23 ], [ %151, %150 ]
%154 = load i8*, i8** %10
%155 = call i8* @w_addchar(i8* %154, i64* %8, i64* %9, i8 signext %24)
store i8* %155, i8** %10
%156 = icmp eq i8* %155, null
br i1 %156, label %157, label %159
157: ; preds = %152
%158 = load i32, i32* @WRDE_NOSPACE
br label %172
159: ; preds = %28, %34, %41, %103, %152
%160 = phi i32 [ %153, %152 ], [ %48, %103 ], [ %26, %41 ], [ %26, %34 ], [ %26, %28 ]
%161 = load i64, i64* %4
%162 = add i64 %161, 1
store i64 %162, i64* %4
%163 = getelementptr inbounds i8, i8* %3, i64 %162
%164 = load i8, i8* %163
%165 = icmp eq i8 %164, 0
br i1 %165, label %166, label %23
166: ; preds = %159
%167 = load i8*, i8** %10
br label %168
168: ; preds = %166, %7
%169 = phi i8* [ %167, %166 ], [ %18, %7 ]
%170 = call i32 @free(i8* %169)
%171 = load i32, i32* @WRDE_SYNTAX
br label %172
172: ; preds = %168, %157, %146, %142, %140, %107, %101, %44, %38, %31
%173 = phi i32 [ %158, %157 ], [ %149, %146 ], [ %141, %140 ], [ %145, %142 ], [ %102, %101 ], [ %108, %107 ], [ %42, %44 ], [ %36, %38 ], [ %29, %31 ], [ %171, %168 ]
ret i32 %173
}