// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, %al
callq 0x2740
movq %rax, -0x18(%rbp)
movb $0x0, %al
callq 0x2740
movq %rax, -0x20(%rbp)
movb $0x0, %al
callq 0x2740
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq 0x40a2(%rip), %rax      # 0xafd8
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq 0x4094(%rip), %rax      # 0xafd8
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq 0x407e(%rip), %rax      # 0xafd0
movq (%rax), %rax
movq %rax, -0x58(%rbp)
cmpl $0x1, -0x8(%rbp)
jle 0x6f6b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
cmpl $0x2, -0x8(%rbp)
jle 0x6f7d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpl $0x3, -0x8(%rbp)
jle 0x6f8f
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x6fed
movq -0x30(%rbp), %rdi
leaq 0x17de(%rip), %rsi      # 0x877f
callq 0x10e0
cmpl $0x0, %eax
je 0x6fed
movq -0x30(%rbp), %rdi
leaq 0x1133(%rip), %rsi      # 0x80e9
callq 0x1150
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x6feb
movq 0x402c(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
leaq 0x10f8(%rip), %rsi      # 0x80d2
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x1180
jmp 0x6fed
cmpq $0x0, -0x38(%rbp)
je 0x704b
movq -0x38(%rbp), %rdi
leaq 0x1780(%rip), %rsi      # 0x877f
callq 0x10e0
cmpl $0x0, %eax
je 0x704b
movq -0x38(%rbp), %rdi
leaq 0x10d5(%rip), %rsi      # 0x80e9
callq 0x1150
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x7049
movq 0x3fce(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x109a(%rip), %rsi      # 0x80d2
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x1180
jmp 0x704b
cmpq $0x0, -0x40(%rbp)
je 0x7094
movq -0x40(%rbp), %rdi
leaq 0x1724(%rip), %rsi      # 0x8781
callq 0x1150
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x7092
movq 0x3f85(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
leaq 0x1051(%rip), %rsi      # 0x80d2
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x1180
jmp 0x7094
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x2bc0
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x2bc0
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x4bd0
movq -0x28(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x2a80
movq -0x18(%rbp), %rdi
callq 0x2950
movq -0x20(%rbp), %rdi
callq 0x2950
movq -0x28(%rbp), %rdi
callq 0x2950
movq -0x48(%rbp), %rax
movq 0x3ede(%rip), %rcx      # 0xafd0
cmpq (%rcx), %rax
je 0x7100
movq -0x48(%rbp), %rdi
callq 0x1080
movq -0x50(%rbp), %rax
movq 0x3ec5(%rip), %rcx      # 0xafd0
cmpq (%rcx), %rax
je 0x7119
movq -0x50(%rbp), %rdi
callq 0x1080
movq -0x58(%rbp), %rax
movq 0x3eac(%rip), %rcx      # 0xafd0
cmpq (%rcx), %rax
je 0x7132
movq -0x58(%rbp), %rdi
callq 0x1080
xorl %eax, %eax
addq $0x60, %rsp
popq %rbp
retq