// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/editscript.c
// Function: editscript_space_add_length
static inline void editscript_space_add_length(GtEditscript *es,
                                               GtEditscriptPos *fillpos,
                                               GtBitsequence value)
{
  /* scheme: [1111][x][x][x][x] first store consecutive ones for each element
     needed, (like elias gamma) then store the value split up to chunks of
     element size */
  /* Idea: this could be made faster with lookup-tables for the filling of most
     significant bits. */
  uint32_t num_elems = 0,
           shift;
  GtBitsequence tmp = value;

  /* needs just one element not starting with 1, store it */
  if (tmp < GT_EDITSCRIPT_FIRSTMASK(es)) {
    editscript_space_add_next(es, fillpos, tmp);
  }
  else {
    /* count the number elements needed */
    while (tmp != 0) {
      num_elems++;
      tmp >>= es->entry_size;
    }

    /* write number of entries in unary */
    tmp = num_elems;
    /* write full 1-entries */
    while (tmp >= es->entry_size) {
      editscript_space_add_next(es, fillpos, GT_EDITSCRIPT_FULLMASK(es));
      tmp -= es->entry_size;
    }
    if (tmp != 0) {
      /* write tmp 1 bits at most siginficant positions, e.g. entry_size=4,
         tmp=3: [1110]
         left shift by number of zeros, mask with entry_size 1bits.
      */
      tmp = (GT_EDITSCRIPT_FULLMASK(es) << (es->entry_size - tmp)) &
        GT_EDITSCRIPT_FULLMASK(es);
    }
    /* tmp contains either the remaining bits or one zero element to seperated
     */
    editscript_space_add_next(es, fillpos, tmp);

    /* store actual value */
    shift = (num_elems * es->entry_size);
    while (num_elems != 0) {
      num_elems--;
      shift -= es->entry_size;
      editscript_space_add_next(es, fillpos, (value >> (GtBitsequence) shift) &
                                GT_EDITSCRIPT_FULLMASK(es));
    }
  }
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movq 0x20(%rsp), %rcx
movzbl 0x15(%rcx), %ecx
subq $0x1, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
cmpq %rcx, %rax
jae 0x15e81d
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq (%rsp), %rdx
callq 0x15ca60
jmp 0x15e97d
jmp 0x15e81f
cmpq $0x0, (%rsp)
je 0x15e849
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
movq 0x20(%rsp), %rax
movzbl 0x15(%rax), %ecx
movq (%rsp), %rax
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, (%rsp)
jmp 0x15e81f
movl 0xc(%rsp), %eax
movq %rax, (%rsp)
movq (%rsp), %rax
movq 0x20(%rsp), %rcx
movzbl 0x15(%rcx), %ecx
cmpq %rcx, %rax
jb 0x15e8a3
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rax
movzbl 0x15(%rax), %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %edx
shlq %cl, %rdx
subq $0x1, %rdx
callq 0x15ca60
movq 0x20(%rsp), %rax
movzbl 0x15(%rax), %eax
movl %eax, %ecx
movq (%rsp), %rax
subq %rcx, %rax
movq %rax, (%rsp)
jmp 0x15e851
cmpq $0x0, (%rsp)
je 0x15e8f4
movq 0x20(%rsp), %rax
movzbl 0x15(%rax), %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
movq 0x20(%rsp), %rcx
movzbl 0x15(%rcx), %ecx
subq (%rsp), %rcx
shlq %cl, %rax
movq 0x20(%rsp), %rcx
movzbl 0x15(%rcx), %ecx
movl %ecx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
subq $0x1, %rcx
andq %rcx, %rax
movq %rax, (%rsp)
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq (%rsp), %rdx
callq 0x15ca60
movl 0xc(%rsp), %eax
movq 0x20(%rsp), %rcx
movzbl 0x15(%rcx), %ecx
imull %ecx, %eax
movl %eax, 0x8(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0x15e97b
movl 0xc(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xc(%rsp)
movq 0x20(%rsp), %rax
movzbl 0x15(%rax), %ecx
movl 0x8(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x8(%rsp)
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
movl 0x8(%rsp), %eax
movl %eax, %ecx
shrq %cl, %rdx
movq 0x20(%rsp), %rax
movzbl 0x15(%rax), %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
andq %rax, %rdx
callq 0x15ca60
jmp 0x15e91b
jmp 0x15e97d
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)