LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: checkHashSn
bool checkHashSn(Read* r, HashAln** table,
    uint32_t hashSize, File dups, bool dupsVerb,
    bool gzOut) {
  for (int k = 0; k < r->alnLen; k++) {
    Aln* a = r->aln + k;
    uint32_t pos = (a->strand ? a->pos[0] : a->pos[1]);
    uint32_t idx = jenkins_hash_aln(a->chrom, NULL,
      pos, 0, a->strand, 0, SINGLE, hashSize);
    HashAln* h = checkHash(a->chrom, NULL, pos, 0,
      a->strand, 0, SINGLE, table, idx);
    if (h) {
      if (dupsVerb)
        logDup(dups, gzOut, r->name, a->chrom, NULL,
          pos, 0, a->strand, 0, h->name, SINGLE);
      return true;
    }
  }
  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, 0x8(%rsp)
movl %r8d, 0xc(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
pushq $-0x1
popq %r12
xorl %ecx, %ecx
movq %rdi, 0x30(%rsp)
movzbl 0x10(%rdi), %r15d
incq %r12
cmpq %r15, %r12
jae 0xa454
movq %r15, 0x18(%rsp)
leaq 0x28(%rcx), %r14
movq 0x8(%rdi), %r13
leaq (%rcx,%r13), %rax
movzbl 0x10(%r13,%rcx), %ebp
movl %ebp, %edx
xorb $0x1, %dl
movzbl %dl, %edx
movl (%rax,%rdx,4), %ebx
movq 0x20(%r13,%rcx), %r15
movq %r15, %rdi
xorl %esi, %esi
movl %ebx, %edx
xorl %ecx, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
pushq 0x28(%rsp)
pushq $0x1
popq %rax
pushq %rax
callq 0x9101
popq %rcx
popq %rdx
subq $0x8, %rsp
movq %r15, %rdi
xorl %esi, %esi
movl %ebx, %edx
xorl %ecx, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
pushq %rax
pushq 0x30(%rsp)
pushq $0x1
popq %rax
pushq %rax
callq 0x928d
movq 0x50(%rsp), %rdi
addq $0x20, %rsp
movq %r14, %rcx
testq %rax, %rax
je 0xa374
cmpb $0x0, 0xc(%rsp)
movq 0x18(%rsp), %r15
je 0xa454
movq (%rdi), %rdx
movq -0x8(%r13,%r14), %rcx
movzbl -0x18(%r13,%r14), %esi
movq (%rax), %rax
subq $0x30, %rsp
movq %rax, 0x18(%rsp)
andl $0x0, 0x10(%rsp)
movl %esi, 0x8(%rsp)
andl $0x0, (%rsp)
movl $0x1, 0x20(%rsp)
movzbl 0x38(%rsp), %esi
movq 0x40(%rsp), %rdi
xorl %r8d, %r8d
movl %ebx, %r9d
callq 0x93b3
addq $0x30, %rsp
cmpq %r15, %r12
setb %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: updatePairedAln
void updatePairedAln(Aln* a, uint16_t flag,
    uint32_t pos, int length, float score) {
  if (flag & 0x40)
    a->pos[0] = flag & 0x10 ? pos + length : pos;
  else
    a->pos[1] = flag & 0x10 ? pos + length : pos;
  if (score == NOSCORE)
    a->score = NOSCORE;
  else if (a->score != NOSCORE)
    a->score += score;
  a->full = true;
}

// Assembly:
movl %esi, %eax
shll $0x1b, %eax
sarl $0x1f, %eax
andl %ecx, %eax
addl %edx, %eax
testb $0x40, %sil
jne 0xad91
movl %eax, 0x4(%rdi)
jmp 0xad93
movl %eax, (%rdi)
movss 0x53f1(%rip), %xmm1     # 0x1018c
ucomiss %xmm1, %xmm0
jne 0xada2
jnp 0xadb6
movss 0x8(%rdi), %xmm1
ucomiss 0x53de(%rip), %xmm1     # 0x1018c
jne 0xadb2
jnp 0xadbb
addss %xmm0, %xmm1
movss %xmm1, 0x8(%rdi)
movb $0x1, 0xe(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: savePairedAln
bool savePairedAln(Aln** aln, int* alnLen,
    uint16_t flag, Chrom* chrom, uint32_t pos,
    int length, uint32_t pnext, float score) {

  // check for excessive alignments
  if (*alnLen == MAX_ALNS)
    return false;

  // save aln info
  Aln* a = *aln + *alnLen;
  a->chrom = chrom;
  a->score = score;
  a->primary = (bool) (!(flag & 0x100));
  a->full = false;
  a->paired = true;

  // save positions for this aln (corrected if rev-comp),
  //   and for its pair (pnext, uncorrected)
  if (flag & 0x40) {
    a->pos[0] = flag & 0x10 ? pos + length : pos;
    a->pos[1] = pnext;
    a->first = true;
  } else {
    a->pos[0] = pnext;
    a->pos[1] = flag & 0x10 ? pos + length : pos;
    a->first = false;
  }

  (*alnLen)++;
  return true;
}

// Assembly:
movslq (%rsi), %rax
cmpq $0x80, %rax
je 0xae29
movl 0x8(%rsp), %r10d
movq (%rdi), %rdi
imulq $0x28, %rax, %r11
movq %rcx, 0x20(%rdi,%r11)
movss %xmm0, 0x8(%rdi,%r11)
movzwl %dx, %ecx
btl $0x8, %ecx
setae 0xc(%rdi,%r11)
movl %ecx, %edx
andl $0x40, %edx
shll $0x1b, %ecx
sarl $0x1f, %ecx
andl %r9d, %ecx
addl %r8d, %ecx
testl %edx, %edx
movl %ecx, %r8d
cmovel %r10d, %r8d
cmovnel %r10d, %ecx
movw $0x1, 0xd(%rdi,%r11)
shrl $0x6, %edx
movl %r8d, (%rdi,%r11)
movl %ecx, 0x4(%rdi,%r11)
movb %dl, 0xf(%rdi,%r11)
incl (%rsi)
cmpl $0x80, %eax
setne %al
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: saveSingleAln
bool saveSingleAln(Aln** aln, int* alnLen,
    uint16_t flag, Chrom* chrom, uint32_t pos,
    int length, float score) {

  // check for excessive alignments
  if (*alnLen == MAX_ALNS)
    return false;

  // save aln info
  Aln* a = *aln + *alnLen;
  a->chrom = chrom;
  a->score = score;
  a->primary = (bool) (!(flag & 0x100));
  a->paired = false;
  a->strand = (bool) (!(flag & 0x10));
  a->first = (bool) (flag & 0x40);
  a->pos[0] = pos;
  a->pos[1] = pos + length;
  (*alnLen)++;
  return true;
}

// Assembly:
movslq (%rsi), %rax
cmpq $0x80, %rax
je 0xae85
movq (%rdi), %rdi
imulq $0x28, %rax, %r10
movq %rcx, 0x20(%rdi,%r10)
movss %xmm0, 0x8(%rdi,%r10)
movzwl %dx, %ecx
btl $0x8, %ecx
setae 0xc(%rdi,%r10)
movb $0x0, 0xd(%rdi,%r10)
testb $0x10, %cl
sete 0x10(%rdi,%r10)
shrb $0x6, %cl
andb $0x1, %cl
movb %cl, 0xf(%rdi,%r10)
movl %r8d, (%rdi,%r10)
addl %r8d, %r9d
movl %r9d, 0x4(%rdi,%r10)
incl (%rsi)
cmpl $0x80, %eax
setne %al
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: sumQual
uint16_t sumQual(char* qual, int len, int offset) {
  if (qual[0] == 0xFF)  // BAM 'null' value
    return 0;
  int sum = 0;
  for (int i = 0; i < len; i++)
    sum += qual[i] - offset;
  return sum > UINT16_MAX ? UINT16_MAX : (uint16_t) sum;
}

// Assembly:
xorl %eax, %eax
testl %esi, %esi
cmovlel %eax, %esi
xorl %ecx, %ecx
cmpq %rax, %rsi
je 0xaeab
movsbl (%rdi,%rax), %r8d
subl %edx, %ecx
addl %r8d, %ecx
incq %rax
jmp 0xae97
movl $0xffff, %eax           # imm = 0xFFFF
cmpl %eax, %ecx
cmovll %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: loadChrom
void loadChrom(char* line, int* chromLen, Chrom** chrom,
    int xcount, char** xchrList, int xBedLen, Bed* xBed,
    bool ctrl, bool verbose) {
  // parse SAM header line for chrom info
  char* name = NULL, *len = NULL;
  char* field = strtok(NULL, TAB);
  while (field != NULL) {
    if (!strncmp(field, "SN:", 3))
      name = field + 3;
    else if (!strncmp(field, "LN:", 3))
      len = field + 3;
    field = strtok(NULL, TAB);
  }
  if (name == NULL || len == NULL)
    return;

  // remove trailing '\n'
  int i;
  for (i = 0; name[i] != '\n' && name[i] != '\0'; i++) ;
  name[i] = '\0';
  for (i = 0; len[i] != '\n' && len[i] != '\0'; i++) ;
  len[i] = '\0';

  // save chrom info to array (*chrom)
  saveChrom(name, (uint32_t) getInt(len), chromLen, chrom,
    xcount, xchrList, xBedLen, xBed, ctrl, verbose);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r12
xorl %r13d, %r13d
leaq 0x67a1(%rip), %r14      # 0x11ab1
xorl %ebx, %ebx
xorl %edi, %edi
movq %r14, %rsi
callq 0x2280
testq %rax, %rax
je 0xb35c
movzbl (%rax), %ecx
cmpl $0x4c, %ecx
je 0xb345
cmpl $0x53, %ecx
jne 0xb312
cmpb $0x4e, 0x1(%rax)
jne 0xb312
movq %rax, %rcx
addq $0x3, %rcx
cmpb $0x3a, 0x2(%rax)
cmoveq %rcx, %r13
jmp 0xb312
cmpb $0x4e, 0x1(%rax)
jne 0xb312
movq %rax, %rcx
addq $0x3, %rcx
cmpb $0x3a, 0x2(%rax)
cmoveq %rcx, %rbx
jmp 0xb312
testq %r13, %r13
je 0xb37a
testq %rbx, %rbx
je 0xb37a
movq %r13, %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0xb380
cmpl $0xa, %ecx
je 0xb380
incq %rax
jmp 0xb369
addq $0x18, %rsp
jmp 0xb3d6
movb $0x0, (%rax)
movq %rbx, %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0xb397
cmpl $0xa, %ecx
je 0xb397
incq %rax
jmp 0xb386
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x27cf
movzbl 0x60(%rsp), %r10d
movzbl 0x58(%rsp), %r11d
movq %r13, %rdi
movl %eax, %esi
movq %r12, %rdx
movq %r15, %rcx
movl %ebp, %r8d
movq 0x8(%rsp), %r9
pushq %r10
pushq %r11
pushq 0x60(%rsp)
pushq 0x28(%rsp)
callq 0xb12f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: checkHeader
void checkHeader(char* line, int* chromLen, Chrom** chrom,
    int xcount, char** xchrList, int xBedLen, Bed* xBed,
    bool ctrl, bool sortOpt, bool verbose) {

  // load tag from SAM header line
  char* tag = strtok(line, TAB);
  if (tag == NULL)
    return;

  if (! strcmp(tag, "@HD")) {
    // first header line: check sort order
    char* order = NULL;
    char* field = strtok(NULL, TAB);
    while (field != NULL) {
      if (!strncmp(field, "SO:", 3))
        order = field + 3;
      field = strtok(NULL, TAB);
    }
    if (order != NULL) {
      // removing trailing '\n'
      int i;
      for (i = 0; order[i] != '\n' && order[i] != '\0'; i++) ;
      order[i] = '\0';
    }

    // sort order must be queryname
    if (sortOpt && (order == NULL
        || strcmp(order, "queryname")))
      exit(error("", ERRSORT));

  } else if (! strcmp(tag, "@SQ"))
    // load chrom lengths from header line
    loadChrom(line, chromLen, chrom, xcount, xchrList,
      xBedLen, xBed, ctrl, verbose);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %ebx
movq %r8, %r14
movl %ecx, %ebp
movq %rdx, %r15
movq %rsi, %r12
leaq 0x66b0(%rip), %rsi      # 0x11ab1
callq 0x2280
testq %rax, %rax
je 0xb4f7
movq %rax, %r13
leaq 0x669a(%rip), %rsi      # 0x11ab3
movq %rax, %rdi
callq 0x21a0
testl %eax, %eax
je 0xb46e
leaq 0x6695(%rip), %rsi      # 0x11ac1
movq %r13, %rdi
callq 0x21a0
testl %eax, %eax
jne 0xb4f7
movb 0x48(%rsp), %al
subq $0x8, %rsp
movzbl 0x60(%rsp), %edi
movzbl %al, %eax
movq %r12, %rsi
movq %r15, %rdx
movl %ebp, %ecx
movq %r14, %r8
movl %ebx, %r9d
pushq %rdi
pushq %rax
pushq 0x58(%rsp)
callq 0xb2e6
addq $0x28, %rsp
jmp 0xb4fb
movb 0x50(%rsp), %bpl
xorl %ebx, %ebx
leaq 0x6635(%rip), %r14      # 0x11ab1
xorl %edi, %edi
movq %r14, %rsi
callq 0x2280
testq %rax, %rax
je 0xb4a7
cmpb $0x53, (%rax)
jne 0xb47c
cmpb $0x4f, 0x1(%rax)
jne 0xb47c
movq %rax, %rcx
addq $0x3, %rcx
cmpb $0x3a, 0x2(%rax)
cmoveq %rcx, %rbx
jmp 0xb47c
testq %rbx, %rbx
je 0xb4f2
movq %rbx, %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0xb4c0
cmpl $0xa, %ecx
je 0xb4c0
incq %rax
jmp 0xb4af
movb $0x0, (%rax)
testb %bpl, %bpl
je 0xb4f7
leaq 0x65e8(%rip), %rsi      # 0x11ab7
movq %rbx, %rdi
callq 0x21a0
testl %eax, %eax
je 0xb4f7
leaq 0x662d(%rip), %rdi      # 0x11b0f
pushq $0x19
popq %rsi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0
testb %bpl, %bpl
jne 0xb4db
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: loadFields
bool loadFields(uint16_t* flag, char** rname, uint32_t* pos,
    uint8_t* mapq, char** cigar, char** rnext, uint32_t* pnext,
    int32_t* tlen, char** seq, char** qual, char** extra) {
  *extra = NULL;  // reset 'extra' fields
  int i = 2;
  char* field = strtok(NULL, TAB);
  while (field != NULL) {
    switch (i) {
      case FLAG: *flag = getInt(field); break;
      case RNAME: *rname = field; break;
      case POS: *pos = getInt(field) - 1; break;  // convert to 0-based
      case MAPQ: *mapq = getInt(field); break;
      case CIGAR: *cigar = field; break;
      case RNEXT: *rnext = field; break;
      case PNEXT: *pnext = getInt(field) - 1; break;  // convert to 0-based
      case TLEN: *tlen = getInt(field); break;
      case SEQ: *seq = field; break;
      case QUAL: *qual = field; break;
      default: return false;
    }
    if (++i > 11) {
      *extra = strtok(NULL, "\n");
      break;
    }
    field = strtok(NULL, TAB);
  }
  return i > 11;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, %rbp
movq 0x80(%rsp), %rax
andq $0x0, (%rax)
pushq $0x2
popq %r15
leaq 0x656c(%rip), %rbx      # 0x11ab1
leaq 0x4d6c(%rip), %r12      # 0x102b8
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2280
movq %rax, %r14
testq %rax, %rax
je 0xb606
leal -0x2(%r15), %eax
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x27cf
movw %ax, (%rbp)
jmp 0xb5dd
movq 0x18(%rsp), %rax
jmp 0xb5da
movq %r14, %rdi
callq 0x27cf
decl %eax
movq 0x8(%rsp), %rcx
jmp 0xb5d1
movq %r14, %rdi
callq 0x27cf
movq 0x10(%rsp), %rcx
movb %al, (%rcx)
jmp 0xb5dd
movq %r14, %rdi
callq 0x27cf
movq 0x68(%rsp), %rcx
jmp 0xb5d1
movq %r14, (%r13)
jmp 0xb5dd
movq 0x20(%rsp), %rax
jmp 0xb5da
movq %r14, %rdi
callq 0x27cf
decl %eax
movq 0x60(%rsp), %rcx
movl %eax, (%rcx)
jmp 0xb5dd
movq 0x70(%rsp), %rax
movq %r14, (%rax)
incl %r15d
jmp 0xb54c
movq 0x78(%rsp), %rax
movq %r14, (%rax)
leaq 0x600b(%rip), %rsi      # 0x115ff
xorl %edi, %edi
callq 0x2280
movq 0x80(%rsp), %rcx
movq %rax, (%rcx)
testq %r14, %r14
setne %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: getScore
float getScore(char* extra) {
  if (extra == NULL)
    return NOSCORE;
  char* end;
  char* field = strtok_r(extra, TAB, &end);
  while (field != NULL) {
    char* tag = strtok(field, COL);
    if (!strcmp(tag, SCORE)) {
      for (int i = 0; i < 2; i++) {
        tag = strtok(NULL, COL);
        if (tag == NULL)
          return NOSCORE;
        if (i)
          return getFloat(tag);
      }
    }
    field = strtok_r(NULL, TAB, &end);
  }
  return NOSCORE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xb6db
leaq 0x647b(%rip), %rbx      # 0x11ab1
movq %rsp, %r14
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2180
movq %rax, %r12
movss 0x4b3d(%rip), %xmm0     # 0x1018c
leaq 0x646f(%rip), %r15      # 0x11ac5
testq %r12, %r12
je 0xb6e3
movq %r12, %rdi
movq %r15, %rsi
callq 0x2280
cmpb $0x41, (%rax)
jne 0xb6bc
cmpb $0x53, 0x1(%rax)
jne 0xb6bc
movb 0x2(%rax), %bpl
testb %bpl, %bpl
jne 0xb6bc
movb $0x1, %r13b
xorl %edi, %edi
movq %r15, %rsi
callq 0x2280
testq %rax, %rax
je 0xb6b0
testb $0x1, %r13b
movl $0x0, %r13d
jne 0xb681
movq %rax, %rdi
callq 0x279a
testb %bpl, %bpl
je 0xb6d6
testq %r12, %r12
jne 0xb65f
jmp 0xb6d6
testb %bpl, %bpl
je 0xb6db
testq %r12, %r12
jne 0xb65f
jmp 0xb6db
xorl %edi, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2180
movq %rax, %r12
movss 0x4ab8(%rip), %xmm0     # 0x1018c
jmp 0xb656
testb %bpl, %bpl
je 0xb6e3
movss 0x4aa9(%rip), %xmm0     # 0x1018c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: parseCigar
int parseCigar(char* cigar, int* offset) {
  int length = 0; // length of sequence
  int pos = 0;    // position of current op in cigar
  char op;
  int len = strlen(cigar);
  for (int i = 0; i < len; i++) {
    if (cigar[i] < 0x30 || cigar[i] > 0x39) {
      op = cigar[i];
      cigar[i] = '\0';
      int opLen = getInt(cigar + pos); // length of current op
      switch (op) {
        case 'M':
        case '=':
        case 'X':
          length += opLen;
          break;
        case 'I':
        case 'S':
          length += opLen;
          *offset -= opLen;
          break;
        case 'D':
          *offset += opLen;
          break;
        case 'N':
        case 'H':
        case 'P':
          break;
        default: ;
          char msg[4] = "' '";
          msg[1] = op;
          exit(error(msg, ERRCIGAR));
      }
      pos = i + 1;
    }
  }
  return length;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x8(%rsp)
movq %rdi, %r14
callq 0x20f0
movq %rax, %r15
xorl %ecx, %ecx
testl %r15d, %r15d
cmovlel %ecx, %r15d
negq %r15
xorl %ebp, %ebp
leaq 0x1(%rcx), %r13
leaq (%r15,%r13), %rax
cmpq $0x1, %rax
je 0xb7ab
movb -0x1(%r14,%r13), %r12b
leal -0x3a(%r12), %eax
cmpb $-0xa, %al
jb 0xb73f
incq %r13
jmp 0xb722
movzbl %r12b, %ebx
movb $0x0, -0x1(%r14,%r13)
movslq %ecx, %rdi
addq %r14, %rdi
callq 0x27cf
leal -0x48(%rbx), %edx
cmpl $0x10, %edx
ja 0xb77d
movl $0x141, %ecx            # imm = 0x141
btl %edx, %ecx
movq %r13, %rcx
jb 0xb71e
movl $0x802, %ecx            # imm = 0x802
btl %edx, %ecx
jb 0xb78e
movl $0x10020, %ecx          # imm = 0x10020
btl %edx, %ecx
jb 0xb787
cmpl $0x44, %ebx
je 0xb79c
cmpl $0x3d, %ebx
jne 0xb7bc
addl %eax, %ebp
movq %r13, %rcx
jmp 0xb71e
addl %eax, %ebp
movq 0x8(%rsp), %rcx
subl %eax, (%rcx)
movq %r13, %rcx
jmp 0xb71e
movq 0x8(%rsp), %rcx
addl %eax, (%rcx)
movq %r13, %rcx
jmp 0xb71e
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14(%rsp), %rdi
movl $0x272027, (%rdi)       # imm = 0x272027
movb %r12b, 0x1(%rdi)
pushq $0x2c
popq %rsi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: calcDist
int calcDist(char* qname, char* seq, char* cigar) {
  int length = strcmp(seq, "*") ? strlen(seq) : 0;
  int offset = 0;
  if (strcmp(cigar, "*")) {
    int len = parseCigar(cigar, &offset);
    if (! length)
      length = len;
    else if (length != len)
      exit(error(qname, ERRMISM));
  } else if (! length)
    exit(error(qname, ERRINFO));
  return length + offset;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r15
movq %rdi, %rbx
cmpb $0x2a, (%rsi)
jne 0xb7f5
cmpb $0x0, 0x1(%rsi)
je 0xb832
movq %rsi, %rdi
callq 0x20f0
movq %rax, %r14
andl $0x0, 0xc(%rsp)
cmpb $0x2a, (%r15)
jne 0xb812
cmpb $0x0, 0x1(%r15)
je 0xb837
leaq 0xc(%rsp), %rsi
movq %r15, %rdi
callq 0xb6f2
testl %r14d, %r14d
je 0xb82d
cmpl %eax, %r14d
je 0xb83c
pushq $0xe
jmp 0xb850
movl %eax, %r14d
jmp 0xb83c
xorl %r14d, %r14d
jmp 0xb800
testl %r14d, %r14d
je 0xb84e
addl 0xc(%rsp), %r14d
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
pushq $0xf
popq %rsi
movq %rbx, %rdi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: readInt32
int32_t readInt32(gzFile in, bool end) {
  int32_t ans = 0;
  for (int i = 0; i < sizeof(int32_t); i++) {
    int m = gzgetc(in);
    if (m == -1) {
      if (end)
        exit(error("", ERRBAM));
      else
        return EOF;
    }
    ans = ans | ((m & 0xFF) << (i*8));
  }
  return ans;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %r14
xorl %r15d, %r15d
xorl %ebx, %ebx
cmpl $0x20, %r15d
je 0xc1e2
movl (%r14), %eax
testl %eax, %eax
je 0xc1bd
decl %eax
movl %eax, (%r14)
incq 0x10(%r14)
movq 0x8(%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%r14)
movzbl (%rax), %eax
jmp 0xc1ca
movq %r14, %rdi
callq 0x20a0
cmpl $-0x1, %eax
je 0xc1da
movzbl %al, %eax
movl %r15d, %ecx
shll %cl, %eax
orl %eax, %ebx
addl $0x8, %r15d
jmp 0xc196
testb %bpl, %bpl
jne 0xc1ef
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5919(%rip), %rdi      # 0x11b0f
pushq $0x13
popq %rsi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: loadInt32
int32_t loadInt32(char** block) {
  int32_t ans = 0;
  for (int i = 0; i < sizeof(int32_t); i++) {
    ans = ans | ((**block & 0xFF) << (i*8));
    (*block)++;
  }
  return ans;
}

// Assembly:
movq (%rdi), %rdx
incq %rdx
xorl %ecx, %ecx
xorl %eax, %eax
cmpl $0x20, %ecx
je 0xc228
movzbl -0x1(%rdx), %esi
shll %cl, %esi
orl %esi, %eax
movq %rdx, (%rdi)
incq %rdx
addl $0x8, %ecx
jmp 0xc210
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: loadBAMfields
void loadBAMfields(char** block, int32_t* refID, int32_t* pos,
    uint8_t* mapq, uint16_t* n_cigar_op, uint16_t* flag,
    int32_t* l_seq, int32_t* next_refID, int32_t* next_pos,
    int32_t* tlen, char** read_name, uint32_t** cigar,
    uint8_t** seq, char** qual, char** extra) {
  *refID = loadInt32(block);
  *pos = loadInt32(block);
  uint32_t bin_mq_nl = loadInt32(block);
  int8_t l_read_name = bin_mq_nl & 0xFF;
  *mapq = (bin_mq_nl >> 8) & 0xFF;
  uint32_t flag_nc = loadInt32(block);
  *n_cigar_op = flag_nc & 0xFFFF;
  *flag = (flag_nc >> 16) & 0xFFFF;
  *l_seq = loadInt32(block);
  *next_refID = loadInt32(block);
  *next_pos = loadInt32(block);
  *tlen = loadInt32(block);
  *read_name = *block;
  (*block) += l_read_name;
  *cigar = (uint32_t*) *block;
  (*block) += *n_cigar_op * sizeof(uint32_t);
  *seq = (uint8_t*) *block;
  (*block) += (*l_seq + 1)/2 * sizeof(uint8_t);
  *qual = *block;
  (*block) += *l_seq;
  *extra = *block;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %r15
movq %r8, %r14
movq %rcx, %rbp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
callq 0xc206
movl %eax, (%r13)
movq %rbx, %rdi
callq 0xc206
movl %eax, (%r12)
movq %rbx, %rdi
callq 0xc206
movb %ah, (%rbp)
movq %rax, %r12
movq %rbx, %rdi
callq 0xc206
movw %ax, (%r14)
shrl $0x10, %eax
movw %ax, (%r15)
movq %rbx, %rdi
callq 0xc206
movq 0x40(%rsp), %r15
movl %eax, (%r15)
movq %rbx, %rdi
callq 0xc206
movq 0x48(%rsp), %rcx
movl %eax, (%rcx)
movq %rbx, %rdi
callq 0xc206
movq 0x50(%rsp), %rcx
movl %eax, (%rcx)
movq %rbx, %rdi
callq 0xc206
movq 0x58(%rsp), %rcx
movl %eax, (%rcx)
movq (%rbx), %rax
movq 0x60(%rsp), %rcx
movq %rax, (%rcx)
movsbq %r12b, %rcx
addq %rax, %rcx
movq %rcx, (%rbx)
movq 0x68(%rsp), %rax
movq %rcx, (%rax)
movzwl (%r14), %eax
shll $0x2, %eax
addq (%rbx), %rax
movq %rax, (%rbx)
movq 0x70(%rsp), %rcx
movq %rax, (%rcx)
movslq (%r15), %rcx
leal 0x1(%rcx), %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
cltq
addq (%rbx), %rax
movq %rax, (%rbx)
movq 0x78(%rsp), %rdx
movq %rax, (%rdx)
addq (%rbx), %rcx
movq %rcx, (%rbx)
movq 0x80(%rsp), %rax
movq %rcx, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: calcDistBAM
int calcDistBAM(int32_t l_seq, uint16_t n_cigar_op,
    uint32_t* cigar) {
  int length = l_seq;
  for (int i = 0; i < n_cigar_op; i++) {
    uint8_t op = cigar[i] & 0xF;
    uint32_t op_len = cigar[i] >> 4;
    if (op == 1 || op == 4)  // 'I' or 'S'
      length -= op_len;
    else if (op == 2)        // 'D'
      length += op_len;
  }
  return length;
}

// Assembly:
movl %edi, %eax
movl %esi, %ecx
xorl %esi, %esi
cmpq %rsi, %rcx
je 0xc35c
movl (%rdx,%rsi,4), %edi
movl %edi, %r8d
andl $0xf, %r8d
shrl $0x4, %edi
cmpl $0x4, %r8d
je 0xc351
cmpl $0x2, %r8d
je 0xc355
cmpl $0x1, %r8d
jne 0xc357
subl %edi, %eax
jmp 0xc357
addl %edi, %eax
incq %rsi
jmp 0xc32d
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: arrayLen
int arrayLen(char* extra) {
  int size = 0;
  switch (extra[0]) {
    case 'c': size = sizeof(int8_t); break;
    case 'C': size = sizeof(uint8_t); break;
    case 's': size = sizeof(int16_t); break;
    case 'S': size = sizeof(uint16_t); break;
    case 'i': size = sizeof(int32_t); break;
    case 'I': size = sizeof(uint32_t); break;
    case 'f': size = sizeof(float); break;
    default: ;
      char msg[4] = "' '";
      msg[1] = extra[0];
      exit(error(msg, ERRTYPE));
  }
  extra++;
  int32_t count = loadInt32(&extra);
  return 1 + sizeof(int32_t) + size * count;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movzbl (%rdi), %eax
pushq $0x1
popq %rbx
cmpl $0x43, %eax
je 0xc392
cmpl $0x49, %eax
je 0xc38f
cmpl $0x53, %eax
je 0xc38b
cmpl $0x63, %eax
je 0xc392
cmpl $0x66, %eax
je 0xc38f
cmpl $0x69, %eax
je 0xc38f
cmpl $0x73, %eax
jne 0xc3b1
pushq $0x2
jmp 0xc391
pushq $0x4
popq %rbx
incq %rdi
leaq 0x8(%rsp), %rax
movq %rdi, (%rax)
movq %rax, %rdi
callq 0xc206
imull %ebx, %eax
addl $0x5, %eax
addq $0x10, %rsp
popq %rbx
retq
leaq 0x4(%rsp), %rdi
movl $0x272027, (%rdi)       # imm = 0x272027
movb %al, 0x1(%rdi)
pushq $0x1a
popq %rsi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: loadInt
int64_t loadInt(char* block, size_t size) {
  int64_t ans = 0;
  for (int i = 0; i < size; i++)
    ans = ans | ((block[i] & 0xFF) << (i*8));
  return ans;
}

// Assembly:
xorl %ecx, %ecx
xorl %edx, %edx
xorl %eax, %eax
cmpq %rdx, %rsi
je 0xc3f0
movzbl (%rdi,%rdx), %r8d
shll %cl, %r8d
movslq %r8d, %r8
orq %r8, %rax
incq %rdx
addl $0x8, %ecx
jmp 0xc3d5
retq
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: openWrite
void openWrite(char* outFile, File* out, bool gz) {
  if (outFile[0] == '-' && strlen(outFile) > 1)
    exit(error(outFile, ERRNAME));
  if (gz) {
    if (!strcmp(outFile + strlen(outFile) - strlen(GZEXT), GZEXT)
        || !strcmp(outFile, "/dev/null"))
      out->gzf = gzopen(outFile, "w");
    else if (!strcmp(outFile, "-"))
      out->gzf = gzdopen(fileno(stdout), "wb");
    else {
      // add ".gz" to outFile
      char* outFile2 = memalloc(strlen(outFile)
        + strlen(GZEXT) + 1);
      strcpy(outFile2, outFile);
      strcat(outFile2, GZEXT);
      out->gzf = gzopen(outFile2, "w");
      free(outFile2);
    }
    if (out->gzf == NULL)
      exit(error(outFile, ERROPENW));
  } else {
    out->f = (strcmp(outFile, "-") ?
      fopen(outFile, "w") : stdout);
    if (out->f == NULL)
      exit(error(outFile, ERROPENW));
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movb (%rdi), %r12b
cmpb $0x2d, %r12b
jne 0xd3cd
movq %rbx, %rdi
callq 0x20f0
cmpq $0x2, %rax
jae 0xd4c6
testb %bpl, %bpl
jne 0xd3d6
cmpb $0x0, 0x1(%rbx)
jne 0xd469
movq 0x9bfb(%rip), %rax      # 0x16fc0
movq (%rax), %rax
jmp 0xd478
testb %bpl, %bpl
je 0xd469
movq %rbx, %rdi
callq 0x20f0
movq %rax, %r15
leaq (%rbx,%rax), %rdi
addq $-0x3, %rdi
leaq 0x4708(%rip), %rsi      # 0x11af8
callq 0x21a0
testl %eax, %eax
je 0xd489
leaq 0x46f8(%rip), %rsi      # 0x11afc
movq %rbx, %rdi
callq 0x21a0
testl %eax, %eax
je 0xd489
cmpb $0x2d, %r12b
jne 0xd420
cmpb $0x0, 0x1(%rbx)
je 0xd4a7
addq $0x4, %r15
movq %r15, %rdi
callq 0x2752
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2070
movq %r12, %rdi
callq 0x20f0
movl $0x7a672e, (%r12,%rax)  # imm = 0x7A672E
leaq 0x46b5(%rip), %rsi      # 0x11b06
movq %r12, %rdi
callq 0x2260
movq %rax, %r15
movq %rax, (%r14)
movq %r12, %rdi
callq 0x2040
jmp 0xd49e
leaq 0x4696(%rip), %rsi      # 0x11b06
movq %rbx, %rdi
callq 0x2270
movq %rax, (%r14)
testq %rax, %rax
je 0xd4a3
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4676(%rip), %rsi      # 0x11b06
movq %rbx, %rdi
callq 0x2260
movq %rax, %r15
movq %rax, (%r14)
testq %r15, %r15
jne 0xd480
pushq $0x2
jmp 0xd4c8
movq 0x9b12(%rip), %rax      # 0x16fc0
movq (%rax), %rdi
callq 0x2210
leaq 0x464b(%rip), %rsi      # 0x11b08
movl %eax, %edi
callq 0x20c0
jmp 0xd498
pushq $0x2b
popq %rsi
movq %rbx, %rdi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: checkBAM
bool checkBAM(File in, bool gz) {
  if (! gz)
    return false;
  char magic[5] = "BAM\1";  // BAM magic string
  for (int i = 0; i < 4; i++) {
    char m = gzgetc(in.gzf);
    if (m == -1)
      exit(error("", ERROPEN));
    if (m != magic[i]) {
      // push back chars before returning false
      if (gzungetc(m, in.gzf) == -1)
        exit(error("", ERRUNGET));
      for (int j = i - 1; j > -1; j--)
        if (gzungetc(magic[j], in.gzf) == -1)
          exit(error("", ERRUNGET));
      return false;
    }
  }
  return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testl %esi, %esi
je 0xd54e
movq %rdi, %rbx
xorl %r14d, %r14d
leaq 0x461c(%rip), %r15      # 0x11b0b
cmpq $0x4, %r14
je 0xd52a
movl (%rbx), %eax
testl %eax, %eax
je 0xd513
decl %eax
movl %eax, (%rbx)
incq 0x10(%rbx)
movq 0x8(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rbx)
movb (%rax), %al
jmp 0xd51b
movq %rbx, %rdi
callq 0x20a0
cmpb $-0x1, %al
je 0xd556
cmpb (%r14,%r15), %al
jne 0xd52e
incq %r14
jmp 0xd4ef
movb $0x1, %al
jmp 0xd550
movsbl %al, %edi
movq %rbx, %rsi
callq 0x20b0
cmpl $-0x1, %eax
je 0xd56e
testq %r14, %r14
jle 0xd54e
movsbl -0x1(%r14,%r15), %edi
decq %r14
jmp 0xd531
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
leaq 0x45b2(%rip), %rdi      # 0x11b0f
pushq $0x1
popq %rbx
movl %ebx, %esi
callq 0x2724
movl %ebx, %edi
callq 0x22a0
leaq 0x459a(%rip), %rdi      # 0x11b0f
pushq $0x29
popq %rsi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: openRead
bool openRead(char* inFile, File* in) {

  // open file or stdin
  bool stdinBool = ! strcmp(inFile, "-");
  FILE* dummy = (stdinBool ? stdin : fopen(inFile, "r"));
  if (dummy == NULL)
    exit(error(inFile, ERROPEN));

  // check for gzip compression: magic number 0x1F, 0x8B
  bool gzip = true;
  int save = 0;  // first char to pushback (for stdin)
  int i, j;
  for (i = 0; i < 2; i++) {
    j = fgetc(dummy);
    if (j == EOF)
      exit(error(inFile, ERROPEN));
    if ( (i && (unsigned char) j != 0x8B)
        || (! i && (unsigned char) j != 0x1F) ) {
      gzip = false;
      break;
    }
    if (! i)
      save = j;
  }

  // for stdin, push back chars
  if (stdinBool) {
    if (gzip)
      exit(error("", ERRGZIP));
    if (ungetc(j, dummy) == EOF)
      exit(error("", ERRUNGET));
    if (i && ungetc(save, dummy) == EOF)
      exit(error("", ERRUNGET));
  }

  // open file
  if (gzip) {
    if (fclose(dummy))
      exit(error("<dummy>", ERRCLOSE));
    in->gzf = gzopen(inFile, "r");
    if (in->gzf == NULL)
      exit(error(inFile, ERROPEN));
  } else {
    if (! stdinBool)
      rewind(dummy);
    in->f = dummy;
  }

  return gzip;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, (%rsp)
movq %rdi, %r14
cmpb $0x2d, (%rdi)
jne 0xd5a7
cmpb $0x0, 0x1(%r14)
je 0xd699
leaq 0x318c(%rip), %rsi      # 0x1073a
movq %r14, %rdi
callq 0x2270
movq %rax, %r15
xorl %r13d, %r13d
testq %r15, %r15
je 0xd62d
xorl %ebp, %ebp
pushq $0x1f
popq %rbx
xorl %r12d, %r12d
cmpl $0x2, %r12d
je 0xd5f9
movq %r15, %rdi
callq 0x2140
cmpl $-0x1, %eax
je 0xd62d
testl %r12d, %r12d
movzbl %al, %ecx
movl $0x8b, %edx
cmovel %ebx, %edx
cmpl %edx, %ecx
jne 0xd641
testl %r12d, %r12d
cmovel %eax, %ebp
incl %r12d
jmp 0xd5c9
testb %r13b, %r13b
jne 0xd6ab
movq %r15, %rdi
callq 0x20d0
testl %eax, %eax
jne 0xd6b6
leaq 0x3121(%rip), %rsi      # 0x1073a
movq %r14, %rdi
callq 0x2260
movq (%rsp), %rcx
movq %rax, (%rcx)
testq %rax, %rax
jne 0xd683
pushq $0x1
popq %rbx
movq %r14, %rdi
movl %ebx, %esi
callq 0x2724
movl %ebx, %edi
callq 0x22a0
testb %r13b, %r13b
je 0xd674
movl %eax, %edi
movq %r15, %rsi
callq 0x2230
cmpl $-0x1, %eax
je 0xd669
testl %r12d, %r12d
je 0xd67c
movl %ebp, %edi
movq %r15, %rsi
callq 0x2230
cmpl $-0x1, %eax
jne 0xd67c
leaq 0x449f(%rip), %rdi      # 0x11b0f
pushq $0x29
jmp 0xd6bf
movq %r15, %rdi
callq 0x2120
movq (%rsp), %rax
movq %r15, (%rax)
cmpl $0x2, %r12d
setae %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9928(%rip), %rax      # 0x16fc8
movq (%rax), %r15
movb $0x1, %r13b
jmp 0xd5bc
leaq 0x445d(%rip), %rdi      # 0x11b0f
pushq $0x2a
jmp 0xd6bf
leaq 0x4453(%rip), %rdi      # 0x11b10
pushq $0x3
popq %rsi
callq 0x2724
pushq $0x1
popq %rdi
callq 0x22a0
// File: /workspace/github_c_makefile_star2_O2/jsh58[P]Genrich/Genrich.c
// Function: saveXChrom
int saveXChrom(char* xchrom, char*** xchrList) {
  int i = 0;
  char* chrom = strtok(xchrom, COM);
  while (chrom != NULL) {
    *xchrList = (char**) memrealloc(*xchrList,
      (i + 1) * sizeof(char*));
    (*xchrList)[i] = (char*) memalloc(1 + strlen(chrom));
    strcpy((*xchrList)[i], chrom);
    i++;
    chrom = strtok(NULL, COM);
  }
  return i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
pushq $0x8
popq %r14
xorl %r12d, %r12d
leaq 0x26b1(%rip), %r15      # 0x11b18
movq %r15, %rsi
callq 0x2280
testq %rax, %rax
je 0xf4bc
movq %rax, %r13
movq (%rbx), %rdi
leaq 0x1(%r12), %rbp
movq %r14, %rsi
callq 0x2776
movq %rax, (%rbx)
movq %r13, %rdi
callq 0x20f0
leaq 0x1(%rax), %rdi
callq 0x2752
movq (%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq (%rbx), %rax
movq (%rax,%r12,8), %rdi
movq %r13, %rsi
callq 0x2070
addq $0x8, %r14
xorl %edi, %edi
movq %rbp, %r12
jmp 0xf467
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/weaslepalace[P]FreeRTOS_Posix_Sim/FreeRTOS_Kernel/croutine.c
// Function: xCoRoutineCreate
signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex )
{
signed portBASE_TYPE xReturn;
corCRCB *pxCoRoutine;

	/* Allocate the memory that will store the co-routine control block. */
	pxCoRoutine = ( corCRCB * ) pvPortMalloc( sizeof( corCRCB ) );
	if( pxCoRoutine )
	{
		/* If pxCurrentCoRoutine is NULL then this is the first co-routine to
		be created and the co-routine data structures need initialising. */
		if( pxCurrentCoRoutine == NULL )
		{
			pxCurrentCoRoutine = pxCoRoutine;
			prvInitialiseCoRoutineLists();
		}

		/* Check the priority is within limits. */
		if( uxPriority >= configMAX_CO_ROUTINE_PRIORITIES )
		{
			uxPriority = configMAX_CO_ROUTINE_PRIORITIES - 1;
		}

		/* Fill out the co-routine control block from the function parameters. */
		pxCoRoutine->uxState = corINITIAL_STATE;
		pxCoRoutine->uxPriority = uxPriority;
		pxCoRoutine->uxIndex = uxIndex;
		pxCoRoutine->pxCoRoutineFunction = pxCoRoutineCode;

		/* Initialise all the other co-routine control block parameters. */
		vListInitialiseItem( &( pxCoRoutine->xGenericListItem ) );
		vListInitialiseItem( &( pxCoRoutine->xEventListItem ) );

		/* Set the co-routine control block as a link back from the xListItem.
		This is so we can get back to the containing CRCB from a generic item
		in a list. */
		listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xGenericListItem ), pxCoRoutine );
		listSET_LIST_ITEM_OWNER( &( pxCoRoutine->xEventListItem ), pxCoRoutine );
	
		/* Event lists are always in priority order. */
		listSET_LIST_ITEM_VALUE( &( pxCoRoutine->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) uxPriority );
		
		/* Now the co-routine has been initialised it can be added to the ready
		list at the correct priority. */
		prvAddCoRoutineToReadyQueue( pxCoRoutine );

		xReturn = pdPASS;
	}
	else
	{		
		xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;
	}
	
	return xReturn;	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
pushq $0x70
popq %rdi
callq 0x4300
testq %rax, %rax
je 0x4959
movq %rax, %rbx
movq 0x66f2(%rip), %rax      # 0xafd0
cmpq $0x0, (%rax)
jne 0x48ec
movq %rbx, (%rax)
callq 0x44c0
xorl %r13d, %r13d
testq %r12, %r12
setne %r13b
andw $0x0, 0x68(%rbx)
movq %r13, 0x58(%rbx)
movq %r14, 0x60(%rbx)
movq %r15, (%rbx)
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x4050
movq %rbx, %rdi
addq $0x30, %rdi
callq 0x4050
movq %rbx, 0x20(%rbx)
movq %rbx, 0x48(%rbx)
pushq $0xa
popq %rax
subl %r13d, %eax
movl %eax, 0x30(%rbx)
movq 0x58(%rbx), %rax
movq 0x663e(%rip), %rcx      # 0xaf78
cmpq (%rcx), %rax
jbe 0x4942
movq %rax, (%rcx)
imulq $0x28, %rax, %rdi
addq 0x6553(%rip), %rdi      # 0xaea0
movq %r14, %rsi
callq 0x4760
pushq $0x1
jmp 0x495b
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/weaslepalace[P]FreeRTOS_Posix_Sim/FreeRTOS_Kernel/croutine.c
// Function: prvInitialiseCoRoutineLists
static void prvInitialiseCoRoutineLists( void )
{
unsigned portBASE_TYPE uxPriority;

	for( uxPriority = 0; uxPriority < configMAX_CO_ROUTINE_PRIORITIES; uxPriority++ )
	{
		vListInitialise( ( xList * ) &( pxReadyCoRoutineLists[ uxPriority ] ) );
	}

	vListInitialise( ( xList * ) &xDelayedCoRoutineList1 );
	vListInitialise( ( xList * ) &xDelayedCoRoutineList2 );
	vListInitialise( ( xList * ) &xPendingReadyCoRoutineList );

	/* Start with pxDelayedCoRoutineList using list1 and the
	pxOverflowDelayedCoRoutineList using list2. */
	pxDelayedCoRoutineList = &xDelayedCoRoutineList1;
	pxOverflowDelayedCoRoutineList = &xDelayedCoRoutineList2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
xorl %ebx, %ebx
movq 0x6525(%rip), %r14      # 0xaea0
cmpq $0x50, %rbx
je 0x4990
leaq (%rbx,%r14), %rdi
callq 0x43c0
addq $0x28, %rbx
jmp 0x497b
movq 0x65d9(%rip), %rbx      # 0xaf70
movq %rbx, %rdi
callq 0x43c0
movq 0x650a(%rip), %r14      # 0xaeb0
movq %r14, %rdi
callq 0x43c0
movq 0x6563(%rip), %rdi      # 0xaf18
callq 0x43c0
movq 0x6607(%rip), %rax      # 0xafc8
movq %rbx, (%rax)
movq 0x64bd(%rip), %rax      # 0xae88
movq %r14, (%rax)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/weaslepalace[P]FreeRTOS_Posix_Sim/FreeRTOS_Kernel/croutine.c
// Function: vCoRoutineAddToDelayedList
void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList )
{
portTickType xTimeToWake;

	/* Calculate the time to wake - this may overflow but this is
	not a problem. */
	xTimeToWake = xCoRoutineTickCount + xTicksToDelay;

	/* We must remove ourselves from the ready list before adding
	ourselves to the blocked list as the same list item is used for
	both lists. */
	vListRemove( ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );

	/* The list item will be inserted in wake time order. */
	listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake );

	if( xTimeToWake < xCoRoutineTickCount )
	{
		/* Wake time has overflowed.  Place this item in the
		overflow list. */
		vListInsert( ( xList * ) pxOverflowDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );
	}
	else
	{
		/* The wake time has not overflowed, so we can use the
		current block list. */
		vListInsert( ( xList * ) pxDelayedCoRoutineList, ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );
	}

	if( pxEventList )
	{
		/* Also add the co-routine to an event list.  If this is done then the
		function must be called with interrupts disabled. */
		vListInsert( pxEventList, &( pxCurrentCoRoutine->xEventListItem ) );
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edi, %r14d
movq 0x65b8(%rip), %r12      # 0xafa0
addl (%r12), %r14d
movq %rsi, %rbx
movq 0x65da(%rip), %r15      # 0xafd0
movq (%r15), %rdi
addq $0x8, %rdi
callq 0x4040
movq (%r15), %rsi
movl %r14d, 0x8(%rsi)
addq $0x8, %rsi
cmpl (%r12), %r14d
jae 0x4a1c
movq 0x646e(%rip), %rax      # 0xae88
jmp 0x4a23
movq 0x65a5(%rip), %rax      # 0xafc8
movq (%rax), %rdi
callq 0x4090
testq %rbx, %rbx
je 0x4a47
movq (%r15), %rsi
addq $0x30, %rsi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x4090
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/weaslepalace[P]FreeRTOS_Posix_Sim/FreeRTOS_Kernel/croutine.c
// Function: prvCheckPendingReadyList
static void prvCheckPendingReadyList( void )
{
	/* Are there any co-routines waiting to get moved to the ready list?  These
	are co-routines that have been readied by an ISR.  The ISR cannot access
	the	ready lists itself. */
	while( !listLIST_IS_EMPTY( &xPendingReadyCoRoutineList ) )
	{
		corCRCB *pxUnblockedCRCB;

		/* The pending ready list can be accessed by an ISR. */
		portDISABLE_INTERRUPTS();
		{	
			pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyCoRoutineList) );			
			vListRemove( &( pxUnblockedCRCB->xEventListItem ) );
		}
		portENABLE_INTERRUPTS();

		vListRemove( &( pxUnblockedCRCB->xGenericListItem ) );
		prvAddCoRoutineToReadyQueue( pxUnblockedCRCB );	
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x64b3(%rip), %r14      # 0xaf18
movq 0x650c(%rip), %r15      # 0xaf78
movq 0x642d(%rip), %r12      # 0xaea0
cmpq $0x0, (%r14)
je 0x4ac8
callq 0x4330
cmpq $0x0, (%r14)
je 0x4a8e
movq 0x18(%r14), %rax
movq 0x18(%rax), %r13
jmp 0x4a91
xorl %r13d, %r13d
leaq 0x30(%r13), %rdi
callq 0x4040
callq 0x43f0
leaq 0x8(%r13), %rbx
movq %rbx, %rdi
callq 0x4040
movq 0x58(%r13), %rax
cmpq (%r15), %rax
jbe 0x4ab7
movq %rax, (%r15)
imulq $0x28, %rax, %rdi
addq %r12, %rdi
movq %rbx, %rsi
callq 0x4760
jmp 0x4a73
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/weaslepalace[P]FreeRTOS_Posix_Sim/FreeRTOS_Kernel/croutine.c
// Function: vCoRoutineSchedule
void vCoRoutineSchedule( void )
{
	/* See if any co-routines readied by events need moving to the ready lists. */
	prvCheckPendingReadyList();

	/* See if any delayed co-routines have timed out. */
	prvCheckDelayedList();

	/* Find the highest priority queue that contains ready co-routines. */
	while( listLIST_IS_EMPTY( &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) ) )
	{
		if( uxTopCoRoutineReadyPriority == 0 )
		{
			/* No more co-routines to check. */
			return;
		}
		--uxTopCoRoutineReadyPriority;
	}

	/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the co-routines
	 of the	same priority get an equal share of the processor time. */
	listGET_OWNER_OF_NEXT_ENTRY( pxCurrentCoRoutine, &( pxReadyCoRoutineLists[ uxTopCoRoutineReadyPriority ] ) );

	/* Call the co-routine. */
	( pxCurrentCoRoutine->pxCoRoutineFunction )( pxCurrentCoRoutine, pxCurrentCoRoutine->uxIndex );

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
callq 0x41f0
callq 0x4390
movq 0x6397(%rip), %rcx      # 0xaf78
movq (%rcx), %rdx
imulq $0x28, %rdx, %rax
movq 0x62b1(%rip), %rsi      # 0xaea0
addq %rsi, %rax
addq $0x10, %rax
decq %rdx
cmpq $0x0, -0x10(%rax)
jne 0x4c0f
cmpq $-0x1, %rdx
je 0x4c40
movq %rdx, (%rcx)
addq $-0x28, %rax
jmp 0x4bf6
movq -0x8(%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, -0x8(%rax)
cmpq %rcx, %rax
jne 0x4c28
movq 0x8(%rcx), %rcx
movq %rcx, -0x8(%rax)
movq 0x18(%rcx), %rdi
movq 0x639d(%rip), %rax      # 0xafd0
movq %rdi, (%rax)
movq (%rdi), %rax
movq 0x60(%rdi), %rsi
popq %rbp
jmpq *%rax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/weaslepalace[P]FreeRTOS_Posix_Sim/FreeRTOS_Kernel/croutine.c
// Function: xCoRoutineRemoveFromEventList
signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList )
{
corCRCB *pxUnblockedCRCB;
signed portBASE_TYPE xReturn;

	/* This function is called from within an interrupt.  It can only access
	event lists and the pending ready list. */
	pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );
	vListRemove( &( pxUnblockedCRCB->xEventListItem ) );
	vListInsertEnd( ( xList * ) &( xPendingReadyCoRoutineList ), &( pxUnblockedCRCB->xEventListItem ) );

	if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority )
	{
		xReturn = pdTRUE;
	}
	else
	{
		xReturn = pdFALSE;
	}

	return xReturn;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
cmpq $0x0, (%rdi)
je 0x4c59
movq 0x18(%rdi), %rax
movq 0x18(%rax), %r14
jmp 0x4c5c
xorl %r14d, %r14d
leaq 0x30(%r14), %rbx
movq %rbx, %rdi
callq 0x4040
movq 0x62a9(%rip), %rdi      # 0xaf18
movq %rbx, %rsi
callq 0x4760
movq 0x58(%r14), %rcx
movq 0x634e(%rip), %rax      # 0xafd0
movq (%rax), %rdx
xorl %eax, %eax
cmpq 0x58(%rdx), %rcx
setae %al
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/weaslepalace[P]FreeRTOS_Posix_Sim/FreeRTOS_Kernel/queue.c
// Function: xQueueCreate
xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize )
{
xQUEUE *pxNewQueue;
size_t xQueueSizeInBytes;

	/* Allocate the new queue structure. */
	if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 )
	{
		pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) );
		if( pxNewQueue != NULL )
		{
			/* Create the list of pointers to queue items.  The queue is one byte
			longer than asked for to make wrap checking easier/faster. */
			xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1;

			pxNewQueue->pcHead = ( signed char * ) pvPortMalloc( xQueueSizeInBytes );
			if( pxNewQueue->pcHead != NULL )
			{
				/* Initialise the queue members as described above where the
				queue type is defined. */
				pxNewQueue->pcTail = pxNewQueue->pcHead + ( uxQueueLength * uxItemSize );
				pxNewQueue->uxMessagesWaiting = 0;
				pxNewQueue->pcWriteTo = pxNewQueue->pcHead;
				pxNewQueue->pcReadFrom = pxNewQueue->pcHead + ( ( uxQueueLength - 1 ) * uxItemSize );
				pxNewQueue->uxLength = uxQueueLength;
				pxNewQueue->uxItemSize = uxItemSize;
				pxNewQueue->xRxLock = queueUNLOCKED;
				pxNewQueue->xTxLock = queueUNLOCKED;

				/* Likewise ensure the event queues start with the correct state. */
				vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );
				vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );

				traceQUEUE_CREATE( pxNewQueue );
				return  pxNewQueue;
			}
			else
			{
				traceQUEUE_CREATE_FAILED();
				vPortFree( pxNewQueue );
			}
		}
	}

	/* Will only reach here if we could not allocate enough memory or no memory
	was required. */
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x4df9
movq %rsi, %r14
movq %rdi, %r15
movl $0x98, %edi
callq 0x4300
testq %rax, %rax
je 0x4df9
movq %rax, %rbx
movq %r14, %r12
imulq %r15, %r12
leaq 0x1(%r12), %rdi
callq 0x4300
movq %rax, (%rbx)
testq %rax, %rax
je 0x4df1
addq %rax, %r12
movq %r12, 0x8(%rbx)
movq $0x0, 0x70(%rbx)
movq %rax, 0x10(%rbx)
leaq -0x1(%r15), %rcx
imulq %r14, %rcx
addq %rax, %rcx
movq %rcx, 0x18(%rbx)
movq %r15, 0x78(%rbx)
movq %r14, 0x80(%rbx)
leaq 0x20(%rbx), %rdi
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x88(%rbx)
callq 0x43c0
movq %rbx, %rdi
addq $0x48, %rdi
callq 0x43c0
jmp 0x4dfb
movq %rbx, %rdi
callq 0x41b0
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/weaslepalace[P]FreeRTOS_Posix_Sim/FreeRTOS_Kernel/queue.c
// Function: xQueueTakeMutexRecursive
portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime )
	{
	portBASE_TYPE xReturn;

		/* Comments regarding mutual exclusion as per those within
		xQueueGiveMutexRecursive(). */

		traceTAKE_MUTEX_RECURSIVE( pxMutex );

		if( pxMutex->pxMutexHolder == xTaskGetCurrentTaskHandle() )
		{
			( pxMutex->uxRecursiveCallCount )++;
			xReturn = pdPASS;
		}
		else
		{
			xReturn = xQueueGenericReceive( pxMutex, NULL, xBlockTime, pdFALSE );

			/* pdPASS will only be returned if we successfully obtained the mutex,
			we may have blocked to reach here. */
			if( xReturn == pdPASS )
			{
				( pxMutex->uxRecursiveCallCount )++;
			}
		}

		return xReturn;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %rbx
movq 0x8(%rdi), %r14
callq 0x40d0
cmpq %rax, %r14
je 0x502e
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x4290
testq %rax, %rax
je 0x5036
incq 0x18(%rbx)
pushq $0x1
popq %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq