// File: /workspace/github_cpp_makefile_star2_O1/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 0x522c
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 0xc88c
movq %rax, %rdx
shrq $0x20, %rdx
addl 0x1c(%r14), %edx
movq (%r12), %rsi
movq %rsi, %rcx
shrq $0x20, %rcx
addl %edx, %ecx
js 0x549e
movl %ecx, %ecx
movq (%r15), %rdx
movq 0x8(%r15), %rdi
subq %rdx, %rdi
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r8, %rdi
cmpq %rcx, %rdi
jbe 0x549e
addl 0x18(%r14), %eax
addl %eax, %esi
js 0x549e
movl %esi, %eax
movq 0x8(%rdx), %rsi
subq (%rdx), %rsi
sarq $0x2, %rsi
cmpq %rax, %rsi
jbe 0x549e
leaq (%rcx,%rcx,2), %rcx
movq (%rdx,%rcx,8), %rcx
movl $0x1, (%rcx,%rax,4)
addq $0x8, %rbx
cmpq %r13, %rbx
jne 0x517d
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq 0x8(%rax), %rdx
subq (%rax), %rdx
shrq $0x3, %rdx
subq %rax, %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %ecx # imm = 0xAAAAAAAB
leal -0x1(%rcx), %esi
testl %ecx, %ecx
jle 0x52e5
movl %esi, %edi
movl %edx, %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
testl %edx, %edx
jle 0x528d
movl %edi, %r9d
andl $0x1, %r9d
shll $0x2, %r9d
leaq (%rdi,%rdi,2), %r10
addq (%rax,%r10,8), %r9
xorl %r10d, %r10d
cmpl $0x0, (%r9,%r10,8)
je 0x5291
incq %r10
cmpq %r10, %r8
jne 0x527e
incl %ecx
jmp 0x52d7
movl %esi, %r10d
cmpq %r10, %rdi
je 0x52d5
testl %edx, %edx
jle 0x52d5
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 (%rax,%r11,8), %r10
xorl %r11d, %r11d
movl (%r9,%r11,8), %ebx
movl %ebx, (%r10,%r11,8)
incq %r11
cmpq %r11, %r8
jne 0x52c5
decl %esi
leaq -0x1(%rdi), %r9
testq %rdi, %rdi
movq %r9, %rdi
jg 0x5264
jmp 0x52e7
xorl %ecx, %ecx
testl %esi, %esi
js 0x5447
movl %esi, %esi
movl %edx, %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl %edx, %edi
addl $0x3, %edi
andl $-0x4, %edi
decq %r8
movq %r8, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0xfd18(%rip), %xmm1     # 0x15030
movdqa 0xfd20(%rip), %xmm2     # 0x15040
movdqa 0xfd28(%rip), %xmm3     # 0x15050
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0xfd28(%rip), %xmm5     # 0x15060
testl %edx, %edx
jle 0x5437
movl %esi, %r8d
andl $0x1, %r8d
shll $0x2, %r8d
leaq (%rsi,%rsi,2), %r9
movq (%rax,%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 0x53ab
movl $0x0, -0x18(%r8,%r9,8)
pxor %xmm4, %xmm8
pextrw $0x4, %xmm8, %r10d
testb $0x1, %r10b
je 0x53c5
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 0x540e
movl $0x0, -0x8(%r8,%r9,8)
pextrw $0x4, %xmm8, %r10d
testb $0x1, %r10b
je 0x5422
movl $0x0, (%r8,%r9,8)
addq $0x4, %r9
paddq %xmm5, %xmm6
paddq %xmm5, %xmm7
cmpq %r9, %rdi
jne 0x5365
leaq -0x1(%rsi), %r8
testq %rsi, %rsi
movq %r8, %rsi
jg 0x5338
movq 0x8(%r14), %rdx
subq (%r14), %rdx
shrq $0x3, %rdx
imull $0x64, %ecx, %eax
addl $0x64, %eax
imull %ecx, %eax
sarl %eax
addl %eax, %edx
xorl %eax, %eax
movl 0xc(%rsp), %esi
cmpl $0x2, %esi
jl 0x5486
decl %esi
imull %edx, %esi
movslq %esi, %rax
imulq $0x66666667, %rax, %rax # imm = 0x66666667
movq %rax, %rsi
shrq $0x3f, %rsi
sarq $0x22, %rax
addl %esi, %eax
addl %edx, %eax
shlq $0x20, %rcx
orq %rcx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xff62(%rip), %rdi      # 0x15407
leaq 0xff9f(%rip), %rsi      # 0x1544b
leaq 0xffa1(%rip), %rcx      # 0x15454
movl $0x18e, %edx            # imm = 0x18E
callq 0x31d0