// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movb $0x0, %al
callq 0x5aa0
leaq -0x20(%rbp), %rdi
callq 0xaa80
cmpl $0x0, %eax
jne 0x230c
jmp 0x232b
leaq 0x9cf1(%rip), %rdi      # 0xc004
leaq 0x9d07(%rip), %rsi      # 0xc021
movl $0x12, %edx
leaq 0x9d04(%rip), %rcx      # 0xc02a
callq 0x20f0
movq 0x9d8e(%rip), %rax      # 0xc0c0
movq %rax, -0x40(%rbp)
movq 0x9d8b(%rip), %rax      # 0xc0c8
movq %rax, -0x38(%rbp)
movq 0x9d88(%rip), %rax      # 0xc0d0
movq %rax, -0x30(%rbp)
movq 0x9d85(%rip), %rax      # 0xc0d8
movq %rax, -0x28(%rbp)
cmpl $0x2, -0x8(%rbp)
jne 0x23e6
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xc6c2(%rip), %rsi      # 0xea32
callq 0x2190
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x23ab
movq 0xfc72(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x9ca9(%rip), %rsi      # 0xc041
movb $0x0, %al
callq 0x2120
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
jmp 0x24aa
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xa990
movq -0x20(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x6b40
cmpl $0x0, %eax
je 0x23d8
jmp 0x23c4
movq -0x48(%rbp), %rdi
callq 0x20b0
jmp 0x247d
cmpl $0x3, -0x8(%rbp)
jne 0x2455
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x9c5a(%rip), %rsi      # 0xc055
callq 0x2110
cmpl $0x0, %eax
jne 0x2455
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0xa5c0
cmpq $0x0, %rax
je 0x241e
jmp 0x243d
leaq 0x9c33(%rip), %rdi      # 0xc058
leaq 0x9bf5(%rip), %rsi      # 0xc021
movl $0x25, %edx
leaq 0x9bf2(%rip), %rcx      # 0xc02a
callq 0x20f0
jmp 0x243f
movq -0x20(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x6b40
cmpl $0x0, %eax
je 0x2453
jmp 0x243f
jmp 0x247b
movq 0xfb9c(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rcx
leaq 0x9c08(%rip), %rsi      # 0xc07c
movb $0x0, %al
callq 0x2120
jmp 0x247d
cmpq $0x0, -0x28(%rbp)
je 0x24a8
movq -0x28(%rbp), %rdi
movl $0x2, %esi
callq 0x3fb0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rsi
leaq 0xc5ac(%rip), %rdi      # 0xea4d
movb $0x0, %al
callq 0x20e0
jmp 0x24aa
cmpq $0x0, -0x28(%rbp)
je 0x24ba
movq -0x28(%rbp), %rdi
callq 0x32e0
movb $0x0, %al
callq 0x5ae0
movq -0x20(%rbp), %rdi
callq 0xac70
cmpl $0x0, %eax
jne 0x24d1
jmp 0x24f0
leaq 0x9bc8(%rip), %rdi      # 0xc0a0
leaq 0x9b42(%rip), %rsi      # 0xc021
movl $0x37, %edx
leaq 0x9b3f(%rip), %rcx      # 0xc02a
callq 0x20f0
movl -0x14(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)