// File: /workspace/github_cpp_makefile_star2_O3/twekkel[P]mzpq/libzpaq.cpp
// Function: libzpaq::LZBuffer::write_literal(unsigned int, unsigned int&)
void LZBuffer::write_literal(unsigned i, unsigned& lit) {
  assert(lit>=0);
  assert(i>=0 && i<=n);
  assert(i>=lit);
  if (level==1) {
    if (lit<1) return;
    int ll=lg(lit);
    assert(ll>=1 && ll<=24);
    putb(0, 2);
    --ll;
    while (--ll>=0) {
      putb(1, 1);
      putb((lit>>ll)&1, 1);
    }
    putb(0, 1);
    while (lit) putb(in[i-lit--], 8);
  }
  else {
    assert(level==2);
    while (lit>0) {
      unsigned lit1=lit;
      if (lit1>64) lit1=64;
      put(lit1-1);
      for (unsigned j=i-lit; j<i-lit+lit1; ++j) put(in[j]);
      lit-=lit1;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
cmpl $0x1, 0x2c(%rdi)
movl (%rdx), %eax
jne 0x29ea2
testl %eax, %eax
je 0x29f1d
movl %eax, %ecx
shrl $0x10, %ecx
xorl %edx, %edx
cmpl $0x10000, %eax          # imm = 0x10000
setae %dl
cmovbl %eax, %ecx
shll $0x4, %edx
movl %ecx, %eax
shrl $0x8, %eax
cmpl $0x100, %ecx            # imm = 0x100
cmovbl %ecx, %eax
leal 0x8(%rdx), %esi
cmovbl %edx, %esi
movl %eax, %edx
shrl $0x4, %edx
cmpl $0x10, %eax
cmovbl %eax, %edx
leal 0x4(%rsi), %ecx
cmovbl %esi, %ecx
leaq 0xef75(%rip), %rax      # 0x38d0b
movsbl (%rdx,%rax), %edx
movl 0x70(%r15), %eax
addl $0x2, %eax
cmpl $0x8, %eax
jb 0x29dce
movl 0x6c(%r15), %esi
movl 0x78(%r15), %edi
movl %edi, %r8d
incl %edi
movb %sil, 0x90(%r15,%r8)
shrl $0x8, %esi
addl $-0x8, %eax
cmpl $0x7, %eax
ja 0x29dae
movl %edi, 0x78(%r15)
movl %esi, 0x6c(%r15)
movl %eax, 0x70(%r15)
leal (%rcx,%rdx), %r12d
decl %r12d
testl %r12d, %r12d
jle 0x29e45
movl 0x6c(%r15), %ecx
movl 0x70(%r15), %eax
btsl %eax, %ecx
movl %ecx, 0x6c(%r15)
incl %eax
cmpl $0x8, %eax
jb 0x29e17
movl 0x78(%r15), %edx
movl %edx, %esi
incl %edx
movb %cl, 0x90(%r15,%rsi)
shrl $0x8, %ecx
addl $-0x8, %eax
cmpl $0x7, %eax
ja 0x29df8
movl %edx, 0x78(%r15)
movl %ecx, 0x6c(%r15)
leal -0x1(%r12), %ebp
movl %eax, 0x70(%r15)
movl (%rbx), %eax
xorl %esi, %esi
btl %ebp, %eax
setb %sil
movq %r15, %rdi
movl $0x1, %edx
callq 0x33e04
cmpl $0x1, %r12d
movl %ebp, %r12d
jg 0x29dde
movl 0x70(%r15), %eax
incl %eax
cmpl $0x8, %eax
jb 0x29e73
movl 0x6c(%r15), %ecx
movl 0x78(%r15), %edx
movl %edx, %esi
incl %edx
movb %cl, 0x90(%r15,%rsi)
shrl $0x8, %ecx
addl $-0x8, %eax
cmpl $0x7, %eax
ja 0x29e54
movl %edx, 0x78(%r15)
movl %ecx, 0x6c(%r15)
movl %eax, 0x70(%r15)
movl (%rbx), %eax
testl %eax, %eax
je 0x29f1d
movq 0x20(%r15), %rcx
leal -0x1(%rax), %edx
movl %edx, (%rbx)
movl %r14d, %edx
subl %eax, %edx
movzbl (%rcx,%rdx), %esi
movq %r15, %rdi
movl $0x8, %edx
callq 0x33e04
jmp 0x29e77
testl %eax, %eax
je 0x29f1d
movq 0x20(%r15), %rcx
movl $0x40, %edx
cmpl $0x40, %eax
cmovael %edx, %eax
leal -0x1(%rax), %esi
movl 0x78(%r15), %r9d
leal 0x1(%r9), %edi
movl %edi, 0x78(%r15)
movb %sil, 0x90(%r15,%r9)
movl (%rbx), %r8d
movl %r14d, %edi
subl %r8d, %edi
leal (%rax,%r14), %esi
movl %esi, %r10d
subl %r8d, %r10d
cmpl %r10d, %edi
jae 0x29f12
movl %edi, %edi
addl $0x2, %r9d
leal -0x1(%r9), %r8d
movb (%rcx,%rdi), %r10b
movl %r9d, 0x78(%r15)
movb %r10b, 0x90(%r15,%r8)
incq %rdi
movl (%rbx), %r8d
movl %esi, %r10d
subl %r8d, %r10d
incl %r9d
cmpq %r10, %rdi
jb 0x29eea
subl %eax, %r8d
movl %r8d, (%rbx)
movl %r8d, %eax
jne 0x29eaf
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq