// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/path.c
// Function: find_source_vtx
static uint64_t find_source_vtx(asmg_t *g, int use_max_scc)
{
    uint64_t i, s, n_seg;
    s = UINT64_MAX;
    
    if (!use_max_scc) {
        // naively select the longest sequence
        uint64_t m_len, len;
        n_seg = g->n_vtx;
        m_len = 0;
        for (i = 0; i < n_seg; ++i) {
            if (g->vtx[i].del) continue;
            len = g->vtx[i].len * g->vtx[i].cov;
            if (m_len < len) {
                m_len = len;
                s = i;
            }
        }
    } else {
        // select the largest sequence from the largest SCC
        int c, m_c, n_scc, *scc;
        uint64_t m_len, len, *lens;
        n_seg = g->n_vtx * 2;

        MYMALLOC(scc, n_seg);
        // find strongly connected components
        n_scc = asmg_tarjans_scc(g, scc);
        
        MYCALLOC(lens, n_scc);
        // find larges SCC
        for (i = 0; i < n_seg; ++i) {
            if (scc[i] < 0) continue; // deleted vtx
            if (scc[i] != scc[i^1] || (i & 1))
                lens[scc[i]] += g->vtx[i>>1].len * g->vtx[i>>1].cov;
        }
        m_len = 0;
        m_c = -1;
        for (c = 0; c < n_scc; ++c) {
            if (m_len < lens[c]) {
                m_len = lens[c];
                m_c = c;
            }
        }
        if (m_c >= 0) {
            m_len = 0;
            for (i = 0; i < n_seg; ++i) {
                if (scc[i] != m_c) continue;
                len = g->vtx[i>>1].len * g->vtx[i>>1].cov;
                if (m_len < len) {
                    m_len = len;
                    s = i;
                }
            }
            s >>= 1;
        }
        free(scc);
        free(lens);
    }

    return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq $-0x1, -0x20(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x7a63
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x7a5e
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
shrl $0x1e, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x79fa
jmp 0x7a4d
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
imulq $0x28, -0x18(%rbp), %rdx
addq %rdx, %rcx
movl 0x20(%rcx), %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movl %ecx, %ecx
imulq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x7a4b
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x7a4d
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x79cc
jmp 0x7c7a
movq -0x8(%rbp), %rax
movq (%rax), %rax
shlq %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
shlq $0x2, %rdi
callq 0x22f0
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x1c710
movl %eax, -0x44(%rbp)
movslq -0x44(%rbp), %rdi
movl $0x8, %esi
callq 0x2240
movq %rax, -0x68(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x7b60
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x7acd
jmp 0x7b4f
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rdx
xorq $0x1, %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0x7af7
movq -0x18(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x7b4d
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, %eax
imulq %rax, %rdx
movq -0x68(%rbp), %rax
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x7b4f
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x7aac
movq $0x0, -0x58(%rbp)
movl $0xffffffff, -0x40(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x7bb3
movq -0x58(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
jae 0x7ba6
movq -0x68(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x7ba8
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x7b76
cmpl $0x0, -0x40(%rbp)
jl 0x7c68
movq $0x0, -0x58(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x7c5d
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x40(%rbp), %eax
je 0x7bed
jmp 0x7c4c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
shrq %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
shrq %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl 0x20(%rcx), %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movl %ecx, %ecx
imulq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x7c4a
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x7c4c
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x7bcd
movq -0x20(%rbp), %rax
shrq %rax
movq %rax, -0x20(%rbp)
movq -0x50(%rbp), %rdi
callq 0x2060
movq -0x68(%rbp), %rdi
callq 0x2060
movq -0x20(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)