// File: /workspace/github_c_makefile_star2_O0/c0stya[P]fslib/src/fsdraw.c
// Function: main
int main(int argc, char * argv[]) {
    struct _fst * fst = fst_create(); 

    const char * ifilename = NULL; 
    const char * ofilename = NULL;

    FILE * fin = stdin;
    FILE * fout = stdout;
    FILE * isym = NULL;
    FILE * osym = NULL;
    FILE * ssym = NULL;

    struct _symt * ist = NULL;
    struct _symt * ost = NULL;
    struct _symt * sst = NULL;

    int c;
    int opt_index = -1;

    const char * short_options = "I:O:S:";

    const struct option long_options [] = {
        { "isym", required_argument, NULL, 'I' },
        { "osym", required_argument, NULL, 'O' },
        { "ssym", required_argument, NULL, 'S' },
        { "help", 0, NULL, 'h' },
        { 0, 0, NULL, 0}
    };

    while ( (c = getopt_long(argc, argv,  
                short_options, long_options, &opt_index )) != -1 ) {
        switch(c) {
            case 'I': 
                isym = file_open(optarg);
                ist = symt_create();
                symt_read(ist, isym);
                break;
            case 'O': 
                osym = file_open(optarg);
                ost = symt_create();
                symt_read(ost, osym);
                break;
            case 'S': 
                ssym = file_open(optarg);
                sst = symt_create();
                symt_read(sst, ssym);
                break;
            default:
                fprintf(stderr, "Usage: %s [--isym filename] [--osym filename]"
                    "[--ssym filename] [input_file] [output_file]\n", argv[0]);
                exit(EXIT_SUCCESS);
        } 
    }

    if (optind < argc)
        ifilename = argv[optind];
    if (optind+1 < argc)
        ofilename = argv[optind+1];

    if (ifilename) {
        if (( fin = fopen(ifilename, "rb")) == NULL ) {
            fprintf(stderr, "Error opening file: %s", ifilename);
            exit(EXIT_FAILURE);
        }
    }

    if (ofilename) {
        if (( fout = fopen(ofilename, "w")) == NULL ) {
            fprintf(stderr, "Error opening file: %s", ofilename);
            exit(EXIT_FAILURE);
        }
    }

    fst_read(fst, fin);
    fst_draw_sym(fst, fout, ist, ost, sst);
    fst_remove(fst);
    
    if (fin != stdout)
        fclose(fin);
    if (fout != stdout)
        fclose(fout);

    if (isym != NULL)
        fclose(isym);
    if (osym != NULL)
        fclose(osym);
    if (ssym != NULL)
        fclose(ssym);

    if (ist != NULL)
        symt_remove(ist); 
    if (ost != NULL)
        symt_remove(ost); 
    if (sst != NULL)
        symt_remove(sst); 

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, %al
callq 0x2750
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq 0x403d(%rip), %rax      # 0xafc8
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq 0x4027(%rip), %rax      # 0xafc0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movl $0xffffffff, -0x70(%rbp) # imm = 0xFFFFFFFF
leaq 0x17a1(%rip), %rax      # 0x877f
movq %rax, -0x78(%rbp)
leaq -0x120(%rbp), %rdi
leaq 0x3d40(%rip), %rsi      # 0xad30
movl $0xa0, %edx
callq 0x1120
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x78(%rbp), %rdx
leaq -0x120(%rbp), %rcx
leaq -0x70(%rbp), %r8
callq 0x10a0
movl %eax, -0x6c(%rbp)
cmpl $-0x1, %eax
je 0x7103
movl -0x6c(%rbp), %eax
movl %eax, -0x124(%rbp)
subl $0x49, %eax
je 0x704e
jmp 0x7031
movl -0x124(%rbp), %eax
subl $0x4f, %eax
je 0x707e
jmp 0x703e
movl -0x124(%rbp), %eax
subl $0x53, %eax
je 0x70ab
jmp 0x70d8
movq 0x3f83(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x6ef0
movq %rax, -0x40(%rbp)
movb $0x0, %al
callq 0x35e0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3200
jmp 0x70fe
movq 0x3f53(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x6ef0
movq %rax, -0x48(%rbp)
movb $0x0, %al
callq 0x35e0
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3200
jmp 0x70fe
movq 0x3f26(%rip), %rax      # 0xafd8
movq (%rax), %rdi
callq 0x6ef0
movq %rax, -0x50(%rbp)
movb $0x0, %al
callq 0x35e0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x3200
jmp 0x70fe
movq 0x3f19(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x16aa(%rip), %rsi      # 0x879a
movb $0x0, %al
callq 0x1100
xorl %edi, %edi
callq 0x1190
jmp 0x6ffa
movq 0x3ec6(%rip), %rax      # 0xafd0
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jge 0x7127
movq -0x10(%rbp), %rax
movq 0x3eb4(%rip), %rcx      # 0xafd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq 0x3ea2(%rip), %rax      # 0xafd0
movl (%rax), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jge 0x7153
movq -0x10(%rbp), %rax
movq 0x3e8d(%rip), %rcx      # 0xafd0
movl (%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x719c
movq -0x20(%rbp), %rdi
leaq 0xf84(%rip), %rsi       # 0x80e9
callq 0x1160
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x719a
movq 0x3e7d(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0xf49(%rip), %rsi       # 0x80d2
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1190
jmp 0x719c
cmpq $0x0, -0x28(%rbp)
je 0x71e5
movq -0x28(%rbp), %rdi
leaq 0x1647(%rip), %rsi      # 0x87f5
callq 0x1160
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x71e3
movq 0x3e34(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0xf00(%rip), %rsi       # 0x80d2
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1190
jmp 0x71e5
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2bd0
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x68(%rbp), %r8
callq 0x46b0
movq -0x18(%rbp), %rdi
callq 0x2960
movq -0x30(%rbp), %rax
movq 0x3da1(%rip), %rcx      # 0xafc0
cmpq (%rcx), %rax
je 0x722d
movq -0x30(%rbp), %rdi
callq 0x1080
movq -0x38(%rbp), %rax
movq 0x3d88(%rip), %rcx      # 0xafc0
cmpq (%rcx), %rax
je 0x7246
movq -0x38(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x40(%rbp)
je 0x7256
movq -0x40(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x48(%rbp)
je 0x7266
movq -0x48(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x50(%rbp)
je 0x7276
movq -0x50(%rbp), %rdi
callq 0x1080
cmpq $0x0, -0x58(%rbp)
je 0x7286
movq -0x58(%rbp), %rdi
callq 0x3670
cmpq $0x0, -0x60(%rbp)
je 0x7296
movq -0x60(%rbp), %rdi
callq 0x3670
cmpq $0x0, -0x68(%rbp)
je 0x72a6
movq -0x68(%rbp), %rdi
callq 0x3670
xorl %eax, %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq