// File: /workspace/github_cpp_makefile_star2_O1/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 0x4a1f4
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 0x4a1f4
movq $0x0, 0x68(%r15)
movq $0x1, 0x28(%r15)
movq 0x10(%r15), %rdi
callq 0x9b54
movq 0x18(%r15), %rdi
callq 0x9b54
movq 0x10(%r15), %rdi
addq $0x10, %rdi
movl $0x109a0, %esi          # imm = 0x109A0
xorl %edx, %edx
callq 0x4a126
leaq 0x41b92(%rip), %rsi     # 0x4f5b8
movq %r15, %rdi
callq 0xd308
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd348
movq 0x10(%r15), %rcx
movq 0x10(%rcx), %rcx
movb %al, 0x2(%rcx)
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd348
movq 0x10(%r15), %rcx
movq 0x10(%rcx), %rcx
movb %al, 0x3(%rcx)
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd348
movq 0x10(%r15), %rcx
movq 0x10(%rcx), %rcx
movb %al, 0x4(%rcx)
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd348
movq 0x10(%r15), %rcx
movq 0x10(%rcx), %rcx
movb %al, 0x5(%rcx)
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd348
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 0xdb64
xorl %r12d, %r12d
leaq 0x4971c(%rip), %r13     # 0x571f0
leaq 0x3dfe5(%rip), %r14     # 0x4bac0
movq %r15, %rdi
movl %r12d, %esi
movl %r12d, %edx
callq 0xd348
movq %r15, %rdi
movq %r13, %rsi
callq 0xd290
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 0xdb29
movq %r15, %rdi
leaq 0x41a83(%rip), %rsi     # 0x4f5a5
xorl %edx, %edx
callq 0xd0f0
cmpl $0x2, %ebx
jl 0xdb58
decl %ebx
movq %r15, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0xd348
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 0xdb30
incl %r12d
cmpl %ebp, %r12d
jne 0xdadb
movq 0x10(%r15), %rax
movl 0x28(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x28(%rax)
addl $0x81, %ecx
movl %ecx, 0x30(%rax)
movl %ecx, 0x2c(%rax)
leaq 0x41a33(%rip), %rsi     # 0x4f5b7
movq %r15, %rdi
callq 0xd308
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0xd412
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 0xdce5
cmpl $0x101, %eax            # imm = 0x101
je 0xdbf6
cmpl $0x100, %eax            # imm = 0x100
jne 0xdc87
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd348
leaq 0x418b9(%rip), %rsi     # 0x4f4a2
movq %r15, %rdi
callq 0xd308
jmp 0xdce5
movq 0x18(%r15), %rdi
addq $0x10, %rdi
movl $0x109a0, %esi          # imm = 0x109A0
xorl %edx, %edx
callq 0x4a126
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 0xcfe2
movq (%r15), %rcx
movzbl (%rcx), %eax
testl %eax, %eax
je 0xdca0
cmpl $0x3b, %eax
je 0xdc9a
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0xdc77
movsbl %al, %esi
movq (%rdi), %rax
callq *(%rax)
movq (%r15), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r15)
movzbl 0x1(%rax), %eax
jmp 0xdc5d
leaq 0x4193c(%rip), %rsi     # 0x4f5ca
movq %r15, %rdi
xorl %edx, %edx
callq 0xd0f0
jmp 0xdce5
incq %rcx
movq %rcx, (%r15)
movq 0x18(%r15), %rsi
movq %r15, %rdi
callq 0xd412
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 0xdce5
leaq 0x418e2(%rip), %rsi     # 0x4f5bd
movq %r15, %rdi
xorl %edx, %edx
callq 0xd0f0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xdd0b
jmp 0xdd0b
jmp 0xdd0b
movq %rax, %rbx
jmp 0xdd18
jmp 0xdd0b
jmp 0xdd0b
jmp 0xdd0b
jmp 0xdd0b
jmp 0xdd0b
jmp 0xdd0b
movq %rax, %rbx
movq 0x8(%rsp), %rdi
callq 0x4a99c
movq 0x10(%rsp), %rdi
callq 0x4a99c
movq %rbx, %rdi
callq 0x4310