// File: /workspace/github_c_makefile_star2_O1/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
movq $0x0, (%r14)
xorl %eax, %eax
callq 0x399c
movq %r14, %rdi
callq 0x6893
testl %eax, %eax
jne 0x25b3
movups 0x4c4d(%rip), %xmm0     # 0x70d0
movaps %xmm0, 0x20(%rsp)
movups 0x4c31(%rip), %xmm0     # 0x70c0
movaps %xmm0, 0x10(%rsp)
cmpl $0x3, %ebp
je 0x24fc
cmpl $0x2, %ebp
jne 0x2597
movq 0x8(%rbx), %rdi
addq $0x8, %rbx
leaq 0x73cf(%rip), %rsi      # 0x9880
callq 0x2190
movq %rax, %r14
testq %rax, %rax
je 0x25a1
movq (%rbx), %rax
leaq 0x10(%rsp), %rbx
movq %rax, (%rbx)
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6871
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4020
testl %eax, %eax
jne 0x24da
movq %r14, %rdi
callq 0x20b0
xorl %ebx, %ebx
testq %r14, %r14
jne 0x2543
jmp 0x2568
movq 0x8(%rbx), %rdi
leaq 0x4b4e(%rip), %rsi      # 0x7055
callq 0x2110
testl %eax, %eax
jne 0x2597
movq 0x10(%rbx), %rdi
movq 0x8(%rsp), %rsi
callq 0x6728
testq %rax, %rax
je 0x25f1
leaq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4020
testl %eax, %eax
jne 0x2530
xorl %ebx, %ebx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2568
movl $0x2, %esi
callq 0x2e88
leaq 0x733d(%rip), %rdi      # 0x989b
movq %rax, %rsi
xorl %eax, %eax
callq 0x20e0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x2577
callq 0x2d7c
xorl %eax, %eax
callq 0x39c6
movq 0x8(%rsp), %rdi
callq 0x6960
testl %eax, %eax
jne 0x25d2
movl %ebx, %eax
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rbx, %rdi
callq 0x2204
jmp 0x2541
movq %rbx, %rdi
callq 0x21e0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x24f5
leaq 0x4a4a(%rip), %rdi      # 0x7004
leaq 0x4a60(%rip), %rsi      # 0x7021
leaq 0x4a62(%rip), %rcx      # 0x702a
movl $0x12, %edx
callq 0x20f0
leaq 0x4ac7(%rip), %rdi      # 0x70a0
leaq 0x4a41(%rip), %rsi      # 0x7021
leaq 0x4a43(%rip), %rcx      # 0x702a
movl $0x37, %edx
callq 0x20f0
leaq 0x4a60(%rip), %rdi      # 0x7058
leaq 0x4a22(%rip), %rsi      # 0x7021
leaq 0x4a24(%rip), %rcx      # 0x702a
movl $0x25, %edx
callq 0x20f0