// File: /workspace/github_c_makefile_star2_O0/mmayer[P]pcal/src/exprpars.c
// Function: parse_expr
int parse_expr (char *pbuf)
{
   OPERAND opd_stack[MAX_OP];   /* operand stack - TRUE/FALSE values */
   OPERATOR opr_stack[MAX_OP];   /* operator stack - precedence | op */
   int value, token, plevel, prec, result, npop, opr, opd, prev_token, op;
   
   plevel = 0;   /* paren nesting level */
   opd = opr = -1;   /* indices of stack tops */
   prev_token = TK_STARTINPUT;   /* to detect null expressions */
   
   if (DEBUG(DEBUG_PP)) fprintf(stderr, "evaluating expression '%s'\n", pbuf);
   do {
      pbuf = next_token(pbuf, &token, &value);
      
      /* check that the current token may follow the previous one */
      if (! IS_LEGAL(token, prev_token)) return EXPR_ERR;

      switch(token) {
         
      case TK_IDENT:   /* identifier => 1 if def, 0 if not */
         opd_stack[++opd] = value != PP_SYM_UNDEF;
         break;
         
      case TK_LPAREN:   /* left paren - bump nesting level */
         ++plevel;
         break;
         
      case TK_RPAREN:   /* right paren - decrement nesting */
         if (--plevel < 0) return EXPR_ERR;
         break;
         
      case TK_ENDINPUT:   /* end-of-input - treat as operator */
         if (prev_token == TK_STARTINPUT) return FALSE;   /* null expr => FALSE */
         /* fall through */

      case TK_UNARYOP:
      case TK_BINARYOP:

         /* get precedence of operator, adjusting for paren
          * nesting (TK_ENDINPUT has the lowest precedence
          * of all, to unwind operand/operator stacks at end)
          */
         prec = token == TK_ENDINPUT ? ENDINPUT_PREC : (plevel * PAREN_PREC) + opr_tbl[value].prec;
         
         /* pop (and perform) any equal- or higher-precedence
          * operators on operator stack: extract operator,
          * check for operand stack underflow, execute
          * operator, adjust operand stack height and place
          * result of operator on top
          */
         
         for ( ;
               opr >= 0 && PREC(opr_stack[opr]) >= prec;
               opr--) {
            op = OPCODE(opr_stack[opr]);
            npop = opr_tbl[op].type == TK_UNARYOP ? 0 : 1;
            if (opd < npop) return EXPR_ERR;
            result = (*opr_tbl[op].pfcn)(opd_stack + opd);
            opd_stack[opd -= npop] = result;
         }

         /* push operator (if any) onto stack */
         
         if (token != TK_ENDINPUT) opr_stack[++opr] = MAKE_OPR(prec, value);

         break;
         
      default:   /* should never get here */
         return EXPR_ERR;
         break;
      }
      
      prev_token = token;
      
   } while (token != TK_ENDINPUT);
   
   /* done - check for dangling parens, and leftover operand/operators */
   
   if (DEBUG(DEBUG_PP)) {
      fprintf(stderr, "evaluated to %s\n", opd_stack[0] ? "TRUE" : "FALSE");
   }

   return plevel != 0 || opd != 0 || opr != -1 ? 
      EXPR_ERR :   /* leftover junk - return error */
      opd_stack[0];   /* all OK - return final value */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0xffffffff, -0x8c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x90(%rbp) # imm = 0xFFFFFFFF
movl $0x7, -0x94(%rbp)
leaq 0x286c1(%rip), %rax     # 0x3275c
movl (%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0xa0c1
movq 0x23f4c(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1a3f8(%rip), %rsi     # 0x244b2
movb $0x0, %al
callq 0x51b0
jmp 0xa0c3
movq -0x10(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x74(%rbp), %rdx
callq 0xa3c0
movq %rax, -0x10(%rbp)
movslq -0x78(%rbp), %rcx
leaq 0x25a0d(%rip), %rax     # 0x2faf0
movl (%rax,%rcx,4), %eax
movl -0x94(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
jne 0xa108
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa3a7
movl -0x78(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0xa0(%rbp)
subl $0x5, %eax
ja 0xa30e
movq -0xa0(%rbp), %rax
leaq 0x1a363(%rip), %rcx     # 0x24490
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $-0x1, -0x74(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
movw %ax, %cx
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
cltq
movw %cx, -0x40(%rbp,%rax,2)
jmp 0xa31a
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0xa31a
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
cmpl $0x0, %eax
jge 0xa188
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa3a7
jmp 0xa31a
cmpl $0x7, -0x94(%rbp)
jne 0xa1a2
movl $0x0, -0x4(%rbp)
jmp 0xa3a7
jmp 0xa1a4
cmpl $0x6, -0x78(%rbp)
jne 0xa1b7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0xa4(%rbp)
jmp 0xa1da
movl -0x7c(%rbp), %eax
shll $0x3, %eax
movslq -0x74(%rbp), %rdx
leaq 0x258e8(%rip), %rcx     # 0x2fab0
shlq $0x4, %rdx
addq %rdx, %rcx
movswl (%rcx), %ecx
addl %ecx, %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0x80(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x8c(%rbp)
movb %al, -0xa5(%rbp)
jl 0xa20f
movslq -0x8c(%rbp), %rax
movswl -0x70(%rbp,%rax,2), %eax
sarl $0x4, %eax
cmpl -0x80(%rbp), %eax
setge %al
movb %al, -0xa5(%rbp)
movb -0xa5(%rbp), %al
testb $0x1, %al
jne 0xa21e
jmp 0xa2e4
movslq -0x8c(%rbp), %rax
movswl -0x70(%rbp,%rax,2), %eax
andl $0xf, %eax
movl %eax, -0x98(%rbp)
movslq -0x98(%rbp), %rcx
leaq 0x2586f(%rip), %rax     # 0x2fab0
shlq $0x4, %rcx
addq %rcx, %rax
movswl 0x2(%rax), %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x4, %edx
cmovel %ecx, %eax
movl %eax, -0x88(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x88(%rbp), %eax
jge 0xa279
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa3a7
movslq -0x98(%rbp), %rcx
leaq 0x25829(%rip), %rax     # 0x2fab0
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
leaq -0x40(%rbp), %rdi
movslq -0x90(%rbp), %rcx
shlq %rcx
addq %rcx, %rdi
callq *%rax
cwtl
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movw %ax, %cx
movl -0x88(%rbp), %edx
movl -0x90(%rbp), %eax
subl %edx, %eax
movl %eax, -0x90(%rbp)
cltq
movw %cx, -0x40(%rbp,%rax,2)
movl -0x8c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0xa1e3
cmpl $0x6, -0x78(%rbp)
je 0xa30c
movl -0x80(%rbp), %eax
shll $0x4, %eax
orl -0x74(%rbp), %eax
movw %ax, %cx
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
cltq
movw %cx, -0x70(%rbp,%rax,2)
jmp 0xa31a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa3a7
movl -0x78(%rbp), %eax
movl %eax, -0x94(%rbp)
cmpl $0x6, -0x78(%rbp)
jne 0xa0c3
leaq 0x28428(%rip), %rax     # 0x3275c
movl (%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0xa36f
movq 0x23cb3(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
movswl -0x40(%rbp), %ecx
leaq 0x1a191(%rip), %rdx     # 0x244e4
leaq 0x1a185(%rip), %rax     # 0x244df
cmpl $0x0, %ecx
cmovneq %rax, %rdx
leaq 0x1a166(%rip), %rsi     # 0x244ce
movb $0x0, %al
callq 0x51b0
cmpl $0x0, -0x7c(%rbp)
jne 0xa387
cmpl $0x0, -0x90(%rbp)
jne 0xa387
cmpl $-0x1, -0x8c(%rbp)
je 0xa394
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0xac(%rbp)
jmp 0xa39e
movswl -0x40(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)