// File: /workspace/github_c_makefile_star2_O3/c0stya[P]fslib/src/compose.c
// Function: match_arcs
void match_arcs(    
                    const struct _fst * fst_a,
                    const struct _fst * fst_b,
                    const struct _spair * pair,
                    struct _sr * sr,
                    struct _queue * mq)
{
    struct _state * state_a = &fst_a->states[pair->a];
    struct _state * state_b = &fst_b->states[pair->b];
    
    int osort = fst_a->flags & OSORT;
    int isort = fst_b->flags & ISORT;

    size_t asize = sizeof(struct _arc);

    arc_t m = state_a->n_arcs + 1;
    arc_t n = state_b->n_arcs + 1;
    
    struct _arc * arcs_a = malloc(asize * m);
    struct _arc * arcs_b = malloc(asize * n);

    memcpy(arcs_a + 1, state_a->arcs, asize * (m-1));
    memcpy(arcs_b + 1, state_b->arcs, asize * (n-1));

    struct _arc loop_arc_a = { 
            .state = pair->a, 
            .ilabel = EPS,
            .olabel = EPS,
            .weight = sr->one 
    };

    struct _arc loop_arc_b = { 
            .state = pair->b, 
            .ilabel = EPS,
            .olabel = EPS,
            .weight = sr->one 
    };

    arcs_a[0] = loop_arc_a;
    arcs_b[0] = loop_arc_b;

    if (isort && osort)
        match_full_sorted(arcs_a, arcs_b, m, n, mq);
    else
        if (isort || osort) {
            if (isort) {
                match_half_sorted(arcs_a, arcs_b, m, n, mq);
            } else {
                match_half_sorted_rev(arcs_a, arcs_b, m, n, mq);
            }
        } else {
            match_unsorted(arcs_a, arcs_b, m, n, mq);
        }

    free(arcs_a);
    free(arcs_b);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, -0x48(%rbp)
movq %rcx, -0x80(%rbp)
movq 0x10(%rdi), %r8
movq %r8, -0x50(%rbp)
movl (%rdx), %ecx
movq %rcx, -0x70(%rbp)
movl 0x4(%rdx), %eax
movq %rax, -0x78(%rbp)
leaq (%rcx,%rcx,2), %r9
movq %r9, -0x58(%rbp)
movq 0x10(%rsi), %rcx
movq %rcx, -0x68(%rbp)
leaq (%rax,%rax,2), %rdx
movq %rdx, -0x60(%rbp)
movb 0xd(%rdi), %r13b
andb $0x2, %r13b
movb 0xd(%rsi), %al
movb %al, -0x29(%rbp)
movl (%r8,%r9,8), %r12d
leal 0x1(%r12), %edi
movl (%rcx,%rdx,8), %ebx
movq %rdi, -0x40(%rbp)
shlq $0x4, %rdi
leal 0x1(%rbx), %r15d
callq 0x1160
movq %rax, %r14
movq %r15, -0x38(%rbp)
movq %r15, %rdi
shlq $0x4, %rdi
callq 0x1160
movq %rax, %r15
leaq 0x10(%r14), %rdi
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x10(%rcx,%rax,8), %rsi
shlq $0x4, %r12
movq %r12, %rdx
callq 0x1150
leaq 0x10(%r15), %rdi
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rsi
shlq $0x4, %rbx
movq %rbx, %rdx
callq 0x1150
movb -0x29(%rbp), %sil
movq -0x80(%rbp), %rax
movss 0x14(%rax), %xmm0
movq -0x70(%rbp), %rax
movl %eax, (%r14)
movss %xmm0, 0x4(%r14)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq -0x78(%rbp), %rcx
movl %ecx, (%r15)
movss %xmm0, 0x4(%r15)
movq %rax, 0x8(%r15)
movl %r13d, %eax
shrb %al
andb %sil, %al
cmpb $0x1, %al
jne 0x397b
movq %r14, %rdi
movq %r15, %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %r8
callq 0x440e
jmp 0x39b5
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %r8
movl %esi, %eax
andb $0x1, %al
movq %r14, %rdi
orb %r13b, %al
je 0x39a3
testb $0x1, %sil
je 0x39ad
movq %r15, %rsi
callq 0x4144
jmp 0x39b5
movq %r15, %rsi
callq 0x4084
jmp 0x39b5
movq %r15, %rsi
callq 0x42b6
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1030