// File: /workspace/github_c_makefile_star2_O2/c0stya[P]fslib/src/fscompose.c
// Function: main
int main(int argc, char * argv[]) {
    struct _fst * fst_a = fst_create(); 
    struct _fst * fst_b = fst_create(); 
    struct _fst * fst_c = fst_create(); 
    const char * ifilename_a = NULL; 
    const char * ifilename_b = NULL; 
    const char * ofilename = NULL;
    FILE * fin_a = stdin;
    FILE * fin_b = stdin;
    FILE * fout = stdout;

    if (argc > 1)
        ifilename_a = argv[1];
    if (argc > 2)
        ifilename_b = argv[2];
    if (argc > 3)
        ofilename = argv[3];
    
    if (ifilename_a && strcmp(ifilename_a, "-") != 0) {
        if (( fin_a = fopen(ifilename_a, "rb")) == NULL ) {
            fprintf(stderr, "Error opening file: %s", ifilename_a);
            exit(EXIT_FAILURE);
        }
    }

    if (ifilename_b && strcmp(ifilename_b, "-") != 0) {
        if (( fin_b = fopen(ifilename_b, "rb")) == NULL ) {
            fprintf(stderr, "Error opening file: %s", ifilename_b);
            exit(EXIT_FAILURE);
        }
    }

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

    fst_read(fst_a, fin_a);
    fst_read(fst_b, fin_b);

    fst_compose(fst_a, fst_b, fst_c);

    //fst_trim(fst_c);

    fst_write(fst_c, fout);

    fst_remove(fst_a);
    fst_remove(fst_b);
    fst_remove(fst_c);
    
    if (fin_a != stdout) {
        fclose(fin_a);
    }
    if (fin_b != stdout) {
        fclose(fin_b);
    }
    if (fout != stdout) {
        fclose(fout);
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movl %edi, %r15d
xorl %eax, %eax
callq 0x1fa0
movq %rax, -0x48(%rbp)
xorl %eax, %eax
callq 0x1fa0
movq %rax, %r12
xorl %eax, %eax
callq 0x1fa0
movq %rax, %r13
movq 0x41b7(%rip), %rax      # 0x8fd8
movq (%rax), %rcx
movq 0x41a5(%rip), %rax      # 0x8fd0
movq (%rax), %rbx
cmpl $0x2, %r15d
movq %r13, -0x40(%rbp)
jl 0x4e43
movq 0x8(%r14), %rdi
jne 0x4e51
xorl %r8d, %r8d
jmp 0x4e65
movq %r12, %r13
movq %rcx, %r14
movq %rcx, %r15
jmp 0x4f18
movq 0x10(%r14), %r8
cmpl $0x4, %r15d
jb 0x4e65
movq 0x18(%r14), %rdx
movq %rdx, -0x30(%rbp)
jmp 0x4e6d
movq $0x0, -0x30(%rbp)
movq %rbx, %rax
movq %rcx, %r14
testq %rdi, %rdi
je 0x4ebb
cmpb $0x2d, (%rdi)
jne 0x4e86
cmpb $0x0, 0x1(%rdi)
movq %rcx, %r14
je 0x4ebb
movq %rcx, %rbx
leaq 0x123e(%rip), %rsi      # 0x60ce
movq %r8, %r14
movq %rdi, %r15
movq %r12, -0x38(%rbp)
movq %rax, %r12
callq 0x1180
movq %r14, %r8
movq %rbx, %rcx
movq %rax, %r14
movq %r12, %rax
movq -0x38(%rbp), %r12
testq %r14, %r14
je 0x4fd2
movq %rax, %rbx
testq %r8, %r8
je 0x4eee
cmpb $0x2d, (%r8)
jne 0x4ed0
cmpb $0x0, 0x1(%r8)
je 0x4eee
leaq 0x11f7(%rip), %rsi      # 0x60ce
movq %r8, %rdi
movq %r8, %r15
callq 0x1180
movq %rax, %rcx
testq %rax, %rax
je 0x4fe8
movq %rcx, %r15
movq -0x30(%rbp), %rdi
movq %r12, %r13
testq %rdi, %rdi
je 0x4f18
leaq 0x1872(%rip), %rsi      # 0x6776
movq %rdi, %r12
callq 0x1180
movq %rax, %rbx
testq %rax, %rax
je 0x4fbc
movq -0x48(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x2238
movq %r13, %rdi
movq %r15, -0x38(%rbp)
movq %r15, %rsi
callq 0x2238
movq %r12, %rdi
movq %r13, %rsi
movq -0x40(%rbp), %r15
movq %r15, %rdx
callq 0x370f
movq %r15, %rdi
movq %rbx, -0x30(%rbp)
movq %rbx, %rsi
callq 0x2129
movq %r12, %rdi
callq 0x20a0
movq %r13, %rdi
callq 0x20a0
movq %r15, %rdi
callq 0x20a0
movq 0x405a(%rip), %r12      # 0x8fd0
cmpq (%r12), %r14
je 0x4f88
movq %r14, %rdi
callq 0x1090
movq (%r12), %r14
movq -0x38(%rbp), %rdi
cmpq %r14, %rdi
movq -0x30(%rbp), %rbx
je 0x4f9e
callq 0x1090
movq (%r12), %rdi
cmpq %rdi, %rbx
je 0x4fab
movq %rbx, %rdi
callq 0x1090
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4035(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x10ea(%rip), %rsi      # 0x60b7
movq %r12, %rdx
jmp 0x4ffc
movq 0x401f(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x10d4(%rip), %rsi      # 0x60b7
movq %r15, %rdx
jmp 0x4ffc
movq %r15, %rdx
movq 0x4006(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x10bb(%rip), %rsi      # 0x60b7
xorl %eax, %eax
callq 0x1120
pushq $0x1
popq %rdi
callq 0x11b0