// File: /workspace/github_c_makefile_star2_O3/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 0x3a18
movq %r14, %rdi
callq 0x6794
testl %eax, %eax
jne 0x259a
movups 0x4c5d(%rip), %xmm0     # 0x70d0
movaps %xmm0, 0x20(%rsp)
movups 0x4c41(%rip), %xmm0     # 0x70c0
movaps %xmm0, 0x10(%rsp)
cmpl $0x3, %ebp
je 0x24e5
cmpl $0x2, %ebp
jne 0x2529
movq 0x8(%rbx), %rdi
addq $0x8, %rbx
leaq 0x742f(%rip), %rsi      # 0x98d0
callq 0x2180
testq %rax, %rax
je 0x258b
movq %rax, %r14
movq (%rbx), %rax
leaq 0x10(%rsp), %rbx
movq %rax, (%rbx)
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6772
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4074
testl %eax, %eax
jne 0x24ca
movq %r14, %rdi
callq 0x20b0
jmp 0x2531
movq 0x8(%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x2529
cmpb $0x65, 0x1(%rax)
jne 0x2529
cmpb $0x0, 0x2(%rax)
jne 0x2529
movq 0x10(%rbx), %rdi
movq 0x8(%rsp), %rsi
callq 0x6629
testq %rax, %rax
je 0x25d8
leaq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4074
testl %eax, %eax
jne 0x2516
jmp 0x2531
movq %rbx, %rdi
callq 0x21f4
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x255a
movl $0x2, %esi
callq 0x2e53
leaq 0x739f(%rip), %rdi      # 0x98eb
xorl %ebx, %ebx
movq %rax, %rsi
xorl %eax, %eax
callq 0x20e0
jmp 0x255c
xorl %ebx, %ebx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x256b
callq 0x2d67
xorl %eax, %eax
callq 0x3a42
movq 0x8(%rsp), %rdi
callq 0x6825
testl %eax, %eax
jne 0x25b9
movl %ebx, %eax
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rbx, %rdi
callq 0x21d0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x255c
leaq 0x4a63(%rip), %rdi      # 0x7004
leaq 0x4a79(%rip), %rsi      # 0x7021
leaq 0x4a7b(%rip), %rcx      # 0x702a
movl $0x12, %edx
callq 0x20f0
leaq 0x4add(%rip), %rdi      # 0x709d
leaq 0x4a5a(%rip), %rsi      # 0x7021
leaq 0x4a5c(%rip), %rcx      # 0x702a
movl $0x37, %edx
callq 0x20f0
leaq 0x4a76(%rip), %rdi      # 0x7055
leaq 0x4a3b(%rip), %rsi      # 0x7021
leaq 0x4a3d(%rip), %rcx      # 0x702a
movl $0x25, %edx
callq 0x20f0
nop