// File: /workspace/github_c_makefile_star2_O0/c0stya[P]fslib/src/match.c
// Function: match_half_sorted
void match_half_sorted(
                struct _arc * a,
                struct _arc * b,
                arc_t M,
                arc_t N,
                struct _queue * q) 
{
    arc_t l, h, ll, hh;
    arc_t i,m;

    struct _match_item mi;

    for (i=0; i < M; ++i) {
        l = 0;
        h = N-1;
        while ( l <= h ) {
            m = (l + h) >> 1;
            if (a[i].olabel > b[m].ilabel) l = m + 1; 
            else  
                if (a[i].olabel < b[m].ilabel) {
                    if (m == 0) break;  // sentinel for unsigned index h
                    h = m - 1;
                }
                else {
                    ll = hh = m;
                    
                    while ((ll > l) && (a[i].olabel == b[ll-1].ilabel)) --ll;
                    while ((hh < h) && (a[i].olabel == b[hh+1].ilabel)) ++hh;

                    while (ll <= hh ) {
                        mi.a = a[i]; 
                        mi.b = b[ll];
                        if (_match(a, b, i, ll))
                            queue_enque(q, &mi);
                        ++ll;
                    }
                    break;
                }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x57a7
movl $0x0, -0x24(%rbp)
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
ja 0x5797
movl -0x24(%rbp), %eax
addl -0x28(%rbp), %eax
shrl %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
movl -0x38(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jbe 0x5636
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5792
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
movl -0x38(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jae 0x5673
cmpl $0x0, -0x38(%rbp)
jne 0x5665
jmp 0x5797
movl -0x38(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x5790
movl -0x38(%rbp), %eax
movl %eax, -0x30(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x24(%rbp), %ecx
movb %al, -0x59(%rbp)
jbe 0x56b6
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movl %edx, %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
sete %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x56bf
jmp 0x56ca
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x567c
jmp 0x56cc
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x28(%rbp), %ecx
movb %al, -0x5a(%rbp)
jae 0x5706
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
movl -0x30(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
sete %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
testb $0x1, %al
jne 0x570f
jmp 0x571a
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x56cc
jmp 0x571c
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
ja 0x578e
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x34(%rbp), %edx
movl -0x2c(%rbp), %ecx
callq 0x5550
cmpl $0x0, %eax
je 0x5783
movq -0x20(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3b00
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x571c
jmp 0x5797
jmp 0x5792
jmp 0x55ed
jmp 0x5799
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x55d1
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)