// File: /workspace/github_cpp_makefile_star2_O3/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 $0x418, %rsp            # imm = 0x418
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movq (%rdi), %rsi
leaq 0x210(%rsp), %r15
movq %r15, %rdi
movl $0x8, %edx
callq 0x23b0
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x230(%rsp,%rax)
je 0x35ee
movq 0x18a59(%rip), %rdi     # 0x1bff0
leaq 0x12d05(%rip), %rsi     # 0x162a3
movl $0x23, %edx
callq 0x2220
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x18a38(%rip), %rdi     # 0x1bff0
callq 0x2220
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
xorl %ebx, %ebx
jmp 0x387e
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x35fb
movq %rax, 0x8(%r14)
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x3608
movq %rax, 0x8(%rbx)
xorl %eax, %eax
leaq 0x8(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x40(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movb $0x1, %r12b
leaq 0x90(%rsp), %r13
movq %rbx, %rbp
testb $0x1, %r12b
jne 0x364f
movq 0x8(%r14), %rax
subq (%r14), %rax
movq %rax, %rcx
sarq $0x5, %rcx
cmpq 0x8(%rsp), %rcx
jge 0x384a
movq 0x210(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x23c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3843
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
movl $0x8, %edx
callq 0x2330
testb $0x1, %r12b
je 0x36e3
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0x21e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x3813
movl $0x21, %edx
movq 0x18923(%rip), %rdi     # 0x1bff0
leaq 0x12bf3(%rip), %rsi     # 0x162c7
callq 0x2220
movb $0x1, %r12b
xorl %ebx, %ebx
jmp 0x3818
movq %r13, %rdi
leaq 0x88(%rsp), %rsi
callq 0x2120
leaq 0x10(%rsp), %r12
movq %rax, %rdi
leaq 0x80(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
leaq 0x78(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
leaq 0x70(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
leaq 0x68(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
leaq 0x60(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x2120
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x3797
movl $0x1c, %edx
movq 0x18880(%rip), %rdi     # 0x1bff0
leaq 0x12b72(%rip), %rsi     # 0x162e9
callq 0x2220
movq 0x8(%r14), %rsi
subq (%r14), %rsi
sarq $0x5, %rsi
movq 0x18862(%rip), %rdi     # 0x1bff0
callq 0x2130
xorl %ebx, %ebx
jmp 0x3815
movsd 0x88(%rsp), %xmm0
movsd 0x80(%rsp), %xmm1
movsd 0x78(%rsp), %xmm2
movsd 0x70(%rsp), %xmm3
movsd %xmm0, 0x10(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm2, 0x20(%rsp)
movsd %xmm3, 0x28(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x41f2
movsd 0x68(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movsd 0x50(%rsp), %xmm3
movsd %xmm0, 0x10(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm2, 0x20(%rsp)
movsd %xmm3, 0x28(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x41f2
movb $0x1, %bl
xorl %r12d, %r12d
movq %r13, %rdi
movq 0x187a6(%rip), %rsi     # 0x1bfc8
callq 0x2290
leaq 0x108(%rsp), %rdi
callq 0x20b0
testb %bl, %bl
movq %rbp, %rbx
jne 0x3630
xorl %ebx, %ebx
jmp 0x3862
movq 0x8(%r14), %rax
subq (%r14), %rax
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
cmpq %rcx, %rax
jne 0x389f
sarq $0x5, %rax
cmpq 0x8(%rsp), %rax
sete %bl
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x387e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x210(%rsp), %rdi
callq 0x2080
movl %ebx, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12a60(%rip), %rdi     # 0x16306
leaq 0x12856(%rip), %rsi     # 0x16103
leaq 0x12a6d(%rip), %rcx     # 0x16321
movl $0x12b, %edx            # imm = 0x12B
callq 0x2110
jmp 0x38ce
jmp 0x38ce
movq %rax, %rbx
jmp 0x390e
jmp 0x38c9
movq %rax, %rbx
jmp 0x38f2
movq %rax, %rbx
movq 0x186f0(%rip), %rsi     # 0x1bfc8
leaq 0x90(%rsp), %rdi
callq 0x2290
leaq 0x108(%rsp), %rdi
callq 0x20b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x390e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21d0
leaq 0x210(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2390