// File: chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: get_max_index(asg_arc_t_offset*, int*, unsigned char*, long long, long long, long long)
inline long long get_max_index(asg_arc_t_offset* x, int32_t* Scores, uint8_t* Flag, long long n,
long long x_readLen, long long y_readLen)
{
    long long i = 0, max_result = -1, max_i = -1, min_xLen = x_readLen * 2 + 2, x_off, y_off, tmp_xLen;
    for (i = 0; i < n; i++)
    {
        if(Flag[i] != 0) continue;
        x_off = (long long)(x[i].Off>>32);
        y_off = (long long)((uint32_t)x[i].Off);
        if(Scores[i] > max_result)
        {
            max_result = Scores[i];
            max_i = i;
            min_xLen = get_hap_overlapLen(x_off, x_off, x_readLen, y_off, y_off, y_readLen, 
            NULL, NULL, NULL, NULL);
        }
        else if(Scores[i] == max_result)
        {
            tmp_xLen = get_hap_overlapLen(x_off, x_off, x_readLen, y_off, y_off, y_readLen, 
            NULL, NULL, NULL, NULL);

            if(tmp_xLen < min_xLen)
            {
                max_result = Scores[i];
                max_i = i;
                min_xLen = tmp_xLen;
            }
        }
    }

    return max_i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $-0x1, -0x40(%rbp)
movq $-0x1, -0x48(%rbp)
movq -0x28(%rbp), %rax
shlq %rax
addq $0x2, %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x1861c2
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x186086
jmp 0x1861b1
movq -0x8(%rbp), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, %eax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
cmpq -0x40(%rbp), %rax
jle 0x186129
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x58(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x60(%rbp), %r8
movq -0x30(%rbp), %r9
xorl %eax, %eax
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
callq 0x185700
movq %rax, -0x50(%rbp)
jmp 0x1861af
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
cmpq -0x40(%rbp), %rax
jne 0x1861ad
movq -0x58(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x60(%rbp), %r8
movq -0x30(%rbp), %r9
xorl %eax, %eax
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
callq 0x185700
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x50(%rbp), %rax
jge 0x1861ab
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x1861ad
jmp 0x1861af
jmp 0x1861b1
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x186062
movq -0x48(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nop