// File: /workspace/github_c_makefile_star2_O3/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 0x2110
movq %rax, -0x48(%rbp)
xorl %eax, %eax
callq 0x2110
movq %rax, %r12
xorl %eax, %eax
callq 0x2110
movq %rax, %r13
movq 0x3d0f(%rip), %rax      # 0x8fd8
movq (%rax), %rcx
movq 0x3cfd(%rip), %rax      # 0x8fd0
movq (%rax), %rbx
cmpl $0x2, %r15d
movq %r13, -0x40(%rbp)
jl 0x52eb
movq 0x8(%r14), %rdi
jne 0x52f9
xorl %r8d, %r8d
jmp 0x530d
movq %r12, %r13
movq %rcx, %r14
movq %rcx, %r15
jmp 0x53c0
movq 0x10(%r14), %r8
cmpl $0x4, %r15d
jb 0x530d
movq 0x18(%r14), %rdx
movq %rdx, -0x30(%rbp)
jmp 0x5315
movq $0x0, -0x30(%rbp)
movq %rbx, %rax
movq %rcx, %r14
testq %rdi, %rdi
je 0x5363
cmpb $0x2d, (%rdi)
jne 0x532e
cmpb $0x0, 0x1(%rdi)
movq %rcx, %r14
je 0x5363
movq %rcx, %rbx
leaq 0xd96(%rip), %rsi       # 0x60ce
movq %r8, %r14
movq %rdi, %r15
movq %r12, -0x38(%rbp)
movq %rax, %r12
callq 0x1190
movq %r14, %r8
movq %rbx, %rcx
movq %rax, %r14
movq %r12, %rax
movq -0x38(%rbp), %r12
testq %r14, %r14
je 0x546c
movq %rax, %rbx
testq %r8, %r8
je 0x5396
cmpb $0x2d, (%r8)
jne 0x5378
cmpb $0x0, 0x1(%r8)
je 0x5396
leaq 0xd4f(%rip), %rsi       # 0x60ce
movq %r8, %r15
movq %r8, %rdi
callq 0x1190
movq %rax, %rcx
testq %rax, %rax
je 0x5474
movq %rcx, %r15
movq -0x30(%rbp), %rdi
movq %r12, %r13
testq %rdi, %rdi
je 0x53c0
leaq 0x13ca(%rip), %rsi      # 0x6776
movq %rdi, %r12
callq 0x1190
movq %rax, %rbx
testq %rax, %rax
je 0x5464
movq -0x48(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x23d9
movq %r13, %rdi
movq %r15, -0x38(%rbp)
movq %r15, %rsi
callq 0x23d9
movq %r12, %rdi
movq %r13, %rsi
movq -0x40(%rbp), %r15
movq %r15, %rdx
callq 0x39d3
movq %r15, %rdi
movq %rbx, -0x30(%rbp)
movq %rbx, %rsi
callq 0x22be
movq %r12, %rdi
callq 0x221b
movq %r13, %rdi
callq 0x221b
movq %r15, %rdi
callq 0x221b
movq 0x3bb2(%rip), %r12      # 0x8fd0
cmpq (%r12), %r14
je 0x5430
movq %r14, %rdi
callq 0x1090
movq (%r12), %r14
movq -0x38(%rbp), %rdi
cmpq %r14, %rdi
movq -0x30(%rbp), %rbx
je 0x5446
callq 0x1090
movq (%r12), %rdi
cmpq %rdi, %rbx
je 0x5453
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 %r12, %rdi
callq 0x131b
movq %r15, %rdi
callq 0x12cd
movq %r15, %rdi
callq 0x12f4