// File: /workspace/github_c_makefile_star2_O3/sc932[P]ALE/src/ALElike.c
// Function: getContributionsForPositions
double getContributionsForPositions(bam1_t *read, contig_t *contig, int qOff, int alignmentLength, float *depthPositions, double *loglikelihoodPositions, int applySoftClip) {
  int i,j;
  int seqPos = 0;
  int refPos = 0;
  int matches = 0;
  int readlen = read->core.l_qseq;
  char *contigSeq = contig->seq;
  double softclipContribution = 0.0;

  if(read == NULL){
	for(refPos = 0; refPos < alignmentLength; refPos++) {
		depthPositions[refPos] = 0.0;
		loglikelihoodPositions[refPos] = getMinLogLike();
	}
	return softclipContribution;
  }
  assert((read->core.flag & BAM_FUNMAP) == 0);

  // read CIGAR first
  uint32_t *cigar = bam1_cigar(read);
  char *readQual = (char*) bam1_qual(read);
  char *MD = getMD(read, contigSeq);
  int numCigarOperations = read->core.n_cigar;
  int ref2seqPos[alignmentLength];

  // initialize loglikelihoodPositions
  for(j=0; j < alignmentLength; j++) {
    loglikelihoodPositions[j] = 0.0;
  }

  for(i=0 ; i < numCigarOperations ; i++) {
    uint32_t cigarInt = *(cigar+i);
    uint32_t cigarFlag = (cigarInt & BAM_CIGAR_MASK);
    uint32_t count = (cigarInt >> BAM_CIGAR_SHIFT);
    ////printf("CIGAR: %u %u %u\n", cigarInt, cigarFlag, count);
    switch (cigarFlag) {
      case(BAM_CMATCH): // match or mismatch
      case(BAM_CEQUAL): // match
      case(BAM_CDIFF):  // mismatch (will be distinguished from match in MD field)
        matches += count;
        for(j=0; j < count; j++) {
        	loglikelihoodPositions[refPos+j] += loglikeMatch(readQual, seqPos+j, 1, qOff);
        	depthPositions[refPos+j] = 1.0;
		    ref2seqPos[refPos+j] = seqPos+j;
        }
        seqPos += count;
        refPos += count;
        break;
      case(BAM_CINS)   : // insertion to the reference.
	if (refPos + 1 < contig->seqLen) {
		double insPenalty = loglikeInsertion(readQual, seqPos, count, qOff) / 2;
		loglikelihoodPositions[refPos] += insPenalty;
		loglikelihoodPositions[refPos+1] += insPenalty;
	} else
		loglikelihoodPositions[refPos] += loglikeInsertion(readQual, seqPos, count, qOff);
        // only increment seqPos
        seqPos += count;
        break;
      case(BAM_CDEL): // deletion from the reference
	{
		assert(refPos + count <= contig->seqLen);
		double delPenalty = loglikeDeletion(readQual, seqPos, count, qOff, readlen) / count;
		for(j=refPos; j < refPos+count; j++) {
			loglikelihoodPositions[j] += delPenalty;
			depthPositions[j] = 0.0;
			ref2seqPos[j] = seqPos;
		}
	}
        // only increment refPos
        refPos += count;
        break;
      case(BAM_CREF_SKIP):
        // assume this is a spliced alignment for RNA, so okay, but no data
        // only increment refPos
		for(j=refPos; j < refPos+count; j++) {
			depthPositions[j] = 0.0;
			ref2seqPos[j] = seqPos;
		}
		refPos += count;
        break;
      case(BAM_CPAD): // silent deletion from padded reference (not in reference or query)
      case(BAM_CHARD_CLIP):
		// hard clipped region is not represented in sequence or quality string, so no information is available for analysis
        break;
      case(BAM_CSOFT_CLIP):
        // soft clipped sequences present in SEQ
        // apply mismatches to clipped portion of the read against the contig past the alignment
        if (seqPos == 0) {
        	// SoftClipped to the left
        	int refPos2 = refPos - count;
        	if (refPos2 < 0) refPos2 = 0;
        	int span = refPos - refPos2;
        	double logMiss = loglikeMiss(readQual, seqPos + count - span, span, qOff);
        	if (applySoftClip)
        		for(j=refPos2; j < refPos; j++)
        			contig->matchLogLikelihood[j] += logMiss / span;
        	softclipContribution += logMiss; // Zmatch already accounts for clipped bases (entire read)
        } else {
        	// SoftClipped to the right
        	int refPos2 = refPos + count;
        	if (refPos2 >= contig->seqLen) refPos2 = contig->seqLen - 1;
        	int span = refPos2 - refPos;
        	double logMiss = loglikeMiss(readQual, seqPos, span, qOff);
        	if (applySoftClip)
        		for(j=refPos; j < refPos2; j++)
        			contig->matchLogLikelihood[j] += logMiss / span;
        	softclipContribution += logMiss; // Zmatch already accounts for clipped bases (entire read)
        }
        seqPos += count;
        readlen -= count;
        break;
    }
  }
  if ((seqPos != read->core.l_qseq) || (refPos != alignmentLength)) {
        fprintf(stderr, "WARNING: Read CIGAR does not match sequence and/or reference alignment lengths: %s %d: seqPos %d seqLen: %d refPos %d alignmentLen: %d\n", bam1_qname(read), read->core.flag, seqPos, read->core.l_qseq, refPos, alignmentLength);
  }

  // now process MD field
  refPos = 0;
  if (MD != NULL && MD[0] == 'Z') {
	  int stop = 0;
	  int pos = 1;

	  // parse MD field
	  while(stop == 0){
	    // matches
	    int seqCount = 0;
	    while(isdigit(MD[pos])){
	        seqCount = seqCount*10 + (int)(MD[pos]) - 48; // chr(48) == '0'
	        pos++;
	    }
	    refPos += seqCount;

	    double logMatch;
	    double logMiss;
	    // misses
	    int baseAmbiguity = 0;
	    while((baseAmbiguity = getBaseAmbibuity(MD[pos])) > 0){
	      char seqBase = contig->seq[refPos + read->core.pos];
	      if (seqBase != MD[pos]) {
	    	  fprintf(stderr, "WARNING: MD field calls mismatch but it does agree with the reference! %s %d: refpos %d MDpos %d: '%c' vs '%c'\n", bam1_qname(read), read->core.flag, refPos+read->core.pos, pos, seqBase, MD[pos]);
	      }
          seqPos = ref2seqPos[refPos];
	      logMatch = loglikeMatch(readQual, seqPos, 1, qOff);
	      if(baseAmbiguity == 1){
	          logMiss = loglikeMiss(readQual, seqPos, 1, qOff);
	      } else {
	    	  if (baseAmbiguity == 4 || isAmbiguousMatch(seqBase, bam1_seq(read)[seqPos]) == 0) {
	    		  logMiss = log(1.0/(float)baseAmbiguity);
	    	  } else {
	    		  // ambiguous match, so offset this mismatch hit (i.e. make the following statements a noop)
	    		  matches++;
	    		  logMiss = logMatch;
	    	  }
	      }
          // logMatch was already applied, so replace it with logMiss
	      loglikelihoodPositions[refPos] += logMiss - logMatch;

	      refPos++;
	      pos++;
	      matches--;
	      ////printf("MD %d miss  %d. %f\n", seqPos, 1, loglikelihood);
	    }

	    // deletions
	    if(MD[pos] == '^'){
	      pos++;
	      while(isalpha(MD[pos])){
	        pos++;
	        refPos++;
	      }
	    }

	    // sees if we are at the end
	    if(MD[pos] == '\0'){
	      stop = 1;
	      continue;
	    }
	  }
	  if (refPos != alignmentLength) fprintf(stderr, "WARNING: CIGAR and MD field disagree on match region for %s\n", bam1_qname(read));
  } else {
	  printf("WARNING: could not find the MD tag for %s\n", bam1_qname(read));
  }

  double identity = ((double)matches) / ((double) readlen);
  setLeastIdentity(identity);

  return softclipContribution;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r8, -0xc8(%rbp)
movl %edx, -0x2c(%rbp)
movq 0x8(%rdi), %rax
btq $0x22, %rax
jb 0x6864
movq %r9, %r12
movl %ecx, %r14d
movq %rdi, %r15
movl 0x10(%rdi), %ecx
movq %rsi, -0x78(%rbp)
movq 0x10(%rsi), %rsi
movl %eax, %edx
shrl $0x18, %edx
addq 0x30(%rdi), %rdx
shrq $0x30, %rax
movq %rdx, -0x48(%rbp)
leaq (%rdx,%rax,4), %r13
movq %rcx, -0xa8(%rbp)
leal 0x1(%rcx), %eax
sarl %eax
movslq %eax, %rbx
callq 0x5b1a
movq %rax, -0x90(%rbp)
movq %r15, -0x38(%rbp)
movq 0x8(%r15), %r15
shrq $0x30, %r15
movl %r14d, %edx
movq %rsp, %rcx
leaq 0xf(,%rdx,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0xb0(%rbp)
movq %rcx, %rsp
movq %r14, -0xc0(%rbp)
testl %r14d, %r14d
jle 0x5f21
shlq $0x3, %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x3260
addq %rbx, %r13
movq %r13, -0x70(%rbp)
testq %r15, %r15
jne 0x5f51
movl $0x0, -0x3c(%rbp)
xorpd %xmm0, %xmm0
movsd %xmm0, -0xa0(%rbp)
xorl %edi, %edi
xorl %r10d, %r10d
movq -0x38(%rbp), %r14
movq %r12, %r11
jmp 0x64f2
movq -0xb0(%rbp), %rax
addq $0xc, %rax
movq %rax, -0xd8(%rbp)
xorpd %xmm0, %xmm0
movsd %xmm0, -0xa0(%rbp)
xorl %r13d, %r13d
xorl %r10d, %r10d
xorl %edi, %edi
movl $0x0, -0x3c(%rbp)
movl -0x2c(%rbp), %r8d
movq -0x38(%rbp), %r14
movq -0x48(%rbp), %rsi
movq %r15, -0x50(%rbp)
movq %r12, %r11
movq %r12, -0x60(%rbp)
movl (%rsi,%r13,4), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x8, %ecx
ja 0x64e6
movl %eax, %r9d
shrl $0x4, %r9d
leaq 0x17bab(%rip), %rdx     # 0x1db60
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq %rdi, -0x88(%rbp)
movq %r13, -0x68(%rbp)
movl %r10d, -0x58(%rbp)
cmpl $0x10, %eax
movq -0x70(%rbp), %r13
jb 0x6068
movslq -0x88(%rbp), %rax
movl -0x58(%rbp), %ecx
movq %rcx, -0x80(%rbp)
movq -0x60(%rbp), %rcx
leaq (%rcx,%rax,8), %r14
movq -0xc8(%rbp), %rcx
leaq (%rcx,%rax,4), %rcx
movq %rcx, -0xb8(%rbp)
movq -0xb0(%rbp), %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, -0xd0(%rbp)
xorl %ebx, %ebx
movq -0x80(%rbp), %rax
leal (%rax,%rbx), %r15d
movq %r13, %rdi
movl %r15d, %esi
movl $0x1, %edx
movl %r8d, %ecx
movq %r9, %r12
callq 0x5c92
movq %r12, %r9
movl -0x2c(%rbp), %r8d
addsd (%r14,%rbx,8), %xmm0
movsd %xmm0, (%r14,%rbx,8)
movq -0xb8(%rbp), %rax
movl $0x3f800000, (%rax,%rbx,4) # imm = 0x3F800000
movq -0xd0(%rbp), %rax
movl %r15d, (%rax,%rbx,4)
incq %rbx
cmpq %rbx, %r12
jne 0x6016
addl %r9d, -0x3c(%rbp)
movl -0x58(%rbp), %r10d
addl %r9d, %r10d
movq -0x88(%rbp), %rdi
addl %r9d, %edi
movq -0x60(%rbp), %r11
movq -0x38(%rbp), %r14
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %r15
movq -0x68(%rbp), %r13
jmp 0x64e6
leal (%r9,%rdi), %eax
cmpl %eax, %edi
jae 0x6396
movl %eax, -0x80(%rbp)
movslq %edi, %r14
movq -0xc8(%rbp), %rax
leaq (%rax,%r14,4), %rdi
decl %r9d
leaq 0x4(,%r9,4), %rdx
xorl %esi, %esi
movl %r10d, %r12d
movq %r13, -0x68(%rbp)
movq %r11, %r13
movq %r9, %rbx
callq 0x3260
pcmpeqd %xmm8, %xmm8
movdqa 0x17a21(%rip), %xmm7    # 0x1db00
movdqa 0x17a09(%rip), %xmm6    # 0x1daf0
movdqa 0x179f1(%rip), %xmm5    # 0x1dae0
movq %r13, %r11
movq -0x68(%rbp), %r13
movl %r12d, %r10d
leaq 0x4(%rbx), %rax
andq $-0x4, %rax
movq %rbx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movq -0xd8(%rbp), %rcx
leaq (%rcx,%r14,4), %rcx
movq -0x38(%rbp), %r14
pxor %xmm7, %xmm0
xorl %edx, %edx
movq %rdx, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movdqa %xmm1, %xmm2
por %xmm6, %xmm2
pxor %xmm7, %xmm2
movdqa %xmm2, %xmm3
pcmpgtd %xmm0, %xmm3
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm4     # xmm4 = xmm2[1,1,3,3]
pand %xmm3, %xmm4
pshufd $0xf5, %xmm3, %xmm2     # xmm2 = xmm3[1,1,3,3]
por %xmm4, %xmm2
movd %xmm2, %esi
notl %esi
testb $0x1, %sil
je 0x6165
movl %r10d, -0xc(%rcx,%rdx,4)
pxor %xmm8, %xmm2
pextrw $0x4, %xmm2, %esi
testb $0x1, %sil
je 0x617a
movl %r10d, -0x8(%rcx,%rdx,4)
por %xmm5, %xmm1
pxor %xmm7, %xmm1
movdqa %xmm1, %xmm2
pcmpgtd %xmm0, %xmm2
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm3     # xmm3 = xmm1[1,1,3,3]
pand %xmm2, %xmm3
pshufd $0xf5, %xmm2, %xmm1     # xmm1 = xmm2[1,1,3,3]
por %xmm3, %xmm1
pxor %xmm8, %xmm1
pextrw $0x0, %xmm1, %esi
testb $0x1, %sil
je 0x61b5
movl %r10d, -0x4(%rcx,%rdx,4)
pextrw $0x4, %xmm1, %esi
testb $0x1, %sil
je 0x61c4
movl %r10d, (%rcx,%rdx,4)
addq $0x4, %rdx
cmpq %rdx, %rax
jne 0x6120
movl -0x80(%rbp), %eax
movl %eax, %edi
movl -0x2c(%rbp), %r8d
movq -0x48(%rbp), %rsi
jmp 0x64e6
testl %r10d, %r10d
movq %r9, -0x98(%rbp)
je 0x63ec
leal (%r9,%rdi), %eax
movq -0x78(%rbp), %rcx
movl 0x8(%rcx), %ecx
leal -0x1(%rcx), %ebx
cmpl %ecx, %eax
cmovll %eax, %ebx
movl %ebx, %r15d
subl %edi, %r15d
movq %rdi, %r12
movq -0x70(%rbp), %rdi
movl %r10d, %r14d
movl %r10d, %esi
movl %r15d, %edx
movl %r8d, %ecx
callq 0x5c16
cmpl $0x0, 0x10(%rbp)
je 0x648f
cmpl %r12d, %ebx
movl -0x2c(%rbp), %r8d
movl %r14d, %r10d
movq -0x60(%rbp), %r11
movq -0x48(%rbp), %rsi
movq %r12, %rdi
movq -0x98(%rbp), %r9
jle 0x6485
xorps %xmm2, %xmm2
cvtsi2sd %r15d, %xmm2
movapd %xmm0, %xmm1
divsd %xmm2, %xmm1
movq -0x78(%rbp), %rax
movq 0x38(%rax), %rax
movslq %edi, %rcx
movslq %ebx, %rdx
movq -0x38(%rbp), %r14
xorps %xmm2, %xmm2
cvtss2sd (%rax,%rcx,4), %xmm2
addsd %xmm1, %xmm2
cvtsd2ss %xmm2, %xmm2
movss %xmm2, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %rdx
jne 0x6272
jmp 0x647f
movq %r13, -0x68(%rbp)
movq %r11, %r13
leal 0x1(%rdi), %ebx
movq -0x78(%rbp), %rax
movl 0x8(%rax), %r14d
movq %rdi, %r12
movq -0x70(%rbp), %rdi
movl %r10d, -0x58(%rbp)
movl %r10d, %esi
movq %r9, %r15
movl %r9d, %edx
movl %r8d, %ecx
callq 0x5c16
cmpl %r14d, %ebx
jge 0x639d
mulsd 0x17775(%rip), %xmm0    # 0x1da48
movslq %r12d, %rax
movq %r13, %r11
movsd (%r13,%rax,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%r13,%rax,8)
movq -0x38(%rbp), %r14
jmp 0x63a7
leal (%r9,%rdi), %ebx
movq -0x78(%rbp), %rax
cmpl 0x8(%rax), %ebx
ja 0x6845
movq %r11, %r14
movq %rdi, %r12
movq -0x70(%rbp), %rdi
movl %r10d, -0x58(%rbp)
movl %r10d, %esi
movl %r9d, %edx
movl %r8d, %ecx
movq -0xa8(%rbp), %r8
movq %r9, %r15
callq 0x5d13
cmpl %ebx, %r12d
jae 0x63ce
xorps %xmm1, %xmm1
cvtsi2sd %r15d, %xmm1
divsd %xmm1, %xmm0
movslq %r12d, %rdx
movq %r14, %r11
leaq (%r14,%rdx,8), %rax
movq -0xc8(%rbp), %rcx
leaq (%rcx,%rdx,4), %rcx
movq -0xb0(%rbp), %rsi
leaq (%rsi,%rdx,4), %rdx
movl %r12d, %esi
xorl %edi, %edi
movl -0x58(%rbp), %r10d
movsd (%rax,%rdi,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rdi,8)
movl $0x0, (%rcx,%rdi,4)
movl %r10d, (%rdx,%rdi,4)
incq %rdi
leal (%rsi,%rdi), %r8d
cmpl %r8d, %ebx
ja 0x6369
movl %ebx, %edi
movl -0x2c(%rbp), %r8d
jmp 0x63db
movl %eax, %edi
jmp 0x64e6
movl %r12d, %ebx
movq -0x38(%rbp), %r14
movq %r13, %r11
movq -0x48(%rbp), %rsi
movq %r12, %rdi
movslq %ebx, %rax
addsd (%r11,%rax,8), %xmm0
movsd %xmm0, (%r11,%rax,8)
addl -0x58(%rbp), %r15d
movl %r15d, %r10d
movl -0x2c(%rbp), %r8d
movq -0x68(%rbp), %r13
jmp 0x63e3
movl %ebx, %edi
movl -0x2c(%rbp), %r8d
movl -0x58(%rbp), %r10d
movq %r14, %r11
movq -0x48(%rbp), %rsi
movq -0x38(%rbp), %r14
movq -0x50(%rbp), %r15
jmp 0x64e6
movl %r10d, -0x58(%rbp)
movl %edi, %ebx
subl %r9d, %ebx
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
movl %edi, %r15d
subl %ebx, %r15d
movl %r9d, %esi
subl %r15d, %esi
movq %rdi, %r12
movq -0x70(%rbp), %rdi
movl %r15d, %edx
movl %r8d, %ecx
callq 0x5c16
cmpl $0x0, 0x10(%rbp)
je 0x649c
cmpl %ebx, %r12d
movl -0x2c(%rbp), %r8d
movl -0x58(%rbp), %r10d
movq -0x60(%rbp), %r11
movq -0x48(%rbp), %rsi
movq %r12, %rdi
movq -0x98(%rbp), %r9
jle 0x6485
xorps %xmm2, %xmm2
cvtsi2sd %r15d, %xmm2
movapd %xmm0, %xmm1
divsd %xmm2, %xmm1
movq -0x78(%rbp), %rax
movq 0x38(%rax), %rax
movl %ebx, %ecx
movl %edi, %edx
movq -0x38(%rbp), %r14
xorps %xmm2, %xmm2
cvtss2sd (%rax,%rcx,4), %xmm2
addsd %xmm1, %xmm2
cvtsd2ss %xmm2, %xmm2
movss %xmm2, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %rdx
jne 0x6462
movq -0x50(%rbp), %r15
jmp 0x64be
movq -0x50(%rbp), %r15
movq -0x38(%rbp), %r14
jmp 0x64be
movl -0x2c(%rbp), %r8d
movq -0x50(%rbp), %r15
movl %r14d, %r10d
jmp 0x64a8
movl -0x2c(%rbp), %r8d
movq -0x50(%rbp), %r15
movl -0x58(%rbp), %r10d
movq -0x60(%rbp), %r11
movq -0x48(%rbp), %rsi
movq -0x38(%rbp), %r14
movq %r12, %rdi
movq -0x98(%rbp), %r9
movsd -0xa0(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0xa0(%rbp)
addl %r9d, %r10d
movq -0xa8(%rbp), %rax
subl %r9d, %eax
movq %rax, -0xa8(%rbp)
incq %r13
cmpq %r15, %r13
jne 0x5f95
movl 0x10(%r14), %r9d
cmpl %r9d, %r10d
movq -0xc0(%rbp), %rax
jne 0x6808
cmpl %eax, %edi
jne 0x6808
leaq 0x30(%r14), %rcx
movq -0x90(%rbp), %rax
testq %rax, %rax
je 0x67c4
cmpb $0x5a, (%rax)
jne 0x67c4
movq %rcx, -0x50(%rbp)
movq %r11, -0x60(%rbp)
callq 0x36a0
movq -0x90(%rbp), %r8
movq %rax, -0x88(%rbp)
leaq 0x1(%r8), %rax
movq %rax, -0x48(%rbp)
movb 0x1(%r8), %r12b
movl $0x1, %r14d
movabsq $0x100000000, %r9       # imm = 0x100000000
xorl %eax, %eax
movq -0x88(%rbp), %rcx
movq (%rcx), %rcx
movslq %r14d, %r15
movsbq %r12b, %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
jne 0x6580
xorl %ebx, %ebx
jmp 0x65b7
movq -0x48(%rbp), %rdx
addq %r15, %rdx
shlq $0x20, %r15
xorl %ebx, %ebx
addq %r9, %r15
movsbl %r12b, %esi
leal (%rbx,%rbx,4), %edi
leal (%rsi,%rdi,2), %ebx
addl $-0x30, %ebx
movsbq (%rdx), %r12
incl %r14d
incq %rdx
testb $0x8, 0x1(%rcx,%r12,2)
jne 0x658d
sarq $0x20, %r15
movb (%r8,%r15), %r12b
addl %eax, %ebx
movsbl %r12b, %edi
callq 0x5dc1
testl %eax, %eax
je 0x674d
movl %eax, %r13d
movslq %ebx, %rax
movq -0xb0(%rbp), %rcx
leaq (%rcx,%rax,4), %rcx
movq %rcx, -0x58(%rbp)
movq -0x60(%rbp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, -0x68(%rbp)
movl %r15d, %r14d
addq -0x90(%rbp), %r15
movq %r15, -0xd0(%rbp)
movl $0x1, %r15d
movq -0x78(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
movl 0x4(%rcx), %r8d
addl %ebx, %r8d
movslq %r8d, %rcx
movsbl (%rax,%rcx), %eax
movq %rax, -0xb8(%rbp)
cmpb %r12b, %al
jne 0x6711
movq -0x58(%rbp), %rax
movl -0x4(%rax,%r15,4), %r12d
movq -0x70(%rbp), %rdi
movl %r12d, %esi
movl $0x1, %edx
movl -0x2c(%rbp), %ecx
callq 0x5c92
movsd %xmm0, -0x80(%rbp)
cmpl $0x4, %r13d
je 0x66b0
cmpl $0x1, %r13d
jne 0x6670
movq -0x70(%rbp), %rdi
movl %r12d, %esi
movl $0x1, %edx
movl -0x2c(%rbp), %ecx
callq 0x5c16
jmp 0x66c9
movq -0x38(%rbp), %rdx
movq 0x8(%rdx), %rax
movq %rax, %rcx
shrq $0x30, %rcx
shlq $0x2, %rcx
addq 0x30(%rdx), %rcx
movslq %r12d, %rdx
shrl $0x18, %eax
addq %rcx, %rax
movsbl (%rdx,%rax), %esi
movq -0xb8(%rbp), %rdi
callq 0x5ddc
testl %eax, %eax
je 0x66b0
movl -0x3c(%rbp), %eax
incl %eax
movsd -0x80(%rbp), %xmm0
jmp 0x66cc
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
movsd 0x17370(%rip), %xmm0    # 0x1da30
divsd %xmm1, %xmm0
callq 0x3290
movl -0x3c(%rbp), %eax
subsd -0x80(%rbp), %xmm0
movq -0x68(%rbp), %rcx
addsd -0x8(%rcx,%r15,8), %xmm0
movsd %xmm0, -0x8(%rcx,%r15,8)
decl %eax
movl %eax, -0x3c(%rbp)
movq -0xd0(%rbp), %rax
movb (%rax,%r15), %r12b
movsbl %r12b, %edi
callq 0x5dc1
movl %eax, %r13d
incl %ebx
incq %r15
incl %r14d
testl %eax, %eax
jne 0x6602
jmp 0x674d
movsbl %r12b, %r10d
movq 0x258dc(%rip), %rax     # 0x2bff8
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rdx
movzwl 0xc(%rax), %ecx
leaq 0x1b87e(%rip), %rsi     # 0x21fb0
movl %r14d, %r9d
xorl %eax, %eax
pushq %r10
pushq -0xb8(%rbp)
callq 0x3350
addq $0x10, %rsp
jmp 0x662c
cmpb $0x5e, %r12b
jne 0x678e
movq -0x88(%rbp), %rax
movq (%rax), %rcx
movslq %r14d, %rdx
addq -0x48(%rbp), %rdx
decl %ebx
movl %ebx, %eax
movq -0x90(%rbp), %r8
movabsq $0x100000000, %r9       # imm = 0x100000000
movsbq (%rdx), %rsi
incl %r14d
incq %rdx
incl %eax
testb $0x4, 0x1(%rcx,%rsi,2)
jne 0x6779
jmp 0x67a1
movl %ebx, %eax
movq -0x90(%rbp), %r8
movabsq $0x100000000, %r9       # imm = 0x100000000
movslq %r14d, %rcx
movb (%r8,%rcx), %r12b
testb %r12b, %r12b
jne 0x6564
cmpl -0xc0(%rbp), %eax
je 0x67d5
movq -0x50(%rbp), %rdi
callq 0x379d
jmp 0x67d5
movq (%rcx), %rsi
leaq 0x1b88f(%rip), %rdi     # 0x2205d
xorl %eax, %eax
callq 0x3210
xorps %xmm0, %xmm0
cvtsi2sdl -0x3c(%rbp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl -0xa8(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0xaba9
movsd -0xa0(%rbp), %xmm0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x257e9(%rip), %rax     # 0x2bff8
movq %rdi, %rbx
movq (%rax), %rdi
movq 0x30(%r14), %rdx
movzwl 0xc(%r14), %ecx
leaq 0x1b703(%rip), %rsi     # 0x21f28
movl %r10d, %r8d
xorl %eax, %eax
pushq -0xc0(%rbp)
pushq %rbx
movq %r11, %rbx
callq 0x3350
movq %rbx, %r11
addq $0x10, %rsp
jmp 0x650e
leaq 0x1b6bb(%rip), %rdi     # 0x21f07
leaq 0x1b512(%rip), %rsi     # 0x21d65
leaq 0x1b651(%rip), %rcx     # 0x21eab
movl $0x235, %edx            # imm = 0x235
callq 0x3230
leaq 0x1b61c(%rip), %rdi     # 0x21e87
leaq 0x1b4f3(%rip), %rsi     # 0x21d65
leaq 0x1b632(%rip), %rcx     # 0x21eab
movl $0x209, %edx            # imm = 0x209
callq 0x3230