// File: 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:
subq $0x248, %rsp            # imm = 0x248
movq %rdi, 0x98(%rsp)
movq %rdi, %rax
movq %rax, 0xa0(%rsp)
movq %rdi, 0x240(%rsp)
movq %rsi, 0x238(%rsp)
movb $0x0, 0x237(%rsp)
callq 0x11560
movq 0x238(%rsp), %rdi
callq 0x11320
movq %rax, 0xa8(%rsp)
jmp 0x564e
leaq 0x1f7(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x4630
movq 0x90(%rsp), %rdx
leaq 0x30de7(%rip), %rsi     # 0x36459
leaq 0x1f8(%rsp), %rdi
callq 0x44f0
jmp 0x5681
movq 0xa8(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x113b0
movq %rax, 0x88(%rsp)
jmp 0x56a0
movq 0x88(%rsp), %rdi
callq 0x115d0
movq %rax, 0x80(%rsp)
jmp 0x56b7
leaq 0x1f8(%rsp), %rdi
callq 0x4700
leaq 0x1f7(%rsp), %rdi
callq 0x4430
movq 0x80(%rsp), %rax
movq %rax, 0x228(%rsp)
movq 0x228(%rsp), %rdi
callq 0x11660
movq %rax, 0x1e8(%rsp)
movq 0x228(%rsp), %rdi
callq 0x11690
movq %rax, 0x1e0(%rsp)
leaq 0x1e8(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x116c0
testb $0x1, %al
jne 0x5729
jmp 0x57f9
leaq 0x1e8(%rsp), %rdi
callq 0x11700
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0x1d8(%rsp)
movq %rax, 0x70(%rsp)
movq 0x1d8(%rsp), %rdi
callq 0x5400
movq %rax, 0x78(%rsp)
jmp 0x5762
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rax
movq %rax, 0x1d0(%rsp)
leaq 0x1d0(%rsp), %rsi
callq 0x11710
jmp 0x5783
jmp 0x5785
leaq 0x1e8(%rsp), %rdi
callq 0x11740
jmp 0x570b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
jmp 0x5caf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
jmp 0x57e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
leaq 0x1f8(%rsp), %rdi
callq 0x4700
leaq 0x1f7(%rsp), %rdi
callq 0x4430
jmp 0x5caf
movq 0x238(%rsp), %rdi
callq 0x11320
movq %rax, 0x68(%rsp)
jmp 0x580d
leaq 0x1a7(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x4630
movq 0x60(%rsp), %rdx
leaq 0x30c36(%rip), %rsi     # 0x36461
leaq 0x1a8(%rsp), %rdi
callq 0x44f0
jmp 0x583a
movq 0x68(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x113b0
movq %rax, 0x58(%rsp)
jmp 0x5853
movq 0x58(%rsp), %rdi
callq 0x5400
movq %rax, 0x50(%rsp)
jmp 0x5864
movq 0x98(%rsp), %rax
movq 0x50(%rsp), %rcx
movq %rcx, 0x1c8(%rsp)
movq 0x1c8(%rsp), %rcx
movq %rcx, 0x18(%rax)
leaq 0x1a8(%rsp), %rdi
callq 0x4700
leaq 0x1a7(%rsp), %rdi
callq 0x4430
leaq 0x170(%rsp), %rdi
callq 0x11760
movq 0x98(%rsp), %rax
movl $0x1, 0x20(%rax)
movl $0x0, 0x16c(%rsp)
cmpl $0x6, 0x16c(%rsp)
jge 0x5b60
leaq 0x138(%rsp), %rdi
callq 0x11770
movq 0x98(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x130(%rsp), %rdi
callq 0x11780
movq %rax, 0x128(%rsp)
movq 0x130(%rsp), %rdi
callq 0x117b0
movq %rax, 0x120(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x117e0
testb $0x1, %al
jne 0x5939
jmp 0x5aa0
leaq 0x128(%rsp), %rdi
callq 0x11820
movq 0x98(%rsp), %rsi
movq %rax, 0x118(%rsp)
movq 0x118(%rsp), %rdi
addq $0x18, %rsi
movl 0x16c(%rsp), %edx
callq 0x11830
movq %rax, 0x48(%rsp)
jmp 0x5975
movq 0x48(%rsp), %rax
movq %rax, 0x110(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x11920
movl %eax, 0x44(%rsp)
jmp 0x5995
movl 0x44(%rsp), %eax
movl %eax, 0x104(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x11930
movl %eax, 0x40(%rsp)
jmp 0x59b3
movl 0x40(%rsp), %eax
movl %eax, 0x100(%rsp)
leaq 0x104(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x118f0
movq %rax, 0x38(%rsp)
jmp 0x59da
movq 0x38(%rsp), %rax
movq %rax, 0x108(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x11890
movb %dl, 0x2f(%rsp)
movq %rax, 0x30(%rsp)
jmp 0x5a07
movb 0x2f(%rsp), %al
movq 0x30(%rsp), %rcx
movq %rcx, 0xf0(%rsp)
movb %al, 0xf8(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x11940
jmp 0x591b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
jmp 0x5a68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x4700
leaq 0x1a7(%rsp), %rdi
callq 0x4430
jmp 0x5caf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x11a20
jmp 0x5c83
leaq 0x170(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x11960
movq %rax, 0x20(%rsp)
jmp 0x5abc
movq 0x20(%rsp), %rax
cmpq $0x0, %rax
je 0x5ad4
movl $0x4, 0xec(%rsp)
jmp 0x5b2c
leaq 0x170(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x119c0
movb %dl, 0x17(%rsp)
movq %rax, 0x18(%rsp)
jmp 0x5af4
movq 0x98(%rsp), %rax
movb 0x17(%rsp), %cl
movq 0x18(%rsp), %rdx
movq %rdx, 0xd8(%rsp)
movb %cl, 0xe0(%rsp)
movl 0x16c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
movl $0x0, 0xec(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x11a20
movl 0xec(%rsp), %eax
testl %eax, %eax
je 0x5b48
jmp 0x5b46
jmp 0x5b60
jmp 0x5b4a
movl 0x16c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x16c(%rsp)
jmp 0x58c6
movq 0x98(%rsp), %rax
movl $0x7fffffff, 0x24(%rax) # imm = 0x7FFFFFFF
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x11780
movq %rax, 0xc8(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x117b0
movq %rax, 0xc0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x117e0
testb $0x1, %al
jne 0x5bbf
jmp 0x5c57
leaq 0xc8(%rsp), %rdi
callq 0x11820
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0xb8(%rsp)
addq $0x24, %rax
movq %rax, 0x8(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x11930
movl %eax, 0x10(%rsp)
jmp 0x5bfb
movq 0x8(%rsp), %rdi
movl 0x10(%rsp), %eax
movl %eax, 0xb4(%rsp)
leaq 0xb4(%rsp), %rsi
callq 0x11a30
movq %rax, (%rsp)
jmp 0x5c1e
movq 0x98(%rsp), %rax
movq (%rsp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x24(%rax)
leaq 0xc8(%rsp), %rdi
callq 0x11940
jmp 0x5ba1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
jmp 0x5c83
movb $0x1, 0x237(%rsp)
movl $0x1, 0xec(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x11a70
testb $0x1, 0x237(%rsp)
jne 0x5c9f
jmp 0x5c92
leaq 0x170(%rsp), %rdi
callq 0x11a70
jmp 0x5caf
movq 0x98(%rsp), %rdi
callq 0x11a80
movq 0xa0(%rsp), %rax
addq $0x248, %rsp            # imm = 0x248
retq
movq 0x98(%rsp), %rdi
callq 0x11a80
movq 0x220(%rsp), %rdi
callq 0x4620
nopl (%rax)