// File: /workspace/github_cpp_makefile_star2_O3/twekkel[P]mzpq/libzpaq.cpp
// Function: libzpaq::ZPAQL::read(libzpaq::Reader*)
int ZPAQL::read(Reader* in2) {

  // Get header size and allocate
  int hsize=in2->get();
  hsize+=in2->get()*256;
  header.resize(hsize+300);
  cend=hbegin=hend=0;
  header[cend++]=hsize&255;
  header[cend++]=hsize>>8;
  while (cend<7) header[cend++]=in2->get(); // hh hm ph pm n

  // Read COMP
  int n=header[cend-1];
  for (int i=0; i<n; ++i) {
    int type=in2->get();  // component type
    if (type<0 || type>255) error("unexpected end of file");
    header[cend++]=type;  // component type
    int size=compsize[type];
    if (size<1) error("Invalid component type");
    if (cend+size>hsize) error("COMP overflows header");
    for (int j=1; j<size; ++j)
      header[cend++]=in2->get();
  }
  if ((header[cend++]=in2->get())!=0) error("missing COMP END");

  // Insert a guard gap and read HCOMP
  hbegin=hend=cend+128;
  if (hend>hsize+129) error("missing HCOMP");
  while (hend<hsize+129) {
    assert(hend<header.isize()-8);
    int op=in2->get();
    if (op==-1) error("unexpected end of file");
    header[hend++]=op;
  }
  if ((header[hend++]=in2->get())!=0) error("missing HCOMP END");
  assert(cend>=7 && cend<header.isize());
  assert(hbegin==cend+128 && hbegin<header.isize());
  assert(hend>hbegin && hend<header.isize());
  assert(hsize==header[0]+256*header[1]);
  assert(hsize==cend-2+hend-hbegin);
  allocx(rcode, rcode_size, 0);  // clear JIT code
  return cend+hend-hbegin;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %rdi
callq *(%rax)
movl %eax, %r12d
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
shll $0x8, %eax
leaq 0x10(%rbx), %r15
leal (%rax,%r12), %ecx
addl $0x12c, %ecx            # imm = 0x12C
movl %eax, %ebp
addl %r12d, %ebp
movslq %ecx, %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x3386a
movl $0x0, 0x30(%rbx)
movq $0x1, 0x28(%rbx)
movq 0x10(%rbx), %rax
movb %r12b, (%rax)
movslq 0x28(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x28(%rbx)
movq 0x10(%rbx), %rcx
movl %ebp, %edx
movl %ebp, %r13d
movb %dh, (%rcx,%rax)
movl 0x28(%rbx), %eax
cmpl $0x6, %eax
jg 0x99b6
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movslq 0x28(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x28(%rbx)
movq 0x10(%rbx), %rdx
movb %al, (%rdx,%rcx)
movl 0x28(%rbx), %eax
cmpl $0x7, %eax
jl 0x9995
movq (%r15), %rcx
movl %eax, %eax
movzbl -0x1(%rcx,%rax), %r12d
testl %r12d, %r12d
je 0x9a5f
xorl %r15d, %r15d
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movl %eax, %ebp
cmpl $0x100, %eax            # imm = 0x100
jb 0x99ea
leaq 0x2fbaf(%rip), %rdi     # 0x39594
callq 0x455c
movslq 0x28(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x28(%rbx)
movq 0x10(%rbx), %rcx
movb %bpl, (%rcx,%rax)
movslq %ebp, %rax
leaq 0x2c88a(%rip), %rcx     # 0x36290
movl (%rcx,%rax,4), %ebp
testl %ebp, %ebp
jg 0x9a19
leaq 0x2fb97(%rip), %rdi     # 0x395ab
callq 0x455c
movl 0x28(%rbx), %eax
addl %ebp, %eax
cmpl %r13d, %eax
jle 0x9a2f
leaq 0x2fb98(%rip), %rdi     # 0x395c2
callq 0x455c
cmpl $0x2, %ebp
jl 0x9a53
decl %ebp
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movslq 0x28(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x28(%rbx)
movq 0x10(%rbx), %rdx
movb %al, (%rdx,%rcx)
decl %ebp
jne 0x9a36
incl %r15d
cmpl %r12d, %r15d
jne 0x99cd
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movslq 0x28(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x28(%rbx)
movq 0x10(%rbx), %rdx
movb %al, (%rdx,%rcx)
testb %al, %al
je 0x9a88
leaq 0x2fb55(%rip), %rdi     # 0x395d8
callq 0x455c
movl 0x28(%rbx), %eax
subl $-0x80, %eax
movl %eax, 0x30(%rbx)
movl %eax, 0x2c(%rbx)
addl $0x81, %r13d
movl %r13d, %r12d
cmpl %r13d, %eax
jle 0x9ab2
leaq 0x2fb3f(%rip), %rdi     # 0x395e9
callq 0x455c
movl 0x30(%rbx), %eax
cmpl %r12d, %eax
jge 0x9aed
leaq 0x2fad6(%rip), %r15     # 0x39594
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x9ad5
movq %r15, %rdi
callq 0x455c
movslq 0x30(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x30(%rbx)
movq 0x10(%rbx), %rcx
movb %bpl, (%rcx,%rax)
cmpl %r12d, 0x30(%rbx)
jl 0x9abe
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movslq 0x30(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x30(%rbx)
movq 0x10(%rbx), %rdx
movb %al, (%rdx,%rcx)
testb %al, %al
je 0x9b16
leaq 0x2fae6(%rip), %rdi     # 0x395f7
callq 0x455c
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
sete %cl
movl 0xb4(%rbx), %eax
testl %eax, %eax
sete %dl
testb %dl, %cl
jne 0x9b54
testq %rdi, %rdi
je 0x9b3f
movslq %eax, %rsi
callq 0x40f0
movq $0x0, 0xb8(%rbx)
movl $0x0, 0xb4(%rbx)
movl 0x30(%rbx), %eax
addl 0x28(%rbx), %eax
subl 0x2c(%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq