// File: /workspace/github_c_makefile_star2_O0/c0stya[P]fslib/src/fssort.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;
    int sort_outer = 0;
    int c;

    while ( (c = getopt(argc, argv, "ioh")) != -1 ) {
        switch(c) {
            case 'i': 
                sort_outer = 0;
                break;
            case 'o': 
                sort_outer = 1;
                break;
            default:
                fprintf(stderr, "Usage: %s [-o] [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_arc_sort(fst, sort_outer);
    fst_write(fst, fout);
    fst_remove(fst);
    
    if (fin != stdout) {
        fclose(fin);
    }

    if (fout != stdout) {
        fclose(fout);
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
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 0x40a8(%rip), %rax      # 0xafd0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq 0x4092(%rip), %rax      # 0xafc8
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x182d(%rip), %rdx      # 0x877f
callq 0x1170
movl %eax, -0x40(%rbp)
cmpl $-0x1, %eax
je 0x6fb0
movl -0x40(%rbp), %eax
movl %eax, -0x44(%rbp)
subl $0x69, %eax
je 0x6f76
jmp 0x6f6c
movl -0x44(%rbp), %eax
subl $0x6f, %eax
je 0x6f7f
jmp 0x6f88
movl $0x0, -0x3c(%rbp)
jmp 0x6fae
movl $0x1, -0x3c(%rbp)
jmp 0x6fae
movq 0x4069(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x17e3(%rip), %rsi      # 0x8783
movb $0x0, %al
callq 0x10f0
xorl %edi, %edi
callq 0x1190
jmp 0x6f44
movq 0x4021(%rip), %rax      # 0xafd8
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jge 0x6fd4
movq -0x10(%rbp), %rax
movq 0x400f(%rip), %rcx      # 0xafd8
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq 0x3ffd(%rip), %rax      # 0xafd8
movl (%rax), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jge 0x7000
movq -0x10(%rbp), %rax
movq 0x3fe8(%rip), %rcx      # 0xafd8
movl (%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7049
movq -0x20(%rbp), %rdi
leaq 0x10d7(%rip), %rsi      # 0x80e9
callq 0x1150
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x7047
movq 0x3fd0(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x109c(%rip), %rsi      # 0x80d2
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x1190
jmp 0x7049
cmpq $0x0, -0x28(%rbp)
je 0x7092
movq -0x28(%rbp), %rdi
leaq 0x1753(%rip), %rsi      # 0x87ae
callq 0x1150
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x7090
movq 0x3f87(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x28(%rbp), %rdx
leaq 0x1053(%rip), %rsi      # 0x80d2
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x1190
jmp 0x7092
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2bd0
movq -0x18(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x39c0
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2a90
movq -0x18(%rbp), %rdi
callq 0x2960
movq -0x30(%rbp), %rax
movq 0x3efc(%rip), %rcx      # 0xafc8
cmpq (%rcx), %rax
je 0x70da
movq -0x30(%rbp), %rdi
callq 0x1080
movq -0x38(%rbp), %rax
movq 0x3ee3(%rip), %rcx      # 0xafc8
cmpq (%rcx), %rax
je 0x70f3
movq -0x38(%rbp), %rdi
callq 0x1080
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq