// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, (%rsp)
callq 0xacb84
movq %rax, %r15
testq %r12, %r12
je 0x1d51e
movq %r12, %rdi
callq 0x89eb7
testb %al, %al
jne 0x1d961
testq %r14, %r14
je 0x1d902
cmpl %ebx, %ebp
jne 0x1d933
movq 0x30(%r14), %rdi
callq 0x9b4cb
testb %al, %al
movq %r15, 0x10(%rsp)
je 0x1d5eb
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x1d98f
callq 0xad1fa
leaq 0x2dd8cf(%rip), %rsi    # 0x2fae2d
movq %rax, %rdi
callq 0xb2ee0
movq %rax, %rbx
movq %rsp, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %r15
movq %r15, %rdx
movq %rax, %rcx
callq 0xb2fab
cmpq $0x1, %rax
jne 0x1d662
movq (%rsp), %rsi
leaq 0x2ca58a(%rip), %rdi    # 0x2e7b1d
xorl %eax, %eax
callq 0x92a82
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 0x2ca348(%rip), %rsi    # 0x2e7908
movl $0x98, %edx
callq 0x93160
movq %rax, %r15
movq 0x8(%r14), %r13
pushq $0x8
popq %rsi
movq %rax, %rdi
movq %r13, %rdx
movq %rbx, %rcx
callq 0xb2fab
cmpq %rax, %r13
sete %r13b
jmp 0x1d668
movabsq $-0x5555555555555556, %r13 # imm = 0xAAAAAAAAAAAAAAAA
movq 0x8(%r14), %rsi
leaq 0x2ca308(%rip), %rdx    # 0x2e7908
pushq $0x8
popq %rdi
movl $0xa2, %ecx
callq 0x9334a
movq %rax, %r15
movq 0x8(%r14), %rax
movq %rax, %rcx
shlq $0x6, %rcx
movq %rcx, (%rsp)
cmpb $0x0, 0x18(%r14)
je 0x1d648
xorl %ebp, %ebp
pushq $-0x1
popq %rbx
cmpq %rax, %rbp
jae 0x1d679
movq %rbx, %rdi
callq 0x955fa
xorq %r13, %rax
movq %rax, (%r15,%rbp,8)
incq %rbp
movq 0x8(%r14), %rax
jmp 0x1d62b
xorl %ecx, %ecx
cmpq %rax, %rcx
jae 0x1d679
movq %rcx, %rax
xorq %r13, %rax
movq %rax, (%r15,%rcx,8)
incq %rcx
movq 0x8(%r14), %rax
jmp 0x1d64a
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0xb2e04
testb %r13b, %r13b
je 0x1d87e
leaq 0x2ca288(%rip), %rdx    # 0x2e7908
movq $0x0, 0x8(%rsp)
movq 0x10(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
movl $0xb2, %ecx
callq 0x8abea
movq %rax, %rdi
callq 0x8a5e5
movq %r13, %rdi
callq 0xad1fa
leaq 0x2ca47c(%rip), %rdi    # 0x2e7b30
movq %rax, %rsi
xorl %eax, %eax
callq 0x92a82
movq 0x8(%r14), %rsi
leaq 0x2ca474(%rip), %rdi    # 0x2e7b3d
xorl %eax, %eax
callq 0x92a82
movl (%r14), %esi
movq (%rsp), %rdx
movq %r15, %rdi
callq 0xbeef4
movq %rax, %rbp
movq 0x8(%r14), %rax
shlq $0x3, %rax
movq %rax, %xmm1
punpckldq 0x2ca1e9(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2ca1f1(%rip), %xmm1   # 0x2e78f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2ca1ed(%rip), %xmm0   # 0x2e7900
leaq 0x2ca436(%rip), %rdi    # 0x2e7b50
movb $0x1, %al
callq 0x92a82
movq %rbp, %rdi
callq 0xbffec
movq %rax, %xmm1
punpckldq 0x2ca1aa(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2ca1b2(%rip), %xmm1   # 0x2e78f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2ca1ae(%rip), %xmm0   # 0x2e7900
leaq 0x2ca412(%rip), %rdi    # 0x2e7b6b
movb $0x1, %al
callq 0x92a82
pushq $0xf
popq %rdi
callq 0x1046b6
movq %rax, %xmm1
punpckldq 0x2ca16b(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x2ca173(%rip), %xmm1   # 0x2e78f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x2ca16f(%rip), %xmm0   # 0x2e7900
leaq 0x2ca3f0(%rip), %rdi    # 0x2e7b88
movb $0x1, %al
callq 0x92a82
movq %r13, %rdi
callq 0xad1fa
movq %rbp, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0xc0021
testl %eax, %eax
je 0x1d7c0
movl %eax, %ebx
jmp 0x1d890
movq %r13, %rdi
callq 0xad1fa
movq %rax, %rdi
movq %r12, %rsi
callq 0xc016b
xorl %ebx, %ebx
testq %rax, %rax
sete %bl
negl %ebx
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x1d890
testq %r15, %r15
je 0x1d890
cmpb $0x1, 0x19(%r14)
jne 0x1d88e
xorl %r14d, %r14d
cmpq (%rsp), %r14
jae 0x1d890
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xbf3df
movl %eax, %r12d
movq %r14, %rax
shrq $0x6, %rax
movq (%r15,%rax,8), %r13
movq %rbp, %rdi
movq %r14, %rsi
callq 0xbf3df
cmpl %r12d, %eax
jne 0x1d8d1
movl %r14d, %ecx
shlq %cl, %r13
shrq $0x3f, %r13
incq %r14
cmpl %r13d, %r12d
je 0x1d802
movq 0x41a714(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2c77b5(%rip), %rsi    # 0x2e5013
leaq 0x2ca37e(%rip), %rdx    # 0x2e7be3
leaq 0x2ca268(%rip), %rcx    # 0x2e7ad4
leaq 0x2ca095(%rip), %r8     # 0x2e7908
movl $0xcf, %r9d
jmp 0x1d9bb
pushq $-0x1
popq %rbx
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
jmp 0x1d890
xorl %ebx, %ebx
movq %rbp, %rdi
callq 0xc0517
movq 0x8(%rsp), %rdi
callq 0xc0517
leaq 0x2ca05f(%rip), %rsi    # 0x2e7908
movq %r15, %rdi
movl $0xd4, %edx
callq 0x936f9
movq 0x10(%rsp), %rdi
callq 0xae103
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x41a690(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2c7731(%rip), %rsi    # 0x2e5013
leaq 0x2ca2c8(%rip), %rdx    # 0x2e7bb1
leaq 0x2ca1e4(%rip), %rcx    # 0x2e7ad4
leaq 0x2ca011(%rip), %r8     # 0x2e7908
movl $0xce, %r9d
jmp 0x1d9bb
movq 0x41a65f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2c7700(%rip), %rsi    # 0x2e5013
leaq 0x32ad39(%rip), %rdx    # 0x348653
leaq 0x2ca1b3(%rip), %rcx    # 0x2e7ad4
leaq 0x2c9fe0(%rip), %r8     # 0x2e7908
movl $0x89, %r9d
jmp 0x1d9bb
movq 0x41a62e(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2c76cf(%rip), %rsi    # 0x2e5013
leaq 0x2ca1a2(%rip), %rdx    # 0x2e7aed
leaq 0x2ca182(%rip), %rcx    # 0x2e7ad4
leaq 0x2c9faf(%rip), %r8     # 0x2e7908
movl $0x8a, %r9d
jmp 0x1d9bb
movq 0x41a600(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2c76a1(%rip), %rsi    # 0x2e5013
leaq 0x2c7846(%rip), %rdx    # 0x2e51bf
leaq 0x2ca154(%rip), %rcx    # 0x2e7ad4
leaq 0x2c9f81(%rip), %r8     # 0x2e7908
movl $0x88, %r9d
jmp 0x1d9bb
movq 0x41a5d2(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2c7673(%rip), %rsi    # 0x2e5013
leaq 0x2ca15a(%rip), %rdx    # 0x2e7b01
leaq 0x2ca126(%rip), %rcx    # 0x2e7ad4
leaq 0x2c9f53(%rip), %r8     # 0x2e7908
movl $0x8e, %r9d
xorl %eax, %eax
callq 0x17a50
callq 0x17390
nop