// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/tools/gt_compressedbits.c
// Function: gt_compressedbits_runner
static int gt_compressedbits_runner(GT_UNUSED int argc,
                                    GT_UNUSED const char **argv,
                                    GT_UNUSED int parsed_args,
                                    void *tool_arguments,
                                    GtError *err)
{
  GtCompressdbitsArguments *arguments = tool_arguments;
  int had_err = 0;
  GtUword idx;
  GtUint64 num_of_bits = 0ULL;
  GtBitsequence *bits = NULL;
  GtCompressedBitsequence *cbs = NULL, *read_cbs = NULL;
  GtStr *filename = gt_str_new();
  FILE *fp = NULL;

  gt_error_check(err);
  gt_assert(arguments);
  gt_assert(argc == parsed_args);

  if (gt_option_is_set(arguments->filename_op)) {
    FILE *file = NULL;
    gt_assert(arguments->filename != NULL);

    file = gt_xfopen(gt_str_get(arguments->filename), "r");
    if ((size_t) 1 != gt_xfread(&num_of_bits,
                                sizeof (num_of_bits), (size_t) 1, file)) {
      had_err = -1;
    }
    if (!had_err) {
      gt_log_log("bits to read: "GT_LLU"", num_of_bits);
      arguments->size = (GtUword) GT_NUMOFINTSFORBITS(num_of_bits);
      bits = gt_malloc(sizeof (*bits) * arguments->size);
      if ((size_t) arguments->size !=
          gt_xfread(bits, sizeof (*bits),
                    (size_t) arguments->size, file)) {
        had_err = -1;
      }
    }
    gt_xfclose(file);
  }
  else {
    bits = gt_calloc(sizeof (*bits), (size_t) arguments->size);
    num_of_bits = (GtUint64) (GT_INTWORDSIZE * arguments->size);

    if (arguments->fill_random) {
      for (idx = 0; idx < arguments->size; idx++) {
        bits[idx] =
          (GtBitsequence) (0xAAAAAAAAAAAAAAAAULL ^ gt_rand_max(ULONG_MAX));
      }
    }
    else {
      for (idx = 0; idx < arguments->size; idx++)
        bits[idx] = (GtBitsequence) (0xAAAAAAAAAAAAAAAAULL ^ idx);
    }
  }

  if (!had_err) {
    fp = gt_xtmpfp(filename);
    gt_fa_xfclose(fp);
    fp = NULL;

    gt_log_log("filename: %s", gt_str_get(filename));
    gt_log_log("size in words: "GT_WU"", arguments->size);
    cbs = gt_compressed_bitsequence_new(
                            bits, arguments->samplerate,
                            (GtUword) num_of_bits);
    gt_log_log("original size in MB: %2.3f",
               (sizeof (*bits) * arguments->size) / (1024.0 * 1024.0));
    gt_log_log("compressed size in MB: %2.3f",
               gt_compressed_bitsequence_size(cbs) / (1024.0 * 1024.0));
    gt_log_log("popcount table size thereof in MB: %2.3f",
               gt_popcount_tab_calculate_size(15U) / (1024.0 * 1024.0));
    had_err = gt_compressed_bitsequence_write(cbs, gt_str_get(filename), err);
  }
  if (!had_err)
  {
    read_cbs =
      gt_compressed_bitsequence_new_from_file(gt_str_get(filename), err);
    if (read_cbs == NULL)
      had_err = -1;
  }
  if (!had_err && bits != NULL && arguments->check_consistency) {
    for (idx = 0; (GtUint64) idx < num_of_bits; ++idx) {
      int GT_UNUSED bit = gt_compressed_bitsequence_access(read_cbs, idx);
      int GT_UNUSED original = GT_ISIBITSET(bits, idx) ? 1 : 0;
      gt_assert(gt_compressed_bitsequence_access(cbs, idx) == bit);
      gt_assert(original == bit);
    }
  }
  gt_compressed_bitsequence_delete(cbs);
  gt_compressed_bitsequence_delete(read_cbs);
  gt_free(bits);
  gt_str_delete(filename);
  return had_err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r12
movq %rcx, %r14
movl %edx, %ebx
movl %edi, %ebp
movq $0x0, (%rsp)
callq 0x11ac6c
movq %rax, %r13
testq %r12, %r12
je 0x9c624
movq %r12, %rdi
callq 0xfcc32
testb %al, %al
jne 0x9c9f4
testq %r14, %r14
je 0x9c9ea
cmpl %ebx, %ebp
jne 0x9c9ef
movq 0x30(%r14), %rdi
callq 0x10ac3f
testb %al, %al
je 0x9c717
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x9c9f9
callq 0x11b0a1
leaq 0x2be7f6(%rip), %rsi    # 0x35ae55
movq %rax, %rdi
callq 0x11f802
movq %rax, %rbx
movq %rsp, %rdi
movl $0x1, %r15d
movl $0x8, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x11f848
cmpq $0x1, %rax
jne 0x9c8e8
movq %r12, 0x10(%rsp)
movq (%rsp), %rsi
leaq 0x2ab47e(%rip), %rdi    # 0x347b1d
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
callq 0x103d72
movq (%rsp), %rax
leaq -0x1(%rax), %rdi
shrq $0x6, %rdi
incq %rdi
cmpq $0x40, %rax
cmovbq %r15, %rdi
movq %rdi, 0x8(%r14)
shlq $0x3, %rdi
leaq 0x2ab233(%rip), %rsi    # 0x347908
movl $0x98, %edx
callq 0x104226
movq %rax, %r15
movq 0x8(%r14), %rbp
movl $0x8, %esi
movq %rax, %rdi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x11f848
movq %rax, %r12
movq %rbx, %rdi
callq 0x11f771
cmpq %r12, %rbp
jne 0x9c996
movq 0x10(%rsp), %r12
jmp 0x9c7a4
movq 0x8(%r14), %rsi
leaq 0x2ab1e6(%rip), %rdx    # 0x347908
movl $0x8, %edi
movl $0xa2, %ecx
callq 0x10436a
movq %rax, %r15
movq 0x8(%r14), %rax
movq %rax, %rcx
shlq $0x6, %rcx
movq %rcx, (%rsp)
cmpb $0x0, 0x18(%r14)
je 0x9c780
testq %rax, %rax
je 0x9c7a4
movq %r12, %rbp
movabsq $-0x5555555555555556, %rbx # imm = 0xAAAAAAAAAAAAAAAA
xorl %r12d, %r12d
movq $-0x1, %rdi
callq 0x105d85
xorq %rbx, %rax
movq %rax, (%r15,%r12,8)
incq %r12
cmpq 0x8(%r14), %r12
jb 0x9c75f
movq %rbp, %r12
jmp 0x9c7a4
testq %rax, %rax
je 0x9c7a4
movabsq $-0x5555555555555556, %rax # imm = 0xAAAAAAAAAAAAAAAA
xorl %ecx, %ecx
movq %rcx, %rdx
xorq %rax, %rdx
movq %rdx, (%r15,%rcx,8)
incq %rcx
cmpq 0x8(%r14), %rcx
jb 0x9c791
leaq 0x2ab15d(%rip), %rdx    # 0x347908
movq $0x0, 0x8(%rsp)
movq %r13, %rdi
xorl %esi, %esi
movl $0xb2, %ecx
callq 0xfd35a
movq %rax, %rdi
callq 0xfd09a
movq %r13, %rdi
callq 0x11b0a1
leaq 0x2ab356(%rip), %rdi    # 0x347b30
movq %rax, %rsi
xorl %eax, %eax
callq 0x103d72
movq 0x8(%r14), %rsi
leaq 0x2ab34e(%rip), %rdi    # 0x347b3d
xorl %eax, %eax
callq 0x103d72
movl (%r14), %esi
movq (%rsp), %rdx
movq %r15, %rdi
callq 0x129358
movq %rax, %rbp
movq 0x8(%r14), %rax
shlq $0x3, %rax
movq %rax, %xmm1
punpckldq 0x2ab0c3(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2ab0cb(%rip), %xmm1   # 0x3478f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2ab0c7(%rip), %xmm0   # 0x347900
leaq 0x2ab310(%rip), %rdi    # 0x347b50
movb $0x1, %al
callq 0x103d72
movq %rbp, %rdi
callq 0x12aa45
movq %rax, %xmm1
punpckldq 0x2ab084(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2ab08c(%rip), %xmm1   # 0x3478f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2ab088(%rip), %xmm0   # 0x347900
leaq 0x2ab2ec(%rip), %rdi    # 0x347b6b
movb $0x1, %al
callq 0x103d72
movl $0xf, %edi
callq 0x164314
movq %rax, %xmm1
punpckldq 0x2ab043(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2ab04b(%rip), %xmm1   # 0x3478f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2ab047(%rip), %xmm0   # 0x347900
leaq 0x2ab2c8(%rip), %rdi    # 0x347b88
movb $0x1, %al
callq 0x103d72
movq %r13, %rdi
callq 0x11b0a1
movq %rbp, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x12aa7a
testl %eax, %eax
je 0x9c906
movl %eax, %ebx
jmp 0x9c99d
movq %rbx, %rdi
callq 0x11f771
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq $0x0, 0x8(%rsp)
xorl %r15d, %r15d
jmp 0x9c99b
movq %r13, %rdi
callq 0x11b0a1
movq %rax, %rdi
movq %r12, %rsi
callq 0x12abe7
xorl %ebx, %ebx
testq %rax, %rax
sete %bl
negl %ebx
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x9c99d
testq %r15, %r15
je 0x9c99d
cmpb $0x1, 0x19(%r14)
jne 0x9c9dc
cmpq $0x0, (%rsp)
je 0x9c99d
movq %r13, 0x10(%rsp)
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x129d03
movl %eax, %r12d
movq %r14, %rax
shrq $0x6, %rax
movq (%r15,%rax,8), %r13
movq %rbp, %rdi
movq %r14, %rsi
callq 0x129d03
cmpl %r12d, %eax
jne 0x9c9e5
movl %r14d, %ecx
shlq %cl, %r13
shrq $0x3f, %r13
cmpl %r13d, %r12d
jne 0x9c9e0
incq %r14
cmpq (%rsp), %r14
jb 0x9c94c
movq 0x10(%rsp), %r13
jmp 0x9c99d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %ebp, %ebp
movq %rbp, %rdi
callq 0x12afc8
movq 0x8(%rsp), %rdi
callq 0x12afc8
leaq 0x2aaf52(%rip), %rsi    # 0x347908
movq %r15, %rdi
movl $0xd4, %edx
callq 0x1045eb
movq %r13, %rdi
callq 0x11bdbf
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
jmp 0x9c99d
callq 0x18d56
callq 0x18d1d
callq 0x18dc8
callq 0x18ce4
callq 0x18cab
callq 0x18d8f
nop