// File: /workspace/github_cpp_makefile_star2_O3/twekkel[P]mzpq/libzpaq.cpp
// Function: libzpaq::Compiler::Compiler(char const*, int*, libzpaq::ZPAQL&, libzpaq::ZPAQL&, libzpaq::Writer*)
Compiler::Compiler(const char* in_, int* args_, ZPAQL& hz_, ZPAQL& pz_,
                   Writer* out2_): in(in_), args(args_), hz(hz_), pz(pz_),
                   out2(out2_), if_stack(1000), do_stack(1000) {
  line=1;
  state=0;
  hz.clear();
  pz.clear();
  hz.header.resize(68000); 

  // Compile the COMP section of header
  rtoken("comp");
  hz.header[2]=rtoken(0, 255);  // hh
  hz.header[3]=rtoken(0, 255);  // hm
  hz.header[4]=rtoken(0, 255);  // ph
  hz.header[5]=rtoken(0, 255);  // pm
  const int n=hz.header[6]=rtoken(0, 255);  // n
  hz.cend=7;
  for (int i=0; i<n; ++i) {
    rtoken(i, i);
    CompType type=CompType(rtoken(compname));
    hz.header[hz.cend++]=type;
    int clen=libzpaq::compsize[type&255];
    if (clen<1 || clen>10) syntaxError("invalid component");
    for (int j=1; j<clen; ++j)
      hz.header[hz.cend++]=rtoken(0, 255);  // component arguments
  }
  hz.header[hz.cend++];  // end
  hz.hbegin=hz.hend=hz.cend+128;

  // Compile HCOMP
  rtoken("hcomp");
  int op=compile_comp(hz);

  // Compute header size
  int hsize=hz.cend-2+hz.hend-hz.hbegin;
  hz.header[0]=hsize&255;
  hz.header[1]=hsize>>8;

  // Compile POST 0 END
  if (op==POST) {
    rtoken(0, 0);
    rtoken("end");
  }

  // Compile PCOMP pcomp_cmd ; program... END
  else if (op==PCOMP) {
    pz.header.resize(68000);
    pz.header[4]=hz.header[4];  // ph
    pz.header[5]=hz.header[5];  // pm
    pz.cend=8;
    pz.hbegin=pz.hend=pz.cend+128;

    // get pcomp_cmd ending with ";" (case sensitive)
    next();
    while (*in && *in!=';') {
      if (out2)
        out2->put(*in);
      ++in;
    }
    if (*in) ++in;

    // Compile PCOMP
    op=compile_comp(pz);
    int len=pz.cend-2+pz.hend-pz.hbegin;  // insert header size
    assert(len>=0);
    pz.header[0]=len&255;
    pz.header[1]=len>>8;
    if (op!=END)
      syntaxError("expected END");
  }
  else if (op!=END)
    syntaxError("expected END or POST 0 END or PCOMP cmd ; ... END");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r15
movq %rsi, (%rdi)
movq %rdx, 0x8(%rdi)
movq %rcx, 0x10(%rdi)
movq %r8, 0x18(%rdi)
movq %r9, 0x20(%rdi)
addq $0x30, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movl $0x0, 0x40(%r15)
movl $0x3e8, %esi            # imm = 0x3E8
movq %rdi, 0x10(%rsp)
xorl %edx, %edx
callq 0x33938
leaq 0x50(%r15), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x54(%r15)
movups %xmm0, 0x48(%r15)
movl $0x3e8, %esi            # imm = 0x3E8
movq %rdi, 0x8(%rsp)
xorl %edx, %edx
callq 0x33938
movq $0x0, 0x68(%r15)
movq $0x1, 0x28(%r15)
movq 0x10(%r15), %rdi
callq 0x9b6c
movq 0x18(%r15), %rdi
callq 0x9b6c
movq 0x10(%r15), %rdi
addq $0x10, %rdi
movl $0x109a0, %esi          # imm = 0x109A0
xorl %edx, %edx
callq 0x3386a
leaq 0x2bec2(%rip), %rsi     # 0x39d88
movq %r15, %rdi
callq 0xd812
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd852
movq 0x10(%r15), %rcx
movq 0x10(%rcx), %rcx
movb %al, 0x2(%rcx)
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd852
movq 0x10(%r15), %rcx
movq 0x10(%rcx), %rcx
movb %al, 0x3(%rcx)
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd852
movq 0x10(%r15), %rcx
movq 0x10(%rcx), %rcx
movb %al, 0x4(%rcx)
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd852
movq 0x10(%r15), %rcx
movq 0x10(%rcx), %rcx
movb %al, 0x5(%rcx)
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd852
movl %eax, %ebp
movq 0x10(%r15), %rax
movq 0x10(%rax), %rax
movb %bpl, 0x6(%rax)
movq 0x10(%r15), %rax
movl $0x7, 0x28(%rax)
andl $0xff, %ebp
je 0xe00d
xorl %r12d, %r12d
leaq 0x3327c(%rip), %r13     # 0x411f0
leaq 0x28315(%rip), %r14     # 0x36290
movq %r15, %rdi
movl %r12d, %esi
movl %r12d, %edx
callq 0xd852
movq %r15, %rdi
movq %r13, %rsi
callq 0xd7be
movq 0x10(%r15), %rcx
movslq 0x28(%rcx), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x28(%rcx)
movq 0x10(%rcx), %rcx
movb %al, (%rcx,%rdx)
movzbl %al, %eax
movl (%r14,%rax,4), %ebx
leal -0xb(%rbx), %eax
cmpl $-0xb, %eax
ja 0xdfc9
movq %r15, %rdi
leaq 0x2bdb3(%rip), %rsi     # 0x39d75
xorl %edx, %edx
callq 0xd61e
cmpl $0x2, %ebx
jl 0xdff8
decl %ebx
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd852
movq 0x10(%r15), %rcx
movslq 0x28(%rcx), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x28(%rcx)
movq 0x10(%rcx), %rcx
movb %al, (%rcx,%rdx)
decl %ebx
jne 0xdfd0
incl %r12d
cmpl %ebp, %r12d
jne 0xdf7b
movq 0x10(%r15), %rax
movl 0x28(%rax), %ecx
jmp 0xe012
movl $0x7, %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x28(%rax)
addl $0x81, %ecx
movl %ecx, 0x30(%rax)
movl %ecx, 0x2c(%rax)
leaq 0x2bd5c(%rip), %rsi     # 0x39d87
movq %r15, %rdi
callq 0xd812
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0xd90a
movq 0x10(%r15), %rdx
movl 0x28(%rdx), %ecx
addl 0x30(%rdx), %ecx
subl 0x2c(%rdx), %ecx
addl $-0x2, %ecx
movq 0x10(%rdx), %rdx
movb %cl, (%rdx)
movq 0x10(%r15), %rdx
movq 0x10(%rdx), %rdx
movb %ch, 0x1(%rdx)
cmpl $0x102, %eax            # imm = 0x102
je 0xe18d
cmpl $0x101, %eax            # imm = 0x101
je 0xe09d
cmpl $0x100, %eax            # imm = 0x100
jne 0xe12f
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd852
leaq 0x2bbe2(%rip), %rsi     # 0x39c72
movq %r15, %rdi
callq 0xd812
jmp 0xe18d
movq 0x18(%r15), %rdi
addq $0x10, %rdi
movl $0x109a0, %esi          # imm = 0x109A0
xorl %edx, %edx
callq 0x3386a
movq 0x10(%r15), %rax
movq 0x18(%r15), %rcx
movq 0x10(%rax), %rax
movb 0x4(%rax), %al
movq 0x10(%rcx), %rcx
movb %al, 0x4(%rcx)
movq 0x10(%r15), %rax
movq 0x18(%r15), %rcx
movq 0x10(%rax), %rax
movb 0x5(%rax), %al
movq 0x10(%rcx), %rcx
movb %al, 0x5(%rcx)
movq 0x18(%r15), %rax
movabsq $0x8800000008, %rcx     # imm = 0x8800000008
movq %rcx, 0x28(%rax)
movl $0x88, 0x30(%rax)
movq %r15, %rdi
callq 0xd51e
movq (%r15), %rax
movb (%rax), %cl
testb %cl, %cl
je 0xe148
cmpb $0x3b, %cl
je 0xe142
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0xe120
movsbl %cl, %esi
movq (%rdi), %rax
callq *(%rax)
movq (%r15), %rax
leaq 0x1(%rax), %rdx
movq %rdx, (%r15)
movb 0x1(%rax), %cl
movq %rdx, %rax
jmp 0xe103
leaq 0x2bc64(%rip), %rsi     # 0x39d9a
movq %r15, %rdi
xorl %edx, %edx
callq 0xd61e
jmp 0xe18d
incq %rax
movq %rax, (%r15)
movq 0x18(%r15), %rsi
movq %r15, %rdi
callq 0xd90a
movq 0x18(%r15), %rdx
movl 0x28(%rdx), %ecx
addl 0x30(%rdx), %ecx
subl 0x2c(%rdx), %ecx
addl $-0x2, %ecx
movq 0x10(%rdx), %rdx
movb %cl, (%rdx)
movq 0x18(%r15), %rdx
movq 0x10(%rdx), %rdx
movb %ch, 0x1(%rdx)
cmpl $0x102, %eax            # imm = 0x102
je 0xe18d
leaq 0x2bc0a(%rip), %rsi     # 0x39d8d
movq %r15, %rdi
xorl %edx, %edx
callq 0xd61e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe1b3
jmp 0xe1b3
movq %rax, %rbx
jmp 0xe1c0
jmp 0xe1b3
jmp 0xe1b3
jmp 0xe1b3
jmp 0xe1b3
jmp 0xe1b3
jmp 0xe1b3
jmp 0xe1b3
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x340e8
movq 0x10(%rsp), %rdi
callq 0x340e8
movq %rbx, %rdi
callq 0x4310