// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/tools/gt_sam_interface.c
// Function: gt_sam_interface_runner
static int gt_sam_interface_runner(GT_UNUSED int argc,
                                   GT_UNUSED const char **argv,
                                   GT_UNUSED int parsed_args,
                                   void *tool_arguments, GtError *err)
{
  GtSamInterfaceArguments *arguments = tool_arguments;
  int had_err = 0, count_out = 0;
  GtSamfileIterator *sa_iter;
  GtSamAlignment *sa_align;
  GtAlphabet *alpha = gt_alphabet_new_dna();

  gt_error_check(err);
  gt_assert(arguments);

  if (arguments->bool_is_sam) {
    if (gt_option_is_set(arguments->ref_idxfile))
      sa_iter = gt_samfile_iterator_new_sam(argv[parsed_args], alpha,
                                        gt_str_get(arguments->indexfilename),
                                        err);
    else
      sa_iter  = gt_samfile_iterator_new_sam(argv[parsed_args], alpha,
                                        NULL,
                                        err);

  }
  else {
    sa_iter = gt_samfile_iterator_new_bam(argv[parsed_args], alpha, err);
  }
  while (gt_samfile_iterator_next(sa_iter, &sa_align) > 0 &&
         arguments->lines - count_out) {
    uint16_t cig_len, idx;

    cig_len = gt_sam_alignment_cigar_length(sa_align);

    printf("%s\t%d\t%s\t",
           gt_sam_alignment_identifier(sa_align),
           (int) gt_sam_alignment_flag(sa_align),
           gt_samfile_iterator_reference_name(sa_iter,
                                         gt_sam_alignment_ref_num(sa_align)));
    if (gt_sam_alignment_is_unmapped(sa_align))
      printf("*");
    else {
      for (idx = 0; idx < cig_len; idx++) {
        printf("%d%c",
               (int) gt_sam_alignment_cigar_i_length(sa_align, idx),
               gt_sam_alignment_cigar_i_operation(sa_align, idx));
      }
    }
    printf("\t");
    gt_alphabet_decode_seq_to_fp(alpha, stdout,
        gt_sam_alignment_sequence(sa_align),
        gt_sam_alignment_read_length(sa_align));
    printf("\t%s\n",
           (char *) gt_sam_alignment_qualitystring(sa_align));
    count_out++;
  }
  gt_samfile_iterator_delete(sa_iter);
  gt_alphabet_delete(alpha);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r15
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r12
callq 0xd0ece
movq %rax, 0x10(%rsp)
testq %r15, %r15
je 0xbe60c
movq %r15, %rdi
callq 0xfcc32
testb %al, %al
jne 0xbe7ee
testq %rbx, %rbx
je 0xbe7e9
cmpb $0x1, (%rbx)
jne 0xbe644
movq 0x8(%rbx), %rdi
callq 0x10ac3f
movslq %ebp, %rcx
movq (%r12,%rcx,8), %r12
testb %al, %al
je 0xbe65a
movq 0x10(%rbx), %rdi
callq 0x11b0a1
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq %rax, %rdx
jmp 0xbe664
movslq %ebp, %rax
movq (%r12,%rax,8), %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0x170ae8
jmp 0xbe66c
movq %r12, %rdi
movq 0x10(%rsp), %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x170afc
movq %rax, %r15
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x170b0e
testl %eax, %eax
jle 0xbe7c6
leaq 0x29761d(%rip), %r12    # 0x355ca8
xorl %r14d, %r14d
movq %rbx, 0x20(%rsp)
movq %r15, 0x18(%rsp)
cmpl %r14d, 0x4(%rbx)
je 0xbe7c6
movq 0x8(%rsp), %rdi
callq 0x17044a
movl %eax, %r13d
movq 0x8(%rsp), %rdi
callq 0x170238
movq %rax, %rbp
movq 0x8(%rsp), %rdi
callq 0x1704b7
movl %eax, %ebx
movq 0x8(%rsp), %rdi
callq 0x17024b
movq %r15, %rdi
movl %eax, %esi
callq 0x170bb6
leaq 0x2975bb(%rip), %rdi    # 0x355c9e
movq %rbp, %rsi
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x17070
movq 0x8(%rsp), %rdi
callq 0x1704f4
testb %al, %al
je 0xbe70c
movl $0x2a, %edi
callq 0x17a20
jmp 0xbe74b
testw %r13w, %r13w
je 0xbe74b
xorl %r15d, %r15d
movq 0x8(%rsp), %rdi
movzwl %r15w, %ebx
movl %ebx, %esi
callq 0x17045d
movl %eax, %ebp
movq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x17047d
movzbl %al, %edx
movq %r12, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x17070
incl %r15d
cmpw %r15w, %r13w
jne 0xbe715
movl $0x9, %edi
callq 0x17a20
movq 0x3fa77c(%rip), %rax    # 0x4b8ed8
movq (%rax), %rbx
movq 0x8(%rsp), %rdi
callq 0x170360
movq %rax, %r13
movq 0x8(%rsp), %rdi
callq 0x1701e2
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0xd1412
movq 0x8(%rsp), %rdi
callq 0x170433
leaq 0x297695(%rip), %rdi    # 0x355e2f
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
incl %r14d
movq 0x18(%rsp), %r15
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0x170b0e
testl %eax, %eax
movq 0x20(%rsp), %rbx
jg 0xbe698
movq %r15, %rdi
callq 0x170a6a
movq 0x10(%rsp), %rdi
callq 0xd0e1c
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1e5e1
callq 0x1e5aa
nop