// File: /workspace/github_c_makefile_star2_O3/jsh58[P]Genrich/Genrich.c
// Function: updateVal
float updateVal(int16_t dCov, uint8_t dFrac, int32_t* cov,
    uint8_t* frac) {

  // add ints
  *cov += dCov;
  if (! dFrac) {
    if (*cov < 0)
      exit(error(errMsg[ERRPILE], ERRISSUE));
    return getVal(*cov, *frac);
  }

  // sum eighths (and collect halves)
  int half = 0;
  if (dFrac & 0x7) {
    int sum8 = (dFrac & 0x7) + (*frac & 0x7);
    while (sum8 > 3) {
      half++;
      sum8 -= 4;
    }
    *frac = (*frac & 0xF8) | sum8;
  } else if (*frac & 0x4) {
    half++;
    *frac &= 0xFB;
  }

  // sum sixths
  if (dFrac & 0x18) {
    int sum6 = ((dFrac >> 3) & 0x3) + ((*frac >> 3) & 0x3);
    if (sum6 > 2) {
      half++;
      sum6 -= 3;
    }
    *frac = (*frac & 0xE7) | (sum6 << 3);
  }

  // sum tenths
  if (dFrac & 0xE0) {
    int sum10 = ((dFrac >> 5) & 0x7) + ((*frac >> 5) & 0x7);
    if (sum10 > 4) {
      half++;
      sum10 -= 5;
    }
    *frac = (*frac & 0x1F) | (sum10 << 5);
  }

  // combine halves
  while (half > 1) {
    (*cov)++;
    half -= 2;
  }
  if (half)
    *frac |= 0x4;

  // check for negative pileup
  if (*cov < 0)
    exit(error(errMsg[ERRPILE], ERRISSUE));

  return getVal(*cov, *frac);
}

// Assembly:
pushq %rax
addl (%rdx), %edi
movl %edi, (%rdx)
testl %esi, %esi
je 0x7b3a
movzbl %sil, %r8d
movl %r8d, %r9d
movb (%rcx), %dil
andl $0x7, %r9d
je 0x7b47
movzbl %dil, %eax
andl $0x7, %eax
addl %eax, %r9d
xorl %eax, %eax
cmpl $0x4, %r9d
jb 0x7b31
xorl %eax, %eax
movl %r9d, %r10d
subl $0x7, %r10d
cmovbl %eax, %r10d
addl $0x3, %r10d
movl %r10d, %eax
shrl $0x2, %eax
incl %eax
andl $0x1c, %r10d
negl %r10d
addl %r10d, %r9d
addl $-0x4, %r9d
andb $-0x8, %dil
orb %dil, %r9b
jmp 0x7b5b
testl %edi, %edi
jns 0x7c22
callq 0x2c96
xorl %eax, %eax
testb $0x4, %dil
je 0x7b61
andb $-0x5, %dil
movl $0x1, %eax
movl %edi, %r9d
movb %r9b, (%rcx)
movl %r9d, %edi
testb $0x18, %sil
je 0x7bac
movl %r8d, %r9d
shrl $0x3, %r9d
andl $0x3, %r9d
movl %edi, %r10d
shrb $0x3, %r10b
andb $0x3, %r10b
movzbl %r10b, %r10d
addl %r9d, %r10d
cmpl $0x3, %r10d
sbbl $-0x1, %eax
leal -0x3(%r10), %r9d
cmpl $0x3, %r10d
movzbl %r9b, %r9d
cmovbl %r10d, %r9d
andb $-0x19, %dil
shlb $0x3, %r9b
orb %dil, %r9b
movb %r9b, (%rcx)
movl %r9d, %edi
cmpb $0x20, %sil
jb 0x7be6
shrl $0x5, %r8d
movl %edi, %esi
shrb $0x5, %sil
movzbl %sil, %esi
addl %r8d, %esi
cmpl $0x5, %esi
sbbl $-0x1, %eax
leal 0x3(%rsi), %r8d
cmpl $0x5, %esi
movzbl %r8b, %r8d
cmovbl %esi, %r8d
andb $0x1f, %dil
shlb $0x5, %r8b
orb %dil, %r8b
movb %r8b, (%rcx)
cmpl $0x2, %eax
jb 0x7c15
movl (%rdx), %esi
xorl %edi, %edi
movl %eax, %r8d
subl $0x3, %r8d
cmovbl %edi, %r8d
incl %r8d
movl %r8d, %edi
shrl %edi
addl %edi, %esi
incl %esi
andl $-0x2, %r8d
negl %r8d
addl %r8d, %eax
addl $-0x2, %eax
movl %esi, (%rdx)
testl %eax, %eax
je 0x7c1c
orb $0x4, (%rcx)
movl (%rdx), %edi
testl %edi, %edi
js 0x7c70
movzbl (%rcx), %eax
cvtsi2ss %edi, %xmm0
movl %eax, %ecx
andl $0x7, %ecx
cvtsi2ss %ecx, %xmm1
mulss 0xa52a(%rip), %xmm1     # 0x12164
addss %xmm0, %xmm1
movl %eax, %ecx
shrl $0x3, %ecx
andl $0x3, %ecx
shrl $0x5, %eax
movd %eax, %xmm0
movd %ecx, %xmm2
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
cvtdq2ps %xmm0, %xmm2
divps 0xa611(%rip), %xmm2     # 0x12270
movaps %xmm2, %xmm0
shufps $0x55, %xmm2, %xmm0     # xmm0 = xmm0[1,1],xmm2[1,1]
addss %xmm1, %xmm0
addss %xmm2, %xmm0
popq %rax
retq
callq 0x2c7e