// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movzbl 0x15(%rdi), %r12d
leal -0x1(%r12), %ecx
movq %rdx, %rax
shrq %cl, %rax
testq %rax, %rax
movq %rsi, 0x20(%rsp)
movq %rdx, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
je 0x1410e3
xorl %r14d, %r14d
testq %rdx, %rdx
je 0x140f77
movq %rdx, %rax
incl %r14d
movl %r12d, %ecx
shrq %cl, %rax
testq %rax, %rax
jne 0x140f69
movl %r14d, %ebp
movb 0x15(%rdi), %al
movzbl %al, %ecx
cmpq %rcx, %rbp
jb 0x1410c0
movb $0x40, %dl
movzbl %dl, %edx
movw %dx, 0xa(%rsp)
movq $-0x1, %r12
shlq %cl, %r12
movl (%rsi), %ebx
movl 0x4(%rsi), %r15d
movzbl %al, %r13d
cmpl $0x0, 0x8(%rdi)
jne 0x140fe9
movl $0x40, %eax
xorl %edx, %edx
divl %r13d
leal 0x1(%rax), %ecx
movl %ecx, 0x8(%rdi)
leal 0x8(,%rax,8), %edi
leaq 0x2438bd(%rip), %rsi    # 0x384888
movl $0x6f, %edx
callq 0x1092b2
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %rax, (%rdi)
movq $0x0, (%rax)
incl 0xc(%rdi)
notq %r12
movl %r15d, %eax
subl %r13d, %eax
jbe 0x141008
movl %eax, %ecx
shlq %cl, %r12
movq (%rdi), %rcx
orq %r12, (%rcx,%rbx,8)
jmp 0x1410a9
movl %r15d, 0xc(%rsp)
movl %ebx, %r15d
incl %r15d
movl 0x8(%rdi), %ecx
cmpl %ecx, %r15d
jb 0x141069
movzwl 0xa(%rsp), %eax
divb 0x15(%rdi)
movzbl %al, %eax
addl %ecx, %eax
incl %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x20fcde(%rip), %xmm0   # 0x350d18
cvttsd2si %xmm0, %rax
movl %eax, 0x8(%rdi)
movq (%rdi), %rdi
movl %eax, %esi
shlq $0x3, %rsi
leaq 0x243836(%rip), %rdx    # 0x384888
movl $0x7b, %ecx
callq 0x1094e6
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %rax, (%rdi)
movl %r13d, %ecx
movl 0xc(%rsp), %r9d
subl %r9d, %ecx
movq %r12, %rax
shrq %cl, %rax
movq (%rdi), %rdx
orq %rax, (%rdx,%rbx,8)
movl %r15d, %r8d
movq $0x0, (%rdx,%r8,8)
movl $0x40, %eax
subl %r9d, %r13d
je 0x1410a6
subl %r13d, %eax
negl %r13d
movl %r13d, %ecx
shlq %cl, %r12
movq %r12, (%rdx,%r8,8)
movl %r15d, %ebx
movl %ebx, (%rsi)
movl %eax, 0x4(%rsi)
movb 0x15(%rdi), %al
movzbl %al, %ecx
subq %rcx, %rbp
cmpq %rcx, %rbp
jae 0x140f93
testq %rbp, %rbp
je 0x14114e
movq $-0x1, %rdx
shlq %cl, %rdx
notq %rdx
subl %ebp, %ecx
movq %rdx, %r12
shlq %cl, %r12
andq %rdx, %r12
jmp 0x141151
movl (%rsi), %ebx
movl 0x4(%rsi), %ebp
cmpl $0x0, 0x8(%rdi)
jne 0x14112f
movl $0x40, %eax
xorl %edx, %edx
divl %r12d
leal 0x1(%rax), %ecx
movl %ecx, 0x8(%rdi)
leal 0x8(,%rax,8), %edi
leaq 0x24377c(%rip), %rsi    # 0x384888
movl $0x6f, %edx
callq 0x1092b2
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rsi
movq %rax, (%rdi)
movq $0x0, (%rax)
incl 0xc(%rdi)
movl %ebp, %eax
subl %r12d, %eax
jbe 0x1413d2
movl %eax, %ecx
shlq %cl, %rdx
movq (%rdi), %rcx
orq %rdx, (%rcx,%rbx,8)
jmp 0x14146d
xorl %r12d, %r12d
movq 0x10(%rsp), %rdx
movl (%rsi), %ebx
movl 0x4(%rsi), %r13d
movzbl %al, %ebp
cmpl $0x0, 0x8(%rdi)
jne 0x1411a5
movl $0x40, %eax
xorl %edx, %edx
divl %ebp
leal 0x1(%rax), %ecx
movl %ecx, 0x8(%rdi)
leal 0x8(,%rax,8), %edi
leaq 0x243706(%rip), %rsi    # 0x384888
movl $0x6f, %edx
callq 0x1092b2
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rsi
movq %rax, (%rdi)
movq $0x0, (%rax)
incl 0xc(%rdi)
movl %r13d, %eax
subl %ebp, %eax
jbe 0x1411c0
movl %eax, %ecx
shlq %cl, %r12
movq (%rdi), %rcx
orq %r12, (%rcx,%rbx,8)
jmp 0x141258
movl %ebx, %r15d
incl %r15d
movl 0x8(%rdi), %ecx
cmpl %ecx, %r15d
jb 0x14121c
movb $0x40, %al
movzbl %al, %eax
divb 0x15(%rdi)
movzbl %al, %eax
addl %ecx, %eax
incl %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x20fb2b(%rip), %xmm0   # 0x350d18
cvttsd2si %xmm0, %rax
movl %eax, 0x8(%rdi)
movq (%rdi), %rdi
movl %eax, %esi
shlq $0x3, %rsi
leaq 0x243683(%rip), %rdx    # 0x384888
movl $0x7b, %ecx
callq 0x1094e6
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %rax, (%rdi)
movl %ebp, %ecx
subl %r13d, %ecx
movq %r12, %rax
shrq %cl, %rax
movq (%rdi), %rdx
orq %rax, (%rdx,%rbx,8)
movl %r15d, %r8d
movq $0x0, (%rdx,%r8,8)
movl $0x40, %eax
subl %r13d, %ebp
je 0x141250
subl %ebp, %eax
negl %ebp
movl %ebp, %ecx
shlq %cl, %r12
movq %r12, (%rdx,%r8,8)
movl %r15d, %ebx
movq 0x10(%rsp), %rdx
movl %ebx, (%rsi)
movl %eax, 0x4(%rsi)
testl %r14d, %r14d
je 0x141472
movzbl 0x15(%rdi), %r9d
imull %r14d, %r9d
movb $0x40, %al
movzbl %al, %eax
movw %ax, 0xa(%rsp)
movzbl 0x15(%rdi), %r13d
subl %r13d, %r9d
movq %rdx, %r12
movl %r9d, %ecx
shrq %cl, %r12
movq $-0x1, %r15
movl %r13d, %ecx
shlq %cl, %r15
movl (%rsi), %ebx
movl 0x4(%rsi), %ebp
cmpl $0x0, 0x8(%rdi)
jne 0x1412f3
movl $0x40, %eax
xorl %edx, %edx
divl %r13d
leal 0x1(%rax), %ecx
movl %ecx, 0x8(%rdi)
leal 0x8(,%rax,8), %edi
leaq 0x2435c8(%rip), %rsi    # 0x384888
movl $0x6f, %edx
movl %r14d, 0xc(%rsp)
movl %r9d, %r14d
callq 0x1092b2
movl %r14d, %r9d
movl 0xc(%rsp), %r14d
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rsi
movq %rax, (%rdi)
movq $0x0, (%rax)
incl 0xc(%rdi)
notq %r15
andq %r15, %r12
movl %ebp, %eax
subl %r13d, %eax
jbe 0x141314
movl %eax, %ecx
shlq %cl, %r12
movq (%rdi), %rcx
orq %r12, (%rcx,%rbx,8)
jmp 0x1413bf
movl %ebx, %r15d
incl %r15d
movl 0x8(%rdi), %ecx
cmpl %ecx, %r15d
jb 0x141380
movzwl 0xa(%rsp), %eax
divb 0x15(%rdi)
movzbl %al, %eax
addl %ecx, %eax
incl %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x20f9d7(%rip), %xmm0   # 0x350d18
cvttsd2si %xmm0, %rax
movl %eax, 0x8(%rdi)
movq (%rdi), %rdi
movl %eax, %esi
shlq $0x3, %rsi
leaq 0x24352f(%rip), %rdx    # 0x384888
movl $0x7b, %ecx
movl %r14d, 0xc(%rsp)
movl %r9d, %r14d
callq 0x1094e6
movl %r14d, %r9d
movl 0xc(%rsp), %r14d
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %rax, (%rdi)
movl %r13d, %ecx
subl %ebp, %ecx
movq %r12, %rax
shrq %cl, %rax
movq (%rdi), %rdx
orq %rax, (%rdx,%rbx,8)
movl %r15d, %r8d
movq $0x0, (%rdx,%r8,8)
movl $0x40, %eax
subl %ebp, %r13d
je 0x1413b7
subl %r13d, %eax
negl %r13d
movl %r13d, %ecx
shlq %cl, %r12
movq %r12, (%rdx,%r8,8)
movl %r15d, %ebx
movq 0x10(%rsp), %rdx
movl %ebx, (%rsi)
movl %eax, 0x4(%rsi)
decl %r14d
jne 0x141279
jmp 0x141472
movl %ebx, %r14d
incl %r14d
movl 0x8(%rdi), %ecx
cmpl %ecx, %r14d
jb 0x141430
movb $0x40, %al
movzbl %al, %eax
divb 0x15(%rdi)
movzbl %al, %eax
addl %ecx, %eax
incl %eax
cvtsi2sd %rax, %xmm0
mulsd 0x20f91c(%rip), %xmm0   # 0x350d18
cvttsd2si %xmm0, %rax
movl %eax, 0x8(%rdi)
movq (%rdi), %rdi
movl %eax, %esi
shlq $0x3, %rsi
leaq 0x243474(%rip), %rdx    # 0x384888
movl $0x7b, %ecx
callq 0x1094e6
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rsi
movq %rax, (%rdi)
movl %r12d, %ecx
subl %ebp, %ecx
movq %rdx, %rax
shrq %cl, %rax
movq %rdx, %r8
movq (%rdi), %rdx
orq %rax, (%rdx,%rbx,8)
movl %r14d, %edi
movq $0x0, (%rdx,%rdi,8)
movl $0x40, %eax
subl %ebp, %r12d
je 0x14146a
subl %r12d, %eax
negl %r12d
movl %r12d, %ecx
shlq %cl, %r8
movq %r8, (%rdx,%rdi,8)
movl %r14d, %ebx
movl %ebx, (%rsi)
movl %eax, 0x4(%rsi)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)