// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/rcr.c
// Function: gt_rcr_analyse_alignment_data
static inline int gt_rcr_analyse_alignment_data(GtRcrEncoder *rcr_enc,
                                                GtTimer *timer,
                                                GtError *err)
{
  int had_err = 0;
  int32_t seq_id = 0;
  samfile_t *samfile = samopen(rcr_enc->samfilename, "rb", NULL);

  gt_assert(rcr_enc->sam_align != NULL);

  if (timer != NULL)
    gt_timer_show_progress(timer, "analyse sam/bam alignment data",
                           stdout);

  if (samfile == NULL) {
    gt_error_set(err, "Cannot open BAM file %s", rcr_enc->samfilename);
    had_err = -1;
  }

  while (!had_err &&
         samread(samfile, rcr_enc->sam_align) >= 0) {
    gt_assert(rcr_enc->sam_align != NULL);
    if (seq_id != rcr_enc->sam_align->core.tid) {
      rcr_enc->prev_readpos = 0;
      seq_id = rcr_enc->sam_align->core.tid;
      rcr_enc->cur_seq_startpos = gt_encseq_seqstartpos(rcr_enc->encseq,
                                                        (GtUword) seq_id);
    }
    if (rcr_enc->prev_readpos > (GtUword) rcr_enc->sam_align->core.pos) {
      gt_error_set(err, "file %s is not sorted", rcr_enc->samfilename);
      had_err = -1;
    }
    else {
      seq_id = rcr_enc->sam_align->core.tid;
      if (!(rcr_enc->sam_align->core.flag & BAM_FUNMAP))
        rcr_enc->numofreads++;
      else
        rcr_enc->numofunmappedreads++;

      had_err = rcr_get_read_infos(rcr_enc->sam_align, rcr_enc);
    }
  }

  /* end symbol */
  rcr_enc->present_cigar_ops[ENDOFRECORD] = (GtUint64)
                                              rcr_enc->numofreads;
  samclose(samfile);

  return had_err;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0xa0(%rax), %rdi
leaq 0x3bb6cf(%rip), %rsi    # 0x577ee5
xorl %eax, %eax
movl %eax, %edx
callq 0x36ba90
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
cmpq $0x0, 0x90(%rax)
jne 0x1bc86b
movq 0x47f766(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3597cf(%rip), %rsi    # 0x516013
leaq 0x3a4e59(%rip), %rdx    # 0x5616a4
leaq 0x3a4e6d(%rip), %rcx    # 0x5616bf
leaq 0x3a4c86(%rip), %r8     # 0x5614df
movl $0x3fc, %r9d            # imm = 0x3FC
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1bc86d
cmpq $0x0, 0x28(%rsp)
je 0x1bc890
movq 0x28(%rsp), %rdi
movq 0x47f6b7(%rip), %rax    # 0x63bf38
movq (%rax), %rdx
leaq 0x3a4e52(%rip), %rsi    # 0x5616dd
callq 0x121930
cmpq $0x0, 0x10(%rsp)
jne 0x1bc8bf
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0xa0(%rax), %rdx
leaq 0x3a4e4c(%rip), %rsi    # 0x5616fc
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
jmp 0x1bc8c1
xorl %eax, %eax
cmpl $0x0, 0x1c(%rsp)
movb %al, 0xf(%rsp)
jne 0x1bc8ee
movq 0x10(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x90(%rax), %rsi
callq 0x36c290
cmpl $0x0, %eax
setge %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x1bc8fb
jmp 0x1bca6e
jmp 0x1bc8fd
movq 0x30(%rsp), %rax
cmpq $0x0, 0x90(%rax)
jne 0x1bc944
movq 0x47f68d(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3596f6(%rip), %rsi    # 0x516013
leaq 0x3a4d80(%rip), %rdx    # 0x5616a4
leaq 0x3a4d94(%rip), %rcx    # 0x5616bf
leaq 0x3a4bad(%rip), %r8     # 0x5614df
movl $0x409, %r9d            # imm = 0x409
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1bc946
movl 0x18(%rsp), %eax
movq 0x30(%rsp), %rcx
movq 0x90(%rcx), %rcx
cmpl (%rcx), %eax
je 0x1bc9a1
movq 0x30(%rsp), %rax
movq $0x0, 0x1a8(%rax)
movq 0x30(%rsp), %rax
movq 0x90(%rax), %rax
movl (%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0x98(%rax), %rdi
movslq 0x18(%rsp), %rsi
callq 0xb0530
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x188(%rax)
movq 0x30(%rsp), %rax
movq 0x1a8(%rax), %rax
movq 0x30(%rsp), %rcx
movq 0x90(%rcx), %rcx
movslq 0x4(%rcx), %rcx
cmpq %rcx, %rax
jbe 0x1bc9eb
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0xa0(%rax), %rdx
leaq 0x3a4d3a(%rip), %rsi    # 0x561714
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
jmp 0x1bca69
movq 0x30(%rsp), %rax
movq 0x90(%rax), %rax
movl (%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x8(%rax), %rax
shrq $0x20, %rax
andq $0xffff, %rax           # imm = 0xFFFF
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x1bca38
movq 0x30(%rsp), %rax
movq 0x198(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x198(%rax)
jmp 0x1bca4f
movq 0x30(%rsp), %rax
movq 0x1a0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x1a0(%rax)
movq 0x30(%rsp), %rax
movq 0x90(%rax), %rdi
movq 0x30(%rsp), %rsi
callq 0x1bf250
movl %eax, 0x1c(%rsp)
jmp 0x1bc8c1
movq 0x30(%rsp), %rax
movq 0x198(%rax), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x138(%rax)
movq 0x10(%rsp), %rdi
callq 0x36c210
movl 0x1c(%rsp), %eax
addq $0x38, %rsp
retq
nopl (%rax)