// File: /workspace/github_c_makefile_star2_O0/c0stya[P]fslib/src/match.c
// Function: match_half_sorted_rev
void match_half_sorted_rev(
                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 < N; ++i) {
        l = 0;
        h = M-1;
        while ( l <= h ) {
            m = (l + h) >> 1;
            if (b[i].ilabel > a[m].olabel) l = m + 1; 
            else  
                if (b[i].ilabel < a[m].olabel) {
                    if (m == 0) break;  // sentinel for unsigned index h
                    h = m - 1;
                }
                else {
                    ll = hh = m;
                    
                    while ((ll > l) && (b[i].ilabel == a[ll-1].olabel)) --ll;
                    while ((hh < h) && (b[i].ilabel == a[hh+1].olabel)) ++hh;

                    while (ll <= hh ) {
                        mi.a = a[ll];
                        mi.b = b[i]; 
                        if (_match(a, b, ll, i))
                            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 -0x18(%rbp), %eax
jae 0x59a7
movl $0x0, -0x24(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
ja 0x5997
movl -0x24(%rbp), %eax
addl -0x28(%rbp), %eax
shrl %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movl -0x38(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jbe 0x5836
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x5992
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movl -0x38(%rbp), %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
jae 0x5873
cmpl $0x0, -0x38(%rbp)
jne 0x5865
jmp 0x5997
movl -0x38(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x5990
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 0x58b6
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movl %edx, %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
sete %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x58bf
jmp 0x58ca
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x587c
jmp 0x58cc
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x28(%rbp), %ecx
movb %al, -0x5a(%rbp)
jae 0x5906
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
movl -0x30(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpl 0xc(%rcx), %eax
sete %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
testb $0x1, %al
jne 0x590f
jmp 0x591a
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x58cc
jmp 0x591c
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
ja 0x598e
movq -0x8(%rbp), %rax
movl -0x2c(%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 -0x34(%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 -0x2c(%rbp), %edx
movl -0x34(%rbp), %ecx
callq 0x5550
cmpl $0x0, %eax
je 0x5983
movq -0x20(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3b00
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x591c
jmp 0x5997
jmp 0x5992
jmp 0x57ed
jmp 0x5999
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x57d1
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)