// File: /workspace/github_c_makefile_star2_O0/jsh58[P]Genrich/Genrich.c
// Function: subsampleSingle
void subsampleSingle(Aln* aln, int alnLen, bool first,
    uint8_t* count, float* score) {

  // insertion sort of aln scores
  float arr[*count];  // sorted array of aln scores
  int k = 0;          // count of valid alns analyzed
  for (int i = 0; i < alnLen; i++) {
    Aln* a = aln + i;
    if (! a->paired && a->first == first
        && a->score >= *score && a->chrom->save
        && ! a->chrom->skip) {

      // insert a->score into array
      int j;
      for (j = 0; j < k; j++)
        if (a->score > arr[j])
          break;
      for (int m = k; m > j; m--)
        arr[m] = arr[m - 1];
      arr[j] = a->score;
      k++;

    }
  }

  *count = *count > 10 ? 10 : *count - 1; // update count of alns to keep
  *score = arr[*count - 1];               // save new min. score
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl (%rax), %edx
movl %edx, %eax
movq %rsp, %rcx
movq %rcx, -0x28(%rbp)
movl %edx, %ecx
leal 0xf(,%rcx,4), %ecx
andl $-0x10, %ecx
movl %ecx, %edx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x50(%rbp)
movq %rcx, %rsp
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xd757
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
testb $0x1, 0xd(%rax)
jne 0xd747
movq -0x40(%rbp), %rax
movb 0xf(%rax), %al
andb $0x1, %al
movzbl %al, %eax
movb -0xd(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0xd747
movq -0x40(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x20(%rbp), %rax
ucomiss (%rax), %xmm0
jb 0xd747
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
testb $0x1, 0xd(%rax)
je 0xd747
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
testb $0x1, 0xc(%rax)
jne 0xd747
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xd6f4
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movss 0x8(%rcx), %xmm0
movslq -0x44(%rbp), %rcx
ucomiss (%rax,%rcx,4), %xmm0
jbe 0xd6e7
jmp 0xd6f4
jmp 0xd6e9
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xd6c6
movl -0x34(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jle 0xd728
movq -0x50(%rbp), %rax
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movslq -0x48(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x48(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xd6fa
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movss 0x8(%rcx), %xmm0
movslq -0x44(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xd749
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xd63b
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xa, %eax
jle 0xd76d
movl $0xa, %eax
movl %eax, -0x54(%rbp)
jmp 0xd77a
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movl -0x54(%rbp), %ecx
movb %cl, %dl
movq -0x18(%rbp), %rcx
movb %dl, (%rcx)
movq -0x18(%rbp), %rcx
movzbl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x20(%rbp), %rax
movss %xmm0, (%rax)
movq -0x28(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nop