// File: /workspace/github_c_makefile_star2_O2/yangtau[P]hedgehog/src/format.c
// Function: main
int main(int argc, char** argv) {
    int ret       = 0;
    void* scanner = NULL;

    hg_strtable_init();
    assert(hg_yylex_init(&scanner) == 0);

    struct hg_parser p = {.fname = NULL, .nerr = 0, .lineno = 1, .tline = 1, .ast = NULL};

    if (argc == 2) {
        FILE* yyin;
        if ((yyin = fopen(argv[1], "r")) == NULL) {
            fprintf(stderr, "faild to open `%s`\n", argv[1]);
            ret = -1;
            goto clean;
        }

        p.fname = argv[1];
        hg_yyset_in(yyin, scanner);
        while (hg_yyparse(&p, scanner))
            ;
        fclose(yyin);

    } else if (argc == 3 && strcmp(argv[1], "-e") == 0) {
        assert(hg_yy_scan_string(argv[2], scanner));
        while (hg_yyparse(&p, scanner))
            ;

    } else {
        fprintf(stderr, "Usage: %s [filename]\n\t%s -s [code]\n", argv[0], argv[0]);
    }

    if (p.ast) {
        hg_str str = hg_ast_node_to_str(p.ast, 2);
        printf("%s", str);
    }

clean:
    if (p.ast) {
        hg_ast_node_free(p.ast);
    }
    hg_strtable_free();
    assert(hg_yylex_destroy(scanner) == 0);
    return ret;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x8(%rsp), %r14
andq $0x0, (%r14)
xorl %eax, %eax
callq 0x37c4
movq %r14, %rdi
callq 0x5e15
testl %eax, %eax
jne 0x243a
movups 0x3de0(%rip), %xmm0     # 0x60d0
movaps %xmm0, 0x20(%rsp)
movups 0x3dc4(%rip), %xmm0     # 0x60c0
movaps %xmm0, 0x10(%rsp)
cmpl $0x3, %ebp
je 0x235f
cmpl $0x2, %ebp
jne 0x23a3
movq 0x8(%rbx), %rdi
leaq 0x6566(%rip), %rsi      # 0x8880
callq 0x2180
testq %rax, %rax
je 0x2419
movq %rax, %r14
movq 0x8(%rbx), %rax
leaq 0x10(%rsp), %rbx
movq %rax, (%rbx)
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x5df3
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x3e40
testl %eax, %eax
jne 0x2344
movq %r14, %rdi
callq 0x20b0
jmp 0x23c1
movq 0x8(%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x23a3
cmpb $0x65, 0x1(%rax)
jne 0x23a3
cmpb $0x0, 0x2(%rax)
jne 0x23a3
movq 0x10(%rbx), %rdi
movq 0x8(%rsp), %rsi
callq 0x5ca1
testq %rax, %rax
je 0x246c
leaq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x3e40
testl %eax, %eax
jne 0x2390
jmp 0x23c1
movq 0x9c4e(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq (%rbx), %rcx
leaq 0x3cc2(%rip), %rsi      # 0x6079
movq %rcx, %rdx
xorl %eax, %eax
callq 0x2110
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x23e8
pushq $0x2
popq %rsi
callq 0x2cd7
leaq 0x64c1(%rip), %rdi      # 0x889b
xorl %ebx, %ebx
movq %rax, %rsi
xorl %eax, %eax
callq 0x20e0
jmp 0x23ea
xorl %ebx, %ebx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x23f9
callq 0x2baa
xorl %eax, %eax
callq 0x37eb
movq 0x8(%rsp), %rdi
callq 0x5e99
testl %eax, %eax
jne 0x2453
movl %ebx, %eax
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x9bd8(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq 0x8(%rbx), %rdx
leaq 0x3c13(%rip), %rsi      # 0x6041
xorl %eax, %eax
callq 0x2110
pushq $-0x1
popq %rbx
jmp 0x23ea
leaq 0x3bc3(%rip), %rdi      # 0x6004
leaq 0x3bd9(%rip), %rsi      # 0x6021
leaq 0x3bdb(%rip), %rcx      # 0x602a
pushq $0x12
jmp 0x2483
leaq 0x3c43(%rip), %rdi      # 0x609d
leaq 0x3bc0(%rip), %rsi      # 0x6021
leaq 0x3bc2(%rip), %rcx      # 0x602a
pushq $0x37
jmp 0x2483
leaq 0x3be2(%rip), %rdi      # 0x6055
leaq 0x3ba7(%rip), %rsi      # 0x6021
leaq 0x3ba9(%rip), %rcx      # 0x602a
pushq $0x25
popq %rdx
callq 0x20f0
nopl (%rax)