// File: /workspace/github_c_makefile_star2_O0/richarddurbin[P]hash10x/moshasm.c
// Function: invBuild
static void invBuild (Readset *rs) /* run this after ms->depth built from reads->hit[] */
{
  Moshset *ms = rs->ms ;
  U32 i, j ;
  U64 offset = 0 ;
  rs->inv = new0 (ms->max+1, U32*) ;
  rs->invSpace = new (rs->totHit, U32) ;
  for (i = 1 ; i <= ms->max ; ++i)
    if (ms->depth[i] && ms->depth[i] < U16MAX)
      { rs->inv[i] = rs->invSpace + offset ;
	offset += ms->depth[i] ;
      }
  Read *read = arrp(rs->reads,1,Read) ;
  for (i = 1 ; i < arrayMax(rs->reads) ; ++i, ++read)
    { for (j = 0 ; j < 4 ; ++j) read->nCopy[j] = 0 ; /* build nCopy here in case msCopy changed */
      U32 *x = read->hit ;
      for (j = 0 ; j < read->nHit ; ++j, ++x)
	{ U32 y = *x & TOPMASK ;
	  ++read->nCopy[msCopy(rs->ms,y)] ;
	  if (ms->depth[y] < U16MAX) *rs->inv[y]++ = i ; /* this is the inverse map */
	}
    }
  offset = 0 ; /* now recreate rs->inv because we moved the pointers */
  for (i = 1 ; i <= ms->max ; ++i)
    if (ms->depth[i] && ms->depth[i] < U16MAX)
      { rs->inv[i] = rs->invSpace + offset ;
	offset += ms->depth[i] ;
      }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
movl $0x8, %esi
callq 0xa230
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
shlq $0x2, %rdi
callq 0xa1e0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x40(%rcx), %eax
ja 0x19c1
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x14(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
je 0x19b4
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x14(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jge 0x19b4
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x20(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x14(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x14(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x19b6
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1945
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
movl 0x14(%rcx), %ecx
shll $0x0, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jae 0x1af2
movl $0x0, -0x18(%rbp)
cmpl $0x4, -0x18(%rbp)
jae 0x1a27
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
movl $0x0, 0x24(%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1a07
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x1ad6
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl -0x34(%rbp), %esi
callq 0x2720
movl %eax, %ecx
movq -0x40(%rbp), %rax
movslq %ecx, %rcx
movl 0x24(%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, 0x24(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x34(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jge 0x1aba
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdx
movl -0x34(%rbp), %eax
movl %eax, %esi
movq (%rdx,%rsi,8), %rax
movq %rax, %rdi
addq $0x4, %rdi
movq %rdi, (%rdx,%rsi,8)
movl %ecx, (%rax)
jmp 0x1abc
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
jmp 0x1a3a
jmp 0x1ad8
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x28(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x28(%rbp)
jmp 0x19ec
movq $0x0, -0x20(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x40(%rcx), %eax
ja 0x1b7d
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x14(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0x0, %eax
je 0x1b70
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x14(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jge 0x1b70
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x20(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x14(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x14(%rbp), %ecx
movzwl (%rax,%rcx,2), %eax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x1b72
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1b01
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)