// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: maxFlow(unsigned long, unsigned long, min_cut_t*)
uint64_t maxFlow(uint64_t src, uint64_t dest, min_cut_t* x)
{
    double flow = 0, max_flow = 0;
    uint64_t v, u;
    hc_edge *p;

    while (bfs_flow(src, dest, x, NULL))
    {
        kdq_clear(x->q);
        flow = DBL_MAX;
        for (v = dest; v != src; v = x->parent.a[v])
        {
            flow = MIN(flow, x->p_weight.a[v]);
        }

        /*******************************for debug************************************/
        // if(src == 26818) fprintf(stderr, "***********flow: %f*********\n", flow);
        /*******************************for debug************************************/

        for (v = dest; v != src; v = x->parent.a[v])
        {
            u = x->parent.a[v];
            p = get_rGraph_edge(x, u, v);

            /*******************************for debug************************************/
            // if(src == 26818) fprintf(stderr, "utg%.6lul (%f)\n", u+1, p->weight);
            /*******************************for debug************************************/

            p->weight -= flow;
            p = get_rGraph_edge(x, v, u);
            p->weight += flow;
            x->rGraphSet.a[u] = x->rGraphSet.a[v] = 1;
        }

        max_flow += flow;
    }
    
    return (max_flow != 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %r12d, %r12d
xorl %ecx, %ecx
callq 0x147c19
testq %rax, %rax
je 0x1482db
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movabsq $-0x400000000000000, %r12 # imm = 0xFC00000000000000
movb $0x1, %bpl
movq 0xf8(%rbx), %rax
andq %r12, (%rax)
movq 0xf8(%rbx), %rax
movq $0x0, 0x8(%rax)
movsd 0xe944b(%rip), %xmm3    # 0x231610
cmpq %r15, %r14
je 0x14829a
movq 0x110(%rbx), %rax
movq 0x128(%rbx), %rcx
movsd 0xe942c(%rip), %xmm3    # 0x231610
movq %r14, %rdx
movapd %xmm3, %xmm0
movsd (%rcx,%rdx,8), %xmm1
cmplesd %xmm1, %xmm0
movapd %xmm0, %xmm2
andnpd %xmm1, %xmm2
andpd %xmm3, %xmm0
orpd %xmm2, %xmm0
movapd %xmm0, %xmm3
movl (%rax,%rdx,4), %edx
cmpq %r15, %rdx
jne 0x1481eb
cmpq %r15, %r14
je 0x14829a
movq 0x110(%rbx), %rax
movq %r14, %r12
movapd %xmm3, 0x10(%rsp)
movl (%rax,%r12,4), %r13d
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x147100
movsd (%rax), %xmm0
subsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x147100
movapd 0x10(%rsp), %xmm3
movsd (%rax), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, (%rax)
movq 0xa8(%rbx), %rax
movb %bpl, (%rax,%r12)
movq 0xa8(%rbx), %rax
movb %bpl, (%rax,%r13)
movq 0x110(%rbx), %rax
movl (%rax,%r12,4), %r12d
cmpq %r15, %r12
jne 0x148224
movabsq $-0x400000000000000, %r12 # imm = 0xFC00000000000000
movsd 0x8(%rsp), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x147c19
testq %rax, %rax
jne 0x1481a4
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
cmpneqsd %xmm0, %xmm1
movq %xmm1, %r12
andl $0x1, %r12d
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq