// File: /workspace/github_c_makefile_star2_O2/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, -0x78(%rbp)
movl 0x4(%rdx), %eax
movq %rax, -0x70(%rbp)
imulq $0x18, %rcx, %r9
movq %r9, -0x58(%rbp)
movq 0x10(%rsi), %rcx
movq %rcx, -0x68(%rbp)
imulq $0x18, %rax, %rdx
movq %rdx, -0x60(%rbp)
movb 0xd(%rdi), %r13b
andb $0x2, %r13b
movb 0xd(%rsi), %al
movb %al, -0x29(%rbp)
movl (%r8,%r9), %r12d
leal 0x1(%r12), %edi
movl (%rcx,%rdx), %ebx
movq %rdi, -0x40(%rbp)
shlq $0x4, %rdi
leal 0x1(%rbx), %r15d
callq 0x1150
movq %rax, %r14
movq %r15, -0x38(%rbp)
movq %r15, %rdi
shlq $0x4, %rdi
callq 0x1150
movq %rax, %r15
leaq 0x10(%r14), %rdi
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x10(%rcx,%rax), %rsi
shlq $0x4, %r12
movq %r12, %rdx
callq 0x1140
leaq 0x10(%r15), %rdi
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
movq 0x10(%rax,%rcx), %rsi
shlq $0x4, %rbx
movq %rbx, %rdx
callq 0x1140
movb -0x29(%rbp), %sil
movq -0x80(%rbp), %rax
movss 0x14(%rax), %xmm0
movq -0x78(%rbp), %rax
movl %eax, (%r14)
movss %xmm0, 0x4(%r14)
andq $0x0, 0x8(%r14)
movq -0x70(%rbp), %rax
movl %eax, (%r15)
movss %xmm0, 0x4(%r15)
andq $0x0, 0x8(%r15)
movl %r13d, %eax
shrb %al
andb %sil, %al
cmpb $0x1, %al
jne 0x36b7
movq %r14, %rdi
movq %r15, %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %r8
callq 0x4072
jmp 0x36f1
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 0x36df
testb $0x1, %sil
je 0x36e9
movq %r15, %rsi
callq 0x3e0d
jmp 0x36f1
movq %r15, %rsi
callq 0x3d38
jmp 0x36f1
movq %r15, %rsi
callq 0x3f46
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