// File: /workspace/github_c_makefile_star2_O1/orangeduck[P]mpc/examples/smallc.c
// Function: main
int main(int argc, char **argv) {

  mpc_parser_t* Ident     = mpc_new("ident");
  mpc_parser_t* Number    = mpc_new("number");
  mpc_parser_t* Character = mpc_new("character");
  mpc_parser_t* String    = mpc_new("string");
  mpc_parser_t* Factor    = mpc_new("factor");
  mpc_parser_t* Term      = mpc_new("term");
  mpc_parser_t* Lexp      = mpc_new("lexp");
  mpc_parser_t* Stmt      = mpc_new("stmt");
  mpc_parser_t* Exp       = mpc_new("exp");
  mpc_parser_t* Typeident = mpc_new("typeident");
  mpc_parser_t* Decls     = mpc_new("decls");
  mpc_parser_t* Args      = mpc_new("args");
  mpc_parser_t* Body      = mpc_new("body");
  mpc_parser_t* Procedure = mpc_new("procedure");
  mpc_parser_t* Main      = mpc_new("main");
  mpc_parser_t* Includes  = mpc_new("includes");
  mpc_parser_t* Smallc    = mpc_new("smallc");

  mpc_err_t* err = mpca_lang(MPCA_LANG_DEFAULT,
    " ident     : /[a-zA-Z_][a-zA-Z0-9_]*/ ;                           \n"
    " number    : /[0-9]+/ ;                                           \n"
    " character : /'.'/ ;                                              \n"
    " string    : /\"(\\\\.|[^\"])*\"/ ;                               \n"
    "                                                                  \n"
    " factor    : '(' <lexp> ')'                                       \n"
    "           | <number>                                             \n"
    "           | <character>                                          \n"
    "           | <string>                                             \n"
    "           | <ident> '(' <lexp>? (',' <lexp>)* ')'                \n"
    "           | <ident> ;                                            \n"
    "                                                                  \n"
    " term      : <factor> (('*' | '/' | '%') <factor>)* ;             \n"
    " lexp      : <term> (('+' | '-') <term>)* ;                       \n"
    "                                                                  \n"
    " stmt      : '{' <stmt>* '}'                                      \n"
    "           | \"while\" '(' <exp> ')' <stmt>                       \n"
    "           | \"if\"    '(' <exp> ')' <stmt>                       \n"
    "           | <ident> '=' <lexp> ';'                               \n"
    "           | \"print\" '(' <lexp>? ')' ';'                        \n"
    "           | \"return\" <lexp>? ';'                               \n"
    "           | <ident> '(' <ident>? (',' <ident>)* ')' ';' ;        \n"
    "                                                                  \n"
    " exp       : <lexp> '>' <lexp>                                    \n"
    "           | <lexp> '<' <lexp>                                    \n"
    "           | <lexp> \">=\" <lexp>                                 \n"
    "           | <lexp> \"<=\" <lexp>                                 \n"
    "           | <lexp> \"!=\" <lexp>                                 \n"
    "           | <lexp> \"==\" <lexp> ;                               \n"
    "                                                                  \n"
    " typeident : (\"int\" | \"char\") <ident> ;                       \n"
    " decls     : (<typeident> ';')* ;                                 \n"
    " args      : <typeident>? (',' <typeident>)* ;                    \n"
    " body      : '{' <decls> <stmt>* '}' ;                            \n"
    " procedure : (\"int\" | \"char\") <ident> '(' <args> ')' <body> ; \n"
    " main      : \"main\" '(' ')' <body> ;                            \n"
    " includes  : (\"#include\" <string>)* ;                           \n"
    " smallc    : /^/ <includes> <decls> <procedure>* <main> /$/ ;     \n",
    Ident, Number, Character, String, Factor, Term, Lexp, Stmt, Exp, 
    Typeident, Decls, Args, Body, Procedure, Main, Includes, Smallc, NULL);
  
  if (err != NULL) {
    mpc_err_print(err);
    mpc_err_delete(err);
    exit(1);
  }
    
  if (argc > 1) {
    
    mpc_result_t r;
    if (mpc_parse_contents(argv[1], Smallc, &r)) {
      mpc_ast_print(r.output);
      mpc_ast_delete(r.output);
    } else {
      mpc_err_print(r.error);
      mpc_err_delete(r.error);
    }
    
  } else {
    
    mpc_result_t r;
    if (mpc_parse_pipe("<stdin>", stdin, Smallc, &r)) {
      mpc_ast_print(r.output);
      mpc_ast_delete(r.output);
    } else {
      mpc_err_print(r.error);
      mpc_err_delete(r.error);
    }
  
  }

  mpc_cleanup(17, Ident, Number, Character, String, Factor, Term, Lexp, Stmt, Exp,
                  Typeident, Decls, Args, Body, Procedure, Main, Includes, Smallc);
  
  return 0;
  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, 0x60(%rsp)
movl %edi, 0x14(%rsp)
leaq 0x9cdf(%rip), %rdi      # 0xb02c
callq 0x3131
movq %rax, 0x58(%rsp)
leaq 0x9ca6(%rip), %rdi      # 0xb004
callq 0x3131
movq %rax, 0x48(%rsp)
leaq 0xaa31(%rip), %rdi      # 0xbda0
callq 0x3131
movq %rax, 0x20(%rsp)
leaq 0x9c8b(%rip), %rdi      # 0xb00b
callq 0x3131
movq %rax, 0x40(%rsp)
leaq 0x9c81(%rip), %rdi      # 0xb012
callq 0x3131
movq %rax, 0xa0(%rsp)
leaq 0x9c74(%rip), %rdi      # 0xb019
callq 0x3131
movq %rax, 0x50(%rsp)
leaq 0x9c68(%rip), %rdi      # 0xb01e
callq 0x3131
movq %rax, 0x98(%rsp)
leaq 0x9c59(%rip), %rdi      # 0xb023
callq 0x3131
movq %rax, 0x38(%rsp)
leaq 0x9c44(%rip), %rdi      # 0xb01f
callq 0x3131
movq %rax, 0x30(%rsp)
leaq 0x9c3c(%rip), %rdi      # 0xb028
callq 0x3131
movq %rax, 0x28(%rsp)
leaq 0x9c35(%rip), %rdi      # 0xb032
callq 0x3131
movq %rax, %rbp
leaq 0x9c2c(%rip), %rdi      # 0xb038
callq 0x3131
movq %rax, %rbx
leaq 0x9c22(%rip), %rdi      # 0xb03d
callq 0x3131
movq %rax, %r14
leaq 0x9c18(%rip), %rdi      # 0xb042
callq 0x3131
movq %rax, %r15
leaq 0x9c13(%rip), %rdi      # 0xb04c
callq 0x3131
movq %rax, %r13
leaq 0x9c09(%rip), %rdi      # 0xb051
callq 0x3131
movq %rax, %r12
leaq 0x9c03(%rip), %rdi      # 0xb05a
callq 0x3131
movq %rax, %r11
leaq 0x9bfb(%rip), %rsi      # 0xb061
xorl %edi, %edi
movq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq 0x98(%rsp), %r10
movq 0x20(%rsp), %r8
movq 0x40(%rsp), %r9
xorl %eax, %eax
pushq $0x0
movq %r11, 0x20(%rsp)
pushq %r11
movq %r12, 0x78(%rsp)
pushq %r12
movq %r13, 0x88(%rsp)
pushq %r13
movq %r15, 0x98(%rsp)
pushq %r15
movq %r14, 0xa8(%rsp)
pushq %r14
movq %rbx, 0xb8(%rsp)
pushq %rbx
movq %rbp, 0xc8(%rsp)
pushq %rbp
pushq 0x68(%rsp)
pushq 0x78(%rsp)
pushq 0x88(%rsp)
movq %r10, %r15
pushq %r10
pushq 0xb0(%rsp)
movq 0x108(%rsp), %rbx
pushq %rbx
callq 0x8d38
addq $0x70, %rsp
testq %rax, %rax
jne 0x15ed
cmpl $0x2, 0x14(%rsp)
jl 0x1523
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x8(%rsp), %rbp
movq 0x18(%rsp), %r14
movq %r14, %rsi
movq %rbp, %rdx
callq 0x2ef9
jmp 0x1549
movq 0xfab6(%rip), %rax      # 0x10fe0
movq (%rax), %rsi
leaq 0xa4ff(%rip), %rdi      # 0xba33
leaq 0x8(%rsp), %rbp
movq 0x18(%rsp), %r14
movq %r14, %rdx
movq %rbp, %rcx
callq 0x2e31
movq (%rbp), %rdi
testl %eax, %eax
je 0x1562
callq 0x6f1e
movq 0x8(%rsp), %rdi
callq 0x6ab7
jmp 0x1571
callq 0x165f
movq 0x8(%rsp), %rdi
callq 0x160c
movl $0x11, %edi
movq 0x58(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq 0x40(%rsp), %r8
movq %rbx, %r9
xorl %eax, %eax
pushq %r14
pushq 0x70(%rsp)
pushq 0x80(%rsp)
pushq 0x90(%rsp)
pushq 0xa0(%rsp)
pushq 0xb0(%rsp)
pushq 0xc0(%rsp)
pushq 0x60(%rsp)
pushq 0x70(%rsp)
pushq 0x80(%rsp)
pushq %r15
pushq 0xa8(%rsp)
callq 0x3580
addq $0x60, %rsp
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbp
movq %rax, %rdi
callq 0x165f
movq %rbp, %rdi
callq 0x160c
movl $0x1, %edi
callq 0x11f0
nop