// File: /workspace/github_cpp_makefile_star2_O1/srajangarg[P]image-morph/src/morph.cpp
// Function: loadSegments(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<LineSegment, std::allocator<LineSegment>>&, std::vector<LineSegment, std::allocator<LineSegment>>&)
bool
loadSegments(std::string const & path, std::vector<LineSegment> & seg1, std::vector<LineSegment> & seg2)
{
  std::ifstream in(path.c_str());
  if (!in)
  {
    std::cerr << "Could not open correspondence file " << path << std::endl;
    return false;
  }

  seg1.clear();
  seg2.clear();

  double asx, asy, aex, aey, bsx, bsy, bex, bey;
  long num_segs = 0;

  std::string line;
  bool first_line = true;
  while ((first_line || (long)seg1.size() < num_segs) && std::getline(in, line))
  {
    std::istringstream line_in(line);
    if (first_line)
    {
      if (!(line_in >> num_segs))
      {
        std::cerr << "Could not read number of segments";
        return false;
      }

      first_line = false;
    }
    else
    {
      if (!(line_in >> asx >> asy >> aex >> aey >> bsx >> bsy >> bex >> bey))
      {
        std::cerr << "Could not read segment pair " << seg1.size();
        return false;
      }

      seg1.push_back(LineSegment(Vec2(asx, asy), Vec2(aex, aey)));
      seg2.push_back(LineSegment(Vec2(bsx, bsy), Vec2(bex, bey)));
    }
  }

  assert(seg1.size() == seg2.size());

  return (long)seg1.size() == num_segs;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movq (%rdi), %rsi
leaq 0x220(%rsp), %r15
movq %r15, %rdi
movl $0x8, %edx
callq 0x23d0
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x240(%rsp,%rax)
je 0x37cd
movq 0x1887a(%rip), %rdi     # 0x1bff0
leaq 0x12b26(%rip), %rsi     # 0x162a3
movl $0x23, %edx
callq 0x2240
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x18859(%rip), %rdi     # 0x1bff0
callq 0x2240
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
xorl %ebx, %ebx
jmp 0x3a8e
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x37da
movq %rax, 0x8(%r14)
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x37e7
movq %rax, 0x8(%rbx)
xorl %eax, %eax
leaq 0x8(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x48(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movb $0x1, %r13b
leaq 0xa0(%rsp), %r12
leaq 0x12ad6(%rip), %rbp     # 0x162e9
movq %rbx, 0x58(%rsp)
testb $0x1, %r13b
jne 0x3834
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x5, %rax
cmpq 0x8(%rsp), %rax
jge 0x3a53
movq 0x220(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %edx
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x23e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3a53
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
movl $0x8, %edx
callq 0x2350
testb $0x1, %r13b
je 0x38c3
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x3977
movl $0x21, %edx
movq 0x1873e(%rip), %rdi     # 0x1bff0
leaq 0x12a0e(%rip), %rsi     # 0x162c7
callq 0x2240
jmp 0x3970
movq %r12, %rdi
leaq 0x98(%rsp), %rsi
callq 0x2130
movq %rax, %rdi
leaq 0x90(%rsp), %rsi
callq 0x2130
movq %rax, %rdi
leaq 0x88(%rsp), %rsi
callq 0x2130
movq %rax, %rdi
leaq 0x80(%rsp), %rsi
callq 0x2130
movq %rax, %rdi
leaq 0x78(%rsp), %rsi
callq 0x2130
movq %rax, %rdi
leaq 0x70(%rsp), %rsi
callq 0x2130
movq %rax, %rdi
leaq 0x68(%rsp), %rsi
callq 0x2130
movq %rax, %rdi
leaq 0x60(%rsp), %rsi
callq 0x2130
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x3981
movl $0x1c, %edx
movq 0x1869f(%rip), %rdi     # 0x1bff0
movq %rbp, %rsi
callq 0x2240
movq 0x8(%r14), %rsi
subq (%r14), %rsi
sarq $0x5, %rsi
movq 0x18685(%rip), %rdi     # 0x1bff0
callq 0x2140
xorl %ebx, %ebx
jmp 0x3a26
movb $0x1, %bl
xorl %r13d, %r13d
jmp 0x3a26
movl %r13d, 0x14(%rsp)
movq %r14, %rdi
movq %r12, %r13
movq %r15, %r12
movq %rbp, %r15
movsd 0x98(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
movsd 0x88(%rsp), %xmm2
movsd 0x80(%rsp), %xmm3
movsd %xmm0, 0x18(%rsp)
movsd %xmm1, 0x20(%rsp)
movsd %xmm2, 0x28(%rsp)
movsd %xmm3, 0x30(%rsp)
leaq 0x18(%rsp), %rbp
movq %rbp, %rsi
callq 0x43fc
movsd 0x78(%rsp), %xmm0
movsd 0x70(%rsp), %xmm1
movsd 0x68(%rsp), %xmm2
movsd 0x60(%rsp), %xmm3
movsd %xmm0, 0x18(%rsp)
movsd %xmm1, 0x20(%rsp)
movsd %xmm2, 0x28(%rsp)
movsd %xmm3, 0x30(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x43fc
movb $0x1, %bl
movq %r15, %rbp
movq %r12, %r15
movq %r13, %r12
movl 0x14(%rsp), %r13d
movq %r12, %rdi
movq 0x18598(%rip), %rsi     # 0x1bfc8
callq 0x22b0
leaq 0x118(%rsp), %rdi
callq 0x20b0
testb %bl, %bl
movq 0x58(%rsp), %rbx
jne 0x3818
xorl %ebx, %ebx
jmp 0x3a72
movq 0x8(%r14), %rax
subq (%r14), %rax
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
cmpq %rcx, %rax
jne 0x3aaf
sarq $0x5, %rax
cmpq 0x8(%rsp), %rax
sete %bl
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3a8e
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x220(%rsp), %rdi
callq 0x2080
movl %ebx, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12850(%rip), %rdi     # 0x16306
leaq 0x12646(%rip), %rsi     # 0x16103
leaq 0x1285d(%rip), %rcx     # 0x16321
movl $0x12b, %edx            # imm = 0x12B
callq 0x2120
jmp 0x3ade
jmp 0x3ade
movq %rax, %rbx
jmp 0x3b1e
jmp 0x3ad9
movq %rax, %rbx
jmp 0x3b02
movq %rax, %rbx
movq 0x184e0(%rip), %rsi     # 0x1bfc8
leaq 0xa0(%rsp), %rdi
callq 0x22b0
leaq 0x118(%rsp), %rdi
callq 0x20b0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3b1e
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x220(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x23b0