// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movl %edi, %r12d
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x2114
movq %rax, -0x50(%rbp)
xorl %eax, %eax
callq 0x2114
movq %rax, -0x48(%rbp)
xorl %eax, %eax
callq 0x2114
movq %rax, -0x40(%rbp)
cmpl $0x2, %r12d
jl 0x52a9
movq 0x8(%rbx), %r15
cmpl $0x3, %r12d
jl 0x52b5
movq 0x10(%rbx), %r14
jmp 0x52b8
xorl %r14d, %r14d
movq 0x3d19(%rip), %rax      # 0x8fd8
cmpl $0x4, %r12d
jl 0x52cf
movq 0x18(%rbx), %rcx
movq %rcx, -0x30(%rbp)
jmp 0x52d7
movq $0x0, -0x30(%rbp)
movq (%rax), %r13
movq 0x3cef(%rip), %rax      # 0x8fd0
movq (%rax), %r12
movq %r13, %rbx
testq %r15, %r15
je 0x531d
leaq 0x1483(%rip), %rsi      # 0x6776
movq %r15, %rdi
callq 0x1110
movq %r13, %rbx
testl %eax, %eax
je 0x531d
leaq 0xdc5(%rip), %rsi       # 0x60ce
movq %r15, %rdi
callq 0x1180
movq %rax, %rbx
testq %rax, %rax
je 0x541b
testq %r14, %r14
je 0x5350
leaq 0x144d(%rip), %rsi      # 0x6776
movq %r14, %rdi
callq 0x1110
testl %eax, %eax
je 0x5350
leaq 0xd92(%rip), %rsi       # 0x60ce
movq %r14, %rdi
callq 0x1180
movq %rax, %r13
testq %rax, %rax
je 0x5423
movq -0x30(%rbp), %r14
testq %r14, %r14
je 0x5374
leaq 0x1418(%rip), %rsi      # 0x6778
movq %r14, %rdi
callq 0x1180
movq %rax, %r12
testq %rax, %rax
je 0x5413
movq -0x50(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x23cd
movq -0x48(%rbp), %r15
movq %r15, %rdi
movq %r13, -0x38(%rbp)
movq %r13, %rsi
callq 0x23cd
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %r13
movq -0x40(%rbp), %rbx
movq %rbx, %rdx
callq 0x39ab
movq %rbx, %rdi
movq %r12, -0x30(%rbp)
movq %r12, %rsi
callq 0x22b2
movq %r14, %rdi
callq 0x2212
movq %r15, %rdi
callq 0x2212
movq %rbx, %rdi
callq 0x2212
movq 0x3bf7(%rip), %r14      # 0x8fd0
cmpq (%r14), %r13
je 0x53e6
movq %r13, %rdi
callq 0x1090
movq -0x38(%rbp), %rdi
cmpq (%r14), %rdi
je 0x53f4
callq 0x1090
movq -0x30(%rbp), %rdi
cmpq (%r14), %rdi
je 0x5402
callq 0x1090
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x130b
movq %r15, %rdi
callq 0x12bd
movq %r14, %rdi
callq 0x12e4