// File: /workspace/github_cpp_makefile_star2_O2/canzarlab[P]Trajan/src/match.cpp
// Function: bipartite_aux(array2d&, std::vector<int, std::allocator<int>>&)
int bipartite_aux(array2d& D, vector<int>& sol)
{
    // complexity of bipartite is O(n2^m) so make sure m < n
    bool transposed = false;
    if (D.n < D.m)
    {
        D = D.transpose();
        transposed = true;
    }

    // dp table for the matching
    array2d bdp(D.n, 1 << D.m), pdp(D.n, 1 << D.m, -1);

    // compute the matching
    int weight = bipartite(D, bdp, pdp, 0, fm(D.m));

    // store the matching
    // note: -1 is unmatched
    sol.resize(D.n, -1);
    mask m = fm(D.m);
    for (int k = 0; k < D.n && m > 0; ++k)
    {
        sol[k] = pdp(k, m);
        if (pdp(k, m) != -1)
            m ^= in(pdp(k, m));
    }

    // transpose the matching back
    if (transposed)
    {
        vector<int> zol(D.m, -1);
        for (int i = 0; i < D.n; ++i)
            if (sol[i] != -1)
                zol[sol[i]] = i;
        swap(sol, zol);
    }
    return weight;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl (%rdi), %r12d
movl 0x4(%rdi), %r13d
movl %r13d, %ecx
movl %r12d, %esi
cmpl %r13d, %r12d
jge 0x3ada
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x5100
movq %r14, %rdi
movq %r15, %rsi
callq 0x5162
leaq 0x38(%rsp), %rdi
callq 0x65ec
movl (%r14), %esi
movl 0x4(%r14), %ecx
pushq $0x1
popq %rbp
movl %ebp, %edx
shll %cl, %edx
leaq 0x30(%rsp), %rdi
movl $0x80000000, %ecx       # imm = 0x80000000
callq 0x517e
movl (%r14), %esi
movb 0x4(%r14), %cl
shll %cl, %ebp
leaq 0x10(%rsp), %rdi
pushq $-0x1
popq %rcx
movl %ebp, %edx
callq 0x517e
movb 0x4(%r14), %cl
pushq $-0x1
popq %r15
movq %r15, %r8
shlq %cl, %r8
notq %r8
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x396f
movl %eax, %ebp
movslq (%r14), %rsi
leaq 0x50(%rsp), %rdx
orl $-0x1, (%rdx)
movq %rbx, %rdi
callq 0x51ca
movb 0x4(%r14), %cl
shlq %cl, %r15
notq %r15
leaq 0x18(%rsp), %rdi
movq (%rdi), %rax
movq (%rbx), %rdx
xorl %esi, %esi
pushq $0x1
popq %r9
movslq (%r14), %rcx
cmpq %rcx, %rsi
jge 0x3ba7
testq %r15, %r15
je 0x3ba7
movl 0x14(%rsp), %ecx
imull %esi, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
movl %ecx, (%rdx,%rsi,4)
movl 0x14(%rsp), %ecx
imull %esi, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
movq %r9, %r8
shlq %cl, %r8
cmpl $-0x1, %ecx
movl $0x0, %ecx
cmovneq %r8, %rcx
xorq %rcx, %r15
incq %rsi
jmp 0x3b5d
cmpl %r13d, %r12d
jge 0x3c17
movq %rdi, %r15
movslq 0x4(%r14), %rsi
leaq 0xc(%rsp), %rdx
orl $-0x1, (%rdx)
leaq 0x50(%rsp), %rdi
leaq 0xb(%rsp), %rcx
callq 0x51fe
movq (%rbx), %rax
movq 0x50(%rsp), %rcx
xorl %edx, %edx
movslq (%r14), %rsi
cmpq %rsi, %rdx
jge 0x3bee
movslq (%rax,%rdx,4), %rsi
cmpq $-0x1, %rsi
je 0x3be9
movl %edx, (%rcx,%rsi,4)
incq %rdx
jmp 0x3bd4
movq 0x10(%rbx), %rax
leaq 0x50(%rsp), %rdi
movaps (%rdi), %xmm0
movq 0x10(%rdi), %rcx
movq %rcx, 0x10(%rbx)
movups (%rbx), %xmm1
movups %xmm0, (%rbx)
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
callq 0x65ec
movq %r15, %rdi
callq 0x65ec
leaq 0x38(%rsp), %rdi
callq 0x65ec
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3c39
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x65ec
jmp 0x3c4b
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x65ec
movq %rbx, %rdi
callq 0x33e0