// File: /workspace/github_cpp_makefile_star2_O2/tanakh[P]icfpc2015/main.cpp
// Function: put_unit(std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::complex<int> const&, unit const&, int, int)
pair<int,int> put_unit(vector<vector<int>> &bd, const pt &pos, const unit &u, int rot, int ls_old)
{
  for (auto &c: u.members) {
    pt p = pos + rot_pivot(c, u.pivot, rot);
    assert(p.imag()>=0&&p.imag()<bd.size()&&p.real()>=0&&p.real()<bd[0].size());
    bd[p.imag()][p.real()] = 1;
  }

  int w = bd[0].size()/2, h = bd.size();
  int cy = h - 1;
  int lines = 0;

  for (int y = h - 1; y >= 0; y--) {
    bool all = true;
    for (int x = 0; x < w; x++) {
      if (bd[y][x*2+y%2] == 0) {
        all = false;
        break;
      }
    }

    if (all) {
      lines++;
    }
    else {
      if (cy != y) {
        for (int x = 0; x < w; x++)
          bd[cy][x*2+cy%2] = bd[y][x*2+y%2];
      }
      cy--;
    }
  }

  while (cy >= 0) {
    for (int x = 0; x < w; x++)
      bd[cy][x*2+cy%2] = 0;
    cy--;
  }

  int points = u.members.size() + 100 * (1 + lines) * lines / 2;
  int bonus = ls_old > 1 ? points * (ls_old - 1) / 10 : 0;

  return make_pair(points + bonus, lines);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, 0xc(%rsp)
movl %ecx, %ebp
movq %rsi, %r12
movq %rdi, %r15
movq (%rdx), %r13
movq 0x8(%rdx), %r14
movq %rdx, 0x10(%rsp)
leaq 0x18(%rdx), %rbx
cmpq %r14, %r13
je 0x492a
movq %r13, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x9666
movq %rax, %rdx
shrq $0x20, %rdx
movq (%r12), %rcx
movq %rcx, %rdi
shrq $0x20, %rdi
addl %edx, %edi
js 0x4a4d
addq %rax, %rcx
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
cqto
pushq $0x18
popq %r8
idivq %r8
testl %ecx, %ecx
js 0x4a4d
movl %edi, %edx
cmpq %rdx, %rax
jbe 0x4a4d
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x8(%rsi), %rax
subq (%rsi), %rax
sarq $0x2, %rax
cmpq %rcx, %rax
jbe 0x4a4d
imulq $0x18, %rdx, %rax
movq (%rsi,%rax), %rax
movl $0x1, (%rax,%rcx,4)
addq $0x8, %r13
jmp 0x489f
movq (%r15), %r8
movq 0x8(%r15), %rax
movq 0x8(%r8), %r9
subq (%r8), %r9
shrq $0x3, %r9
subq %r8, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %rsi
decl %esi
xorl %edi, %edi
testl %r9d, %r9d
cmovlel %edi, %r9d
pushq $0x2
popq %r10
movl %esi, %ecx
movl 0xc(%rsp), %ebp
testl %esi, %esi
js 0x4a00
movl %esi, %r11d
andl $0x1, %r11d
shll $0x2, %r11d
movl %esi, %eax
imulq $0x18, %rax, %rax
addq %r8, %rax
movq %r11, %rdx
movq %r9, %r14
subq $0x1, %r14
jb 0x499c
movq (%rax), %rbx
cmpl $0x0, (%rbx,%rdx)
leaq 0x8(%rdx), %rdx
jne 0x4981
cmpl %esi, %ecx
jne 0x49a2
decl %ecx
jmp 0x499e
incl %edi
decl %esi
jmp 0x495f
movslq %ecx, %rax
imulq $0x18, %rax, %r14
addq %r8, %r14
movl %ecx, %eax
cltd
idivl %r10d
movslq %edx, %rax
shlq $0x2, %rax
addq %r11, %rbx
xorl %edx, %edx
cmpq %rdx, %r9
je 0x4998
movl (%rbx,%rdx,8), %r11d
movq (%r14), %r15
addq %rax, %r15
movl %r11d, (%r15,%rdx,8)
incq %rdx
jmp 0x49be
movl %ecx, %eax
andl $0x1, %eax
shll $0x2, %eax
movl %ecx, %edx
imulq $0x18, %rdx, %rdx
addq %r8, %rdx
movq %r9, %rsi
subq $0x1, %rsi
jb 0x49fe
movq (%rdx), %r10
andl $0x0, (%r10,%rax)
addq $0x8, %rax
jmp 0x49ea
decl %ecx
testl %ecx, %ecx
jns 0x49d6
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0x64, %edi, %eax
addl $0x64, %eax
imull %edi, %eax
sarl %eax
addl %eax, %ecx
xorl %eax, %eax
cmpl $0x2, %ebp
jl 0x4a35
decl %ebp
imull %ecx, %ebp
pushq $0xa
popq %rsi
movl %ebp, %eax
cltd
idivl %esi
addl %ecx, %eax
shlq $0x20, %rdi
orq %rdi, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd98b(%rip), %rdi      # 0x123df
leaq 0xd9c8(%rip), %rsi      # 0x12423
leaq 0xd9ca(%rip), %rcx      # 0x1242c
movl $0x18e, %edx            # imm = 0x18E
callq 0x31c0