// File: /workspace/github_c_makefile_star2_O1/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 0x7b28
movzbl %sil, %edi
movl %edi, %r9d
movzbl (%rcx), %r8d
andl $0x7, %r9d
je 0x7b35
movl %r8d, %eax
andl $0x7, %eax
addl %eax, %r9d
xorl %eax, %eax
cmpl $0x4, %r9d
jb 0x7b1f
cmpl $0x7, %r9d
movl $0x7, %eax
cmovll %r9d, %eax
movl %r9d, %r10d
subl %eax, %r10d
addl $0x3, %r10d
movl %r10d, %eax
shrl $0x2, %eax
andl $-0x4, %r10d
incl %eax
subl %r10d, %r9d
addl $-0x4, %r9d
andb $-0x8, %r8b
orb %r8b, %r9b
jmp 0x7b49
testl %edi, %edi
jns 0x7c07
callq 0x2c7e
xorl %eax, %eax
testb $0x4, %r8b
je 0x7b4c
andb $-0x5, %r8b
movl $0x1, %eax
movl %r8d, %r9d
movb %r9b, (%rcx)
testb $0x18, %sil
je 0x7b94
movl %edi, %r8d
shrl $0x3, %r8d
andl $0x3, %r8d
movzbl (%rcx), %r9d
movl %r9d, %r10d
shrl $0x3, %r10d
andl $0x3, %r10d
addl %r8d, %r10d
cmpl $0x3, %r10d
sbbl $-0x1, %eax
leal -0x3(%r10), %r8d
cmpl $0x3, %r10d
movzbl %r8b, %r8d
cmovbl %r10d, %r8d
andb $-0x19, %r9b
shlb $0x3, %r8b
orb %r9b, %r8b
movb %r8b, (%rcx)
cmpb $0x20, %sil
jb 0x7bcf
shrl $0x5, %edi
movzbl (%rcx), %esi
movl %esi, %r8d
shrl $0x5, %r8d
addl %edi, %r8d
cmpl $0x5, %r8d
sbbl $-0x1, %eax
leal 0x3(%r8), %edi
cmpl $0x5, %r8d
movzbl %dil, %edi
cmovbl %r8d, %edi
andb $0x1f, %sil
shlb $0x5, %dil
orb %sil, %dil
movb %dil, (%rcx)
cmpl $0x2, %eax
jl 0x7bfa
movl $0x3, %esi
cmovlel %eax, %esi
negl %esi
addl %eax, %esi
incl %esi
movl %esi, %edi
shrl %edi
andl $-0x2, %esi
movl (%rdx), %r8d
addl %r8d, %edi
incl %edi
negl %esi
addl %esi, %eax
addl $-0x2, %eax
movl %edi, (%rdx)
testl %eax, %eax
je 0x7c01
orb $0x4, (%rcx)
movl (%rdx), %edi
testl %edi, %edi
js 0x7c55
movzbl (%rcx), %eax
cvtsi2ss %edi, %xmm0
movl %eax, %ecx
andl $0x7, %ecx
cvtsi2ss %ecx, %xmm1
mulss 0xa54d(%rip), %xmm1     # 0x1216c
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 0xa62c(%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 0x2c66