// File: /workspace/github_cpp_makefile_star2_O1/Kingsford-Group[P]ghost2/include/hungarian.hpp
// Function: kuhn_findPrime(float**, signed char**, signed char*, signed char*, unsigned long, unsigned long)
size_t* kuhn_findPrime(cell** t, byte** marks, boolean* rowCovered, boolean* colCovered, size_t n, size_t m)
{
    size_t i, j;
    BitSet zeroes = new_BitSet(n * m);
    
    for (i = 0; i < n; i++)
        if (!*(rowCovered + i))
	    for (j = 0; j < m; j++)
	        if ((!*(colCovered + j)) && (*(*(t + i) + j) == 0))
		  BitSet_set(zeroes, i * m + j);
    
    ssize_t p;
    size_t row, col;
    boolean markInRow;
    
    for (;;)
    {
        p = BitSet_any(zeroes);
	if (p < 0)
        {
	    delete[](zeroes.limbs);
	    delete(zeroes.first);
	    delete[](zeroes.next);
	    delete[](zeroes.prev);
	    return null;
	}
	
	row = (size_t)p / m;
	col = (size_t)p % m;
	
	*(*(marks + row) + col) = PRIME;
	
	markInRow = false;
	for (j = 0; j < m; j++)
	    if (*(*(marks + row) + j) == MARKED)
	    {
		markInRow = true;
		col = j;
	    }
	
	if (markInRow)
	{
	    *(rowCovered + row) = true;
	    *(colCovered + col) = false;
	    
	    for (i = 0; i < n; i++)
	        if ((*(*(t + i) + col) == 0) && (row != i))
		{
		    if ((!*(rowCovered + i)) && (!*(colCovered + col)))
		        BitSet_set(zeroes, i * m + col);
		    else
		        BitSet_unset(zeroes, i * m + col);
		}
	    
	    for (j = 0; j < m; j++)
	        if ((*(*(t + row) + j) == 0) && (col != j))
		{
		    if ((!*(rowCovered + row)) && (!*(colCovered + j)))
		        BitSet_set(zeroes, row * m + j);
		    else
		        BitSet_unset(zeroes, row * m + j);
		}
	    
	    if ((!*(rowCovered + row)) && (!*(colCovered + col)))
	        BitSet_set(zeroes, row * m + col);
	    else
	        BitSet_unset(zeroes, row * m + col);
	}
	else
	{
	    size_t* rc = new size_t[2];
	    *rc = row;
	    *(rc + 1) = col;
	    delete[](zeroes.limbs);
	    delete(zeroes.first);
	    delete[](zeroes.next);
	    delete[](zeroes.prev);
	    return rc;
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %r12
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, 0x18(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdi, 0x38(%rsp)
movq %r9, %rsi
imulq %r8, %rsi
leaq 0x40(%rsp), %rdi
callq 0x175e1
movq %r14, %r11
movq %rbx, %r10
testq %rbx, %rbx
movq %rbx, 0x28(%rsp)
movq %r14, 0x30(%rsp)
je 0x16f3d
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rsi
xorl %edi, %edi
xorps %xmm0, %xmm0
xorl %r8d, %r8d
testq %r12, %r12
sete %r9b
movq 0x18(%rsp), %r10
cmpb $0x0, (%r10,%r8)
setne %r10b
orb %r9b, %r10b
je 0x16ec9
incq %r8
addq %r12, %rdi
movq 0x28(%rsp), %r10
cmpq %r10, %r8
jne 0x16e9d
jmp 0x16f3d
xorl %r9d, %r9d
cmpb $0x0, (%r11,%r9)
je 0x16edd
incq %r9
cmpq %r9, %r12
jne 0x16ecc
jmp 0x16eb7
movq 0x38(%rsp), %r10
movq (%r10,%r8,8), %r10
movss (%r10,%r9,4), %xmm1
ucomiss %xmm0, %xmm1
jne 0x16ed3
jp 0x16ed3
leaq (%rdi,%r9), %r11
movq %r11, %r10
shrq $0x6, %r10
movq (%rax,%r10,8), %rbx
movq %rbx, %r14
btsq %r11, %r14
movq 0x30(%rsp), %r11
movq %r14, (%rax,%r10,8)
testq %rbx, %rbx
jne 0x16ed3
leaq 0x1(%r10), %r11
movq (%rcx), %rbx
movq %r11, (%rdx,%rbx,8)
movq $0x0, 0x8(%rdx,%r10,8)
movq (%rcx), %rbx
movq %rbx, 0x8(%rsi,%r10,8)
movq %r11, (%rcx)
movq 0x30(%rsp), %r11
jmp 0x16ed3
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %r15
movq 0x50(%rsp), %r13
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x1, %r12
movq %r12, %rbx
adcq $0x0, %rbx
movl $0x1, %edi
movq 0x18(%rsp), %r9
movq %r15, 0x8(%rsp)
movq (%r15), %rbp
testq %rbp, %rbp
je 0x16fab
movq -0x8(%r14,%rbp,8), %rax
decq %rbp
movq %rax, %rdi
negq %rdi
andq %rax, %rdi
callq 0x1778e
movl $0x1, %edi
movq 0x18(%rsp), %r9
movq 0x30(%rsp), %r11
movq 0x28(%rsp), %r10
shlq $0x6, %rbp
addq %rax, %rbp
jmp 0x16fb2
movq $-0x1, %rbp
testq %rbp, %rbp
js 0x172dc
movq %rbp, %rax
xorl %edx, %edx
divq %r12
movq %rdx, %rbp
xorl %ecx, %ecx
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %rsi
movq (%rsi,%rax,8), %rdx
movb $0x2, (%rdx,%rbp)
movq (%rsi,%rax,8), %rdx
xorl %esi, %esi
cmpb $0x1, (%rdx,%rsi)
cmoveq %rsi, %rbp
movzbl %cl, %ecx
cmovel %edi, %ecx
incq %rsi
cmpq %rsi, %rbx
jne 0x16fe0
testb %cl, %cl
xorps %xmm1, %xmm1
je 0x1730e
movq 0x20(%rsp), %rcx
movb $0x1, (%r9,%rcx)
movb $0x0, (%r11,%rbp)
testq %r10, %r10
je 0x17108
movq %rbp, %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x170ce
movq 0x38(%rsp), %rsi
movq (%rsi,%rdx,8), %rsi
movss (%rsi,%rbp,4), %xmm0
ucomiss %xmm1, %xmm0
jne 0x170ce
jp 0x170ce
cmpb $0x0, (%r9,%rdx)
jne 0x17052
cmpb $0x0, (%r11,%rbp)
je 0x170b3
movq %rcx, %rsi
movq $-0x2, %rdi
rolq %cl, %rdi
shrq $0x6, %rsi
movq (%r14,%rsi,8), %r8
andq %r8, %rdi
movq %rdi, (%r14,%rsi,8)
setne %dil
testq %r8, %r8
sete %r8b
orb %dil, %r8b
jne 0x170ce
leaq 0x1(%rsi), %r8
movq 0x8(%r13,%rsi,8), %r9
movq 0x10(%rsp), %r15
movq 0x8(%r15,%rsi,8), %rdi
movq %r9, (%r13,%rdi,8)
movq %rdi, (%r15,%r9,8)
movq 0x18(%rsp), %r9
movq 0x8(%rsp), %rsi
cmpq %r8, (%rsi)
jne 0x170ce
movq 0x8(%rsp), %rsi
movq %rdi, (%rsi)
jmp 0x170ce
movq %rcx, %rsi
shrq $0x6, %rsi
movq (%r14,%rsi,8), %rdi
movq %rdi, %r8
btsq %rcx, %r8
movq %r8, (%r14,%rsi,8)
testq %rdi, %rdi
je 0x170df
incq %rdx
addq %r12, %rcx
cmpq %rdx, %r10
jne 0x1701e
jmp 0x17108
leaq 0x1(%rsi), %rdi
movq 0x8(%rsp), %r15
movq (%r15), %r8
movq %rdi, (%r13,%r8,8)
movq $0x0, 0x8(%r13,%rsi,8)
movq (%r15), %r8
movq 0x10(%rsp), %r15
movq %r8, 0x8(%r15,%rsi,8)
jmp 0x170a9
movq 0x38(%rsp), %rcx
movq 0x20(%rsp), %rdx
movq (%rcx,%rdx,8), %rdx
imulq %r12, %rax
xorl %esi, %esi
movss (%rdx,%rsi,4), %xmm0
ucomiss %xmm1, %xmm0
jne 0x171cf
jp 0x171cf
cmpq %rsi, %rbp
je 0x171cf
movq 0x20(%rsp), %rcx
cmpb $0x0, (%r9,%rcx)
jne 0x1714c
cmpb $0x0, (%r11,%rsi)
je 0x171ab
leaq (%rsi,%rax), %rcx
movq %rcx, %rdi
movq $-0x2, %r8
rolq %cl, %r8
shrq $0x6, %rdi
movq (%r14,%rdi,8), %rcx
andq %rcx, %r8
movq %r8, (%r14,%rdi,8)
setne %r8b
testq %rcx, %rcx
sete %cl
orb %r8b, %cl
jne 0x171cf
leaq 0x1(%rdi), %rcx
movq 0x8(%r13,%rdi,8), %r8
movq 0x10(%rsp), %r15
movq 0x8(%r15,%rdi,8), %rdi
movq %r8, (%r13,%rdi,8)
movq %rdi, (%r15,%r8,8)
movq 0x8(%rsp), %r8
cmpq %rcx, (%r8)
jne 0x171cf
movq 0x8(%rsp), %rcx
movq %rdi, (%rcx)
jmp 0x171cf
leaq (%rsi,%rax), %rdi
movq %rdi, %rcx
shrq $0x6, %rcx
movq (%r14,%rcx,8), %r8
movq %r8, %r9
btsq %rdi, %r9
movq %r9, (%r14,%rcx,8)
movq 0x18(%rsp), %r9
testq %r8, %r8
je 0x171dd
incq %rsi
cmpq %rsi, %rbx
jne 0x1711c
jmp 0x1720b
leaq 0x1(%rcx), %rdi
movq 0x8(%rsp), %r10
movq (%r10), %r8
movq %rdi, (%r13,%r8,8)
movq $0x0, 0x8(%r13,%rcx,8)
movq (%r10), %r8
movq 0x28(%rsp), %r10
movq 0x10(%rsp), %r15
movq %r8, 0x8(%r15,%rcx,8)
jmp 0x171a1
movq 0x20(%rsp), %rcx
cmpb $0x0, (%r9,%rcx)
jne 0x1721e
cmpb $0x0, (%r11,%rbp)
je 0x1728c
addq %rax, %rbp
movq %rbp, %rax
movq $-0x2, %rdx
movl %ebp, %ecx
rolq %cl, %rdx
shrq $0x6, %rax
movq (%r14,%rax,8), %rcx
andq %rcx, %rdx
movq %rdx, (%r14,%rax,8)
setne %dl
testq %rcx, %rcx
sete %cl
orb %dl, %cl
movq 0x8(%rsp), %r15
movl $0x1, %edi
jne 0x16f70
leaq 0x1(%rax), %rdx
movq 0x8(%r13,%rax,8), %rsi
movq 0x10(%rsp), %rdi
movq 0x8(%rdi,%rax,8), %rcx
movq %rsi, (%r13,%rcx,8)
movq %rcx, (%rdi,%rsi,8)
movl $0x1, %edi
cmpq %rdx, (%r15)
jne 0x16f70
movq %rcx, (%r15)
jmp 0x16f70
addq %rax, %rbp
movq %rbp, %rax
shrq $0x6, %rax
movq (%r14,%rax,8), %rcx
movq %rcx, %rdx
btsq %rbp, %rdx
movq %rdx, (%r14,%rax,8)
testq %rcx, %rcx
movq 0x8(%rsp), %r15
movl $0x1, %edi
jne 0x16f70
leaq 0x1(%rax), %rcx
movq (%r15), %rdx
movq %rcx, (%r13,%rdx,8)
movq $0x0, 0x8(%r13,%rax,8)
movq (%r15), %rdx
movq 0x10(%rsp), %rsi
movq %rdx, 0x8(%rsi,%rax,8)
jmp 0x17284
testq %r14, %r14
je 0x172e9
movq %r14, %rdi
callq 0xd710
movl $0x8, %esi
movq %r15, %rdi
callq 0xd550
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x17305
callq 0xd710
movq 0x50(%rsp), %rdi
xorl %ebx, %ebx
jmp 0x17357
movl $0x10, %edi
callq 0xd040
movq %rax, %rbx
movq 0x20(%rsp), %rax
movq %rax, (%rbx)
movq %rbp, 0x8(%rbx)
testq %r14, %r14
je 0x17334
movq %r14, %rdi
callq 0xd710
movl $0x8, %esi
movq 0x8(%rsp), %rdi
callq 0xd550
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x17352
callq 0xd710
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x17361
callq 0xd710
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq