// File: /workspace/github_c_makefile_star2_O0/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
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movzbl 0xd(%rax), %eax
andl $0x2, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movzbl 0xd(%rax), %eax
andl $0x1, %eax
movl %eax, -0x40(%rbp)
movq $0x10, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movl -0x4c(%rbp), %eax
imulq %rax, %rdi
callq 0x1120
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rdi
movl -0x50(%rbp), %eax
imulq %rax, %rdi
callq 0x1120
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
addq $0x10, %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x48(%rbp), %rdx
movl -0x4c(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
imulq %rax, %rdx
callq 0x1110
movq -0x60(%rbp), %rdi
addq $0x10, %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x48(%rbp), %rdx
movl -0x50(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
imulq %rax, %rdx
callq 0x1110
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x70(%rbp)
movq -0x20(%rbp), %rax
movss 0x14(%rax), %xmm0
movss %xmm0, -0x6c(%rbp)
movl $0x0, -0x68(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x80(%rbp)
movq -0x20(%rbp), %rax
movss 0x14(%rax), %xmm0
movss %xmm0, -0x7c(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x74(%rbp)
movq -0x58(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rcx, (%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x60(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x8(%rax)
cmpl $0x0, -0x40(%rbp)
je 0x4b56
cmpl $0x0, -0x3c(%rbp)
je 0x4b56
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x4c(%rbp), %edx
movl -0x50(%rbp), %ecx
movq -0x28(%rbp), %r8
callq 0x59b0
jmp 0x4bb3
cmpl $0x0, -0x40(%rbp)
jne 0x4b62
cmpl $0x0, -0x3c(%rbp)
je 0x4b9a
cmpl $0x0, -0x40(%rbp)
je 0x4b81
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x4c(%rbp), %edx
movl -0x50(%rbp), %ecx
movq -0x28(%rbp), %r8
callq 0x55b0
jmp 0x4b98
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x4c(%rbp), %edx
movl -0x50(%rbp), %ecx
movq -0x28(%rbp), %r8
callq 0x57b0
jmp 0x4bb1
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x4c(%rbp), %edx
movl -0x50(%rbp), %ecx
movq -0x28(%rbp), %r8
callq 0x5460
jmp 0x4bb3
movq -0x58(%rbp), %rdi
callq 0x1030
movq -0x60(%rbp), %rdi
callq 0x1030
addq $0x80, %rsp
popq %rbp
retq
nop