// File: /workspace/github_c_makefile_star2_O3/jsh58[P]Genrich/Genrich.c
// Function: getBAMscore
float getBAMscore(char* extra, int len) {
  if (extra == NULL)
    return NOSCORE;

  // check auxiliary field
  char tag[3], val;
  tag[2] = '\0';
  int i = 0;
  while (i < len - 4) {

    // load tag and value
    for (int j = 0; j < 3; j++) {
      if (j < 2)
        tag[j] = extra[i];
      else
        val = extra[i];
      i++;
    }

    if (! strcmp(tag, SCORE)) {

      // return alignment score (cast to float)
      extra += i;
      switch (val) {
        case 'c':
          return (float) (int8_t) loadInt(extra, sizeof(int8_t));
        case 'C':
          return (float) (uint8_t) loadInt(extra, sizeof(uint8_t));
        case 's':
          return (float) (int16_t) loadInt(extra, sizeof(int16_t));
        case 'S':
          return (float) (uint16_t) loadInt(extra, sizeof(uint16_t));
        case 'i':
          return (float) (int32_t) loadInt(extra, sizeof(int32_t));
        case 'I':
          return (float) (uint32_t) loadInt(extra, sizeof(uint32_t));
        default: ;
          char msg[4] = "' '";
          msg[1] = val;
          exit(error(msg, ERRTYPE));
      }

    } else {

      // skip to next auxiliary field
      switch (val) {
        case 'A': i++; break;
        case 'c': i += sizeof(int8_t); break;
        case 'C': i += sizeof(uint8_t); break;
        case 's': i += sizeof(int16_t); break;
        case 'S': i += sizeof(uint16_t); break;
        case 'i': i += sizeof(int32_t); break;
        case 'I': i += sizeof(uint32_t); break;
        case 'f': i += sizeof(float); break;
        case 'Z': for (; extra[i] != '\0'; i++) ; i++; break;
        case 'H': for (; extra[i] != '\0'; i += 2) ; i++; break;
        case 'B': i += arrayLen(extra + i); break;
        default: ;
          char msg[4] = "' '";
          msg[1] = val;
          exit(error(msg, ERRTYPE));
      }
    }

    // check if field has gone past end of block
    if (i > len)
      exit(error("", ERRAUX));
  }

  return NOSCORE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0xddb6
movl %esi, %r14d
movq %rdi, %rbx
movb $0x0, 0x6(%rsp)
leal -0x4(%r14), %ebp
xorl %r12d, %r12d
movss 0x44ad(%rip), %xmm0     # 0x12174
leaq 0x46c2(%rip), %r15      # 0x12390
cmpl %ebp, %r12d
jge 0xde47
movslq %r12d, %rax
movzwl (%rbx,%rax), %edx
movw %dx, 0x4(%rsp)
movzbl 0x2(%rbx,%rax), %esi
leaq 0x3(%rax), %rcx
xorl $0x5341, %edx           # imm = 0x5341
movzbl 0x6(%rsp), %edi
orw %dx, %di
je 0xddc3
addq $0x2, %rax
addl $0x3, %r12d
cmpl $0x52, %esi
jle 0xdd2a
cmpl $0x65, %esi
jg 0xdd44
cmpl $0x53, %esi
je 0xdd57
cmpl $0x5a, %esi
je 0xdda2
cmpl $0x63, %esi
je 0xdd3f
jmp 0xde59
leal -0x41(%rsi), %edx
cmpl $0x8, %edx
ja 0xde59
movslq (%r15,%rdx,4), %rdx
addq %r15, %rdx
jmpq *%rdx
addl $0x2, %eax
jmp 0xdd5f
cmpl $0x66, %esi
je 0xdd5c
cmpl $0x69, %esi
je 0xdd5c
cmpl $0x73, %esi
jne 0xde59
addl $0x3, %eax
jmp 0xdd5f
addl $0x5, %eax
movl %eax, %r12d
cmpl %r14d, %r12d
jle 0xdcce
jmp 0xde54
movslq %r12d, %rax
leal -0x1(%rax), %r12d
addq %rbx, %rax
addl $0x2, %r12d
cmpb $0x0, (%rax)
leaq 0x2(%rax), %rax
jne 0xdd7a
jmp 0xdd62
movslq %ecx, %r12
leaq (%rbx,%r12), %rdi
callq 0xdc01
movss 0x43d7(%rip), %xmm0     # 0x12174
addl %eax, %r12d
jmp 0xdd62
movslq %r12d, %rax
addq %rbx, %rax
incl %r12d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0xdda8
jmp 0xdd62
movss 0x43b6(%rip), %xmm0     # 0x12174
jmp 0xde47
movslq %ecx, %rax
addq %rax, %rbx
cmpl $0x62, %esi
jg 0xdde6
cmpl $0x43, %esi
je 0xde38
cmpl $0x49, %esi
je 0xddfa
cmpl $0x53, %esi
jne 0xde63
movzwl (%rbx), %eax
jmp 0xde40
cmpl $0x63, %esi
je 0xde3d
cmpl $0x69, %esi
je 0xde1e
cmpl $0x73, %esi
jne 0xde63
movswl (%rbx), %eax
jmp 0xde40
xorl %ecx, %ecx
xorl %eax, %eax
movzbl (%rbx), %edx
shll %cl, %edx
orl %edx, %eax
addq $0x8, %rcx
incq %rbx
cmpq $0x20, %rcx
jne 0xddfe
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0xde47
xorl %ecx, %ecx
xorl %eax, %eax
movzbl (%rbx), %edx
shll %cl, %edx
orl %edx, %eax
addq $0x8, %rcx
incq %rbx
cmpq $0x20, %rcx
jne 0xde22
jmp 0xde40
movzbl (%rbx), %eax
jmp 0xde40
movsbl (%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x3093
leaq 0x8(%rsp), %rdi
callq 0x30ab
leaq 0xc(%rsp), %rdi
callq 0x30c6