// File: /workspace/github_cpp_makefile_star2_O3/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)
movq %rdx, %r14
movq %rdi, %r15
movq (%rdx), %rbx
movq 0x8(%rdx), %r13
cmpq %r13, %rbx
je 0x5217
movl %ecx, %ebp
movq %rsi, %r12
movq (%rbx), %rax
movq %rax, %rcx
shrq $0x20, %rcx
movl 0x18(%r14), %edx
subl 0x1c(%r14), %ecx
subl %edx, %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0xc93e
movq %rax, %rdx
shrq $0x20, %rdx
addl 0x1c(%r14), %edx
movq (%r12), %rsi
movq %rsi, %rcx
shrq $0x20, %rcx
addl %edx, %ecx
js 0x548d
movl %ecx, %edi
movq (%r15), %rcx
movq 0x8(%r15), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r8, %rdx
cmpq %rdi, %rdx
jbe 0x548d
addl 0x18(%r14), %eax
addl %eax, %esi
js 0x548d
movq 0x8(%rcx), %rax
subq (%rcx), %rax
movl %esi, %esi
movq %rax, %r8
sarq $0x2, %r8
cmpq %rsi, %r8
jbe 0x548d
leaq (%rdi,%rdi,2), %rdi
movq (%rcx,%rdi,8), %rdi
movl $0x1, (%rdi,%rsi,4)
addq $0x8, %rbx
cmpq %r13, %rbx
jne 0x5163
jmp 0x523a
movq (%r15), %rcx
movq 0x8(%r15), %rsi
movq 0x8(%rcx), %rax
subq (%rcx), %rax
subq %rcx, %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdx
shrq $0x3, %rax
leal -0x1(%rdx), %esi
testl %edx, %edx
jle 0x52d4
movl %esi, %edi
movl %eax, %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
xorl %edx, %edx
testl %eax, %eax
jle 0x5280
movl %edi, %r9d
andl $0x1, %r9d
shll $0x2, %r9d
leaq (%rdi,%rdi,2), %r10
addq (%rcx,%r10,8), %r9
xorl %r10d, %r10d
cmpl $0x0, (%r9,%r10,8)
je 0x5284
incq %r10
cmpq %r10, %r8
jne 0x5271
incl %edx
jmp 0x52c6
movl %esi, %r10d
cmpq %r10, %rdi
je 0x52c4
movslq %esi, %r10
leaq (%r10,%r10,2), %r11
movl %esi, %r10d
shrl $0x1f, %r10d
addl %esi, %r10d
andl $-0x2, %r10d
movl %esi, %ebx
subl %r10d, %ebx
movslq %ebx, %r10
shlq $0x2, %r10
addq (%rcx,%r11,8), %r10
xorl %r11d, %r11d
movl (%r9,%r11,8), %ebx
movl %ebx, (%r10,%r11,8)
incq %r11
cmpq %r11, %r8
jne 0x52b4
decl %esi
leaq -0x1(%rdi), %r9
testq %rdi, %rdi
movq %r9, %rdi
jg 0x5257
jmp 0x52d6
xorl %edx, %edx
testl %esi, %esi
js 0x5436
movl %esi, %esi
movl %eax, %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl %eax, %edi
addl $0x3, %edi
andl $-0x4, %edi
decq %r8
movq %r8, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0xfd29(%rip), %xmm1     # 0x15030
movdqa 0xfd31(%rip), %xmm2     # 0x15040
movdqa 0xfd39(%rip), %xmm3     # 0x15050
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0xfd39(%rip), %xmm5     # 0x15060
testl %eax, %eax
jle 0x5426
movl %esi, %r8d
andl $0x1, %r8d
shll $0x2, %r8d
leaq (%rsi,%rsi,2), %r9
movq (%rcx,%r9,8), %r9
addq %r9, %r8
addq $0x18, %r8
xorl %r9d, %r9d
movdqa %xmm2, %xmm6
movdqa %xmm1, %xmm7
movdqa %xmm6, %xmm8
pxor %xmm3, %xmm8
movdqa %xmm8, %xmm9
pcmpgtd %xmm0, %xmm9
pcmpeqd %xmm0, %xmm8
pshufd $0xf5, %xmm8, %xmm10    # xmm10 = xmm8[1,1,3,3]
pand %xmm9, %xmm10
pshufd $0xf5, %xmm9, %xmm8     # xmm8 = xmm9[1,1,3,3]
por %xmm10, %xmm8
movd %xmm8, %r10d
notl %r10d
testb $0x1, %r10b
je 0x539a
movl $0x0, -0x18(%r8,%r9,8)
pxor %xmm4, %xmm8
pextrw $0x4, %xmm8, %r10d
testb $0x1, %r10b
je 0x53b4
movl $0x0, -0x10(%r8,%r9,8)
movdqa %xmm7, %xmm8
pxor %xmm3, %xmm8
movdqa %xmm8, %xmm9
pcmpgtd %xmm0, %xmm9
pcmpeqd %xmm0, %xmm8
pshufd $0xf5, %xmm8, %xmm10    # xmm10 = xmm8[1,1,3,3]
pand %xmm9, %xmm10
pshufd $0xf5, %xmm9, %xmm8     # xmm8 = xmm9[1,1,3,3]
por %xmm10, %xmm8
pxor %xmm4, %xmm8
pextrw $0x0, %xmm8, %r10d
testb $0x1, %r10b
je 0x53fd
movl $0x0, -0x8(%r8,%r9,8)
pextrw $0x4, %xmm8, %r10d
testb $0x1, %r10b
je 0x5411
movl $0x0, (%r8,%r9,8)
addq $0x4, %r9
paddq %xmm5, %xmm6
paddq %xmm5, %xmm7
cmpq %r9, %rdi
jne 0x5354
leaq -0x1(%rsi), %r8
testq %rsi, %rsi
movq %r8, %rsi
jg 0x5327
movq 0x8(%r14), %rcx
subq (%r14), %rcx
shrq $0x3, %rcx
imull $0x64, %edx, %eax
addl $0x64, %eax
imull %edx, %eax
sarl %eax
addl %eax, %ecx
xorl %eax, %eax
movl 0xc(%rsp), %esi
cmpl $0x2, %esi
jl 0x5475
decl %esi
imull %ecx, %esi
movslq %esi, %rax
imulq $0x66666667, %rax, %rax # imm = 0x66666667
movq %rax, %rsi
shrq $0x3f, %rsi
sarq $0x22, %rax
addl %esi, %eax
addl %ecx, %eax
shlq $0x20, %rdx
orq %rdx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xff53(%rip), %rdi      # 0x153e7
leaq 0xff90(%rip), %rsi      # 0x1542b
leaq 0xff92(%rip), %rcx      # 0x15434
movl $0x18e, %edx            # imm = 0x18E
callq 0x31d0