// File: /workspace/github_cpp_makefile_star2_O2/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, %r15
movq (%rdi), %rsi
leaq 0x90(%rsp), %r12
pushq $0x8
popq %rdx
movq %r12, %rdi
callq 0x2410
movq (%r12), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
je 0x326c
movq 0x11daa(%rip), %rdi     # 0x14ff0
leaq 0xc036(%rip), %rsi      # 0xf283
callq 0x21f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21e0
movq %rax, %rdi
callq 0x2110
xorl %ebx, %ebx
jmp 0x34aa
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x3279
movq %rax, 0x8(%r14)
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x3286
movq %rax, 0x8(%rbx)
leaq 0x8(%rsp), %rax
andq $0x0, (%rax)
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movb $0x1, %r15b
leaq 0x70(%rsp), %r13
leaq 0x298(%rsp), %rbp
leaq 0x10(%rsp), %r12
testb $0x1, %r15b
jne 0x32d7
movq 0x8(%r14), %rax
subq (%r14), %rax
movq %rax, %rcx
sarq $0x5, %rcx
cmpq 0x8(%rsp), %rcx
jge 0x3488
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x2060
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3481
movq %rbp, %rdi
movq %r13, %rsi
pushq $0x8
popq %rdx
callq 0x23a0
testb $0x1, %r15b
je 0x334a
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x3461
movq 0x11cbd(%rip), %rdi     # 0x14ff0
leaq 0xbf6d(%rip), %rsi      # 0xf2a7
callq 0x21f0
movb $0x1, %r15b
xorl %r12d, %r12d
jmp 0x3467
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x60(%rsp), %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x48(%rsp), %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x40(%rsp), %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x38(%rsp), %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0x2160
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x33eb
movq 0x11c29(%rip), %rdi     # 0x14ff0
leaq 0xbefb(%rip), %rsi      # 0xf2c9
callq 0x21f0
movq 0x8(%r14), %rsi
subq (%r14), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x2170
xorl %r12d, %r12d
jmp 0x3464
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 %r14, %rdi
movq %r12, %rsi
callq 0x3d36
movsd 0x48(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
movsd 0x30(%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 0x3d36
movb $0x1, %r12b
xorl %r15d, %r15d
movq %rbp, %rdi
callq 0x2100
testb %r12b, %r12b
leaq 0x10(%rsp), %r12
jne 0x32b8
xorl %ebx, %ebx
jmp 0x34a0
movq 0x8(%r14), %rax
subq (%r14), %rax
movq 0x8(%rbx), %rcx
subq (%rbx), %rcx
cmpq %rcx, %rax
jne 0x34cb
sarq $0x5, %rax
cmpq 0x8(%rsp), %rax
sete %bl
leaq 0x70(%rsp), %rdi
callq 0x20f0
leaq 0x90(%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 0xbe14(%rip), %rdi      # 0xf2e6
leaq 0xbc0a(%rip), %rsi      # 0xf0e3
leaq 0xbe21(%rip), %rcx      # 0xf301
movl $0x12b, %edx            # imm = 0x12B
callq 0x2150
jmp 0x34fa
jmp 0x34fa
movq %rax, %rbx
jmp 0x3514
jmp 0x34f5
movq %rax, %rbx
jmp 0x350a
movq %rax, %rbx
leaq 0x298(%rsp), %rdi
callq 0x2100
leaq 0x70(%rsp), %rdi
callq 0x20f0
leaq 0x90(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x23f0