// File: /workspace/github_cpp_makefile_star2_O2/tanakh[P]icfpc2015/main.cpp
// Function: to_unit(picojson::value&)
unit to_unit(value &v) {
  unit u;
  for (auto &c: v.get<object>()["members"].get<picojson::array>()) {
    u.members.push_back(to_cell(c));
  }
  u.pivot = to_cell(v.get<object>()["pivot"]);

  // calculate rotation max
  set<set<pair<int, int>>> ss;
  u.rot_max = 1;
  for (int i = 0; i < 6; i++) {
    set<pair<int, int>> s;
    for (auto &c: u.members) {
      auto p = rot_pivot(c, u.pivot, i);
      s.insert(make_pair(p.real(), p.imag()));
    }
    if (ss.count(s)) break;
    ss.insert(s);
    u.rot_max = i + 1;
  }

  u.miny = 0x7fffffff;
  for (auto &p: u.members)
    u.miny = min(u.miny, p.imag());

  return u;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movq %rdi, 0x8(%rsp)
movups %xmm0, (%rdi)
movq %rsi, %rdi
callq 0x94f4
movq %rax, %r15
leaq 0xe563(%rip), %rsi      # 0x12371
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x30e0
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x954c
movq %rax, %rdi
callq 0x960e
movq %rax, %r13
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x3550
movq (%r13), %r12
movq 0x8(%r13), %rbx
cmpq %rbx, %r12
je 0x3e6f
movq %r12, %rdi
callq 0x3d16
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0xd1e2
addq $0x10, %r12
jmp 0x3e4a
movq %r14, %rdi
callq 0x94f4
movq %rax, %r14
leaq 0xe4f8(%rip), %rsi      # 0x12379
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x30e0
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x954c
movq %rax, %rdi
callq 0x3d16
movq 0x8(%rsp), %rbx
leaq 0x18(%rbx), %r14
movq %rax, 0x18(%rbx)
leaq 0x10(%rsp), %rdi
callq 0x3550
leaq 0x18(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movl $0x1, 0x20(%rbx)
xorl %ebp, %ebp
leaq 0x48(%rsp), %r12
leaq 0x40(%rsp), %r13
cmpl $0x6, %ebp
je 0x3f86
andl $0x0, 0x50(%rsp)
andq $0x0, 0x58(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x60(%rsp)
movq %rax, 0x68(%rsp)
andq $0x0, 0x70(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %r15
movq 0x8(%rax), %rbx
cmpq %rbx, %r15
je 0x3f46
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x9666
movq %rax, 0x40(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0xd33e
addq $0x8, %r15
jmp 0x3f1e
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x96b4
testq %rax, %rax
jne 0x3f7c
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xd5bc
incl %ebp
movq 0x8(%rsp), %rax
movl %ebp, 0x20(%rax)
movq %r12, %rdi
callq 0xa452
jmp 0x3ee9
leaq 0x48(%rsp), %rdi
callq 0xa452
movq 0x8(%rsp), %rcx
movl $0x7fffffff, 0x24(%rcx) # imm = 0x7FFFFFFF
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rcx, %rax
je 0x3fb9
movl 0x4(%rax), %esi
cmpl %edx, %esi
cmovll %esi, %edx
movq 0x8(%rsp), %rsi
movl %edx, 0x24(%rsi)
addq $0x8, %rax
jmp 0x3f9e
leaq 0x10(%rsp), %rdi
callq 0xa49a
movq 0x8(%rsp), %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3ff2
jmp 0x3ff2
jmp 0x3ff2
jmp 0x3ff2
jmp 0x3fe1
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x3550
jmp 0x4010
jmp 0x3ff9
movq %rax, %r14
jmp 0x4010
jmp 0x3ff9
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0xa452
leaq 0x10(%rsp), %rdi
callq 0xa49a
movq 0x8(%rsp), %rdi
callq 0xd1d4
movq %r14, %rdi
callq 0x34a0