// File: 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
movq %rsp, %rbp
subq $0x550, %rsp            # imm = 0x550
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3100
movq %rax, %rsi
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x3550
movq -0x228(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x228(%rbp,%rax), %rdi
callq 0x3140
movb %al, -0x4a9(%rbp)
jmp 0x5064
movb -0x4a9(%rbp), %al
testb $0x1, %al
jne 0x5070
jmp 0x50e4
movq 0x1cf79(%rip), %rdi     # 0x21ff0
leaq 0x171e5(%rip), %rsi     # 0x1c263
callq 0x32c0
movq %rax, -0x4b8(%rbp)
jmp 0x508c
movq -0x4b8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x32b0
movq %rax, -0x4c0(%rbp)
jmp 0x50a5
movq -0x4c0(%rbp), %rdi
movq 0x1cefd(%rip), %rsi     # 0x21fb0
callq 0x3310
jmp 0x50ba
movb $0x0, -0x1(%rbp)
movl $0x1, -0x238(%rbp)
jmp 0x555f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x5579
movq -0x18(%rbp), %rdi
callq 0x6870
movq -0x20(%rbp), %rdi
callq 0x6870
movq $0x0, -0x280(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x33f0
movb $0x1, -0x2a1(%rbp)
testb $0x1, -0x2a1(%rbp)
jne 0x513a
movq -0x18(%rbp), %rdi
callq 0x60c0
movq %rax, %rcx
xorl %eax, %eax
cmpq -0x280(%rbp), %rcx
movb %al, -0x4c1(%rbp)
jge 0x5182
leaq -0x228(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x3070
movq %rax, -0x4d0(%rbp)
jmp 0x5156
movq -0x4d0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x33c0
movb %al, -0x4d1(%rbp)
jmp 0x5174
movb -0x4d1(%rbp), %al
movb %al, -0x4c1(%rbp)
jmp 0x5182
movb -0x4c1(%rbp), %al
testb $0x1, %al
jne 0x5191
jmp 0x54d8
leaq -0x428(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
movl $0x8, %edx
callq 0x34c0
jmp 0x51ab
testb $0x1, -0x2a1(%rbp)
je 0x526c
leaq -0x428(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x31c0
movq %rax, -0x4e0(%rbp)
jmp 0x51d4
movq -0x4e0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3140
movb %al, -0x4e1(%rbp)
jmp 0x51f2
movb -0x4e1(%rbp), %al
testb $0x1, %al
jne 0x51fe
jmp 0x5260
movq 0x1cdeb(%rip), %rdi     # 0x21ff0
leaq 0x1707b(%rip), %rsi     # 0x1c287
callq 0x32c0
jmp 0x5213
movb $0x0, -0x1(%rbp)
movl $0x1, -0x238(%rbp)
jmp 0x54bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x5551
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x428(%rbp), %rdi
callq 0x3150
jmp 0x5551
movb $0x0, -0x2a1(%rbp)
jmp 0x54b1
leaq -0x428(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x3260
movq %rax, -0x4f0(%rbp)
jmp 0x5288
movq -0x4f0(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x3260
movq %rax, -0x4f8(%rbp)
jmp 0x52a4
movq -0x4f8(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x3260
movq %rax, -0x500(%rbp)
jmp 0x52c0
movq -0x500(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x3260
movq %rax, -0x508(%rbp)
jmp 0x52dc
movq -0x508(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x3260
movq %rax, -0x510(%rbp)
jmp 0x52f8
movq -0x510(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x3260
movq %rax, -0x518(%rbp)
jmp 0x5314
movq -0x518(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x3260
movq %rax, -0x520(%rbp)
jmp 0x5330
movq -0x520(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x3260
movq %rax, -0x528(%rbp)
jmp 0x534c
movq -0x528(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3140
movb %al, -0x529(%rbp)
jmp 0x536a
movb -0x529(%rbp), %al
testb $0x1, %al
jne 0x5376
jmp 0x53bf
movq 0x1cc73(%rip), %rdi     # 0x21ff0
leaq 0x16f25(%rip), %rsi     # 0x1c2a9
callq 0x32c0
movq %rax, -0x538(%rbp)
jmp 0x5392
movq -0x18(%rbp), %rdi
callq 0x60c0
movq -0x538(%rbp), %rdi
movq %rax, %rsi
callq 0x3090
jmp 0x53ac
movb $0x0, -0x1(%rbp)
movl $0x1, -0x238(%rbp)
jmp 0x54bb
movq -0x18(%rbp), %rax
movq %rax, -0x540(%rbp)
movsd -0x240(%rbp), %xmm0
movsd -0x248(%rbp), %xmm1
leaq -0x458(%rbp), %rdi
callq 0x6140
jmp 0x53e8
movsd -0x250(%rbp), %xmm0
movsd -0x258(%rbp), %xmm1
leaq -0x468(%rbp), %rdi
callq 0x6140
jmp 0x5406
leaq -0x448(%rbp), %rdi
leaq -0x458(%rbp), %rsi
leaq -0x468(%rbp), %rdx
callq 0x68c0
jmp 0x5422
movq -0x540(%rbp), %rdi
leaq -0x448(%rbp), %rsi
callq 0x6890
jmp 0x5437
movq -0x20(%rbp), %rax
movq %rax, -0x548(%rbp)
movsd -0x260(%rbp), %xmm0
movsd -0x268(%rbp), %xmm1
leaq -0x498(%rbp), %rdi
callq 0x6140
jmp 0x5460
movsd -0x270(%rbp), %xmm0
movsd -0x278(%rbp), %xmm1
leaq -0x4a8(%rbp), %rdi
callq 0x6140
jmp 0x547e
leaq -0x488(%rbp), %rdi
leaq -0x498(%rbp), %rsi
leaq -0x4a8(%rbp), %rdx
callq 0x68c0
jmp 0x549a
movq -0x548(%rbp), %rdi
leaq -0x488(%rbp), %rsi
callq 0x6890
jmp 0x54af
jmp 0x54b1
movl $0x0, -0x238(%rbp)
leaq -0x428(%rbp), %rdi
callq 0x3150
movl -0x238(%rbp), %eax
testl %eax, %eax
jne 0x5543
jmp 0x54d3
jmp 0x5114
movq -0x18(%rbp), %rdi
callq 0x60c0
movq %rax, -0x550(%rbp)
movq -0x20(%rbp), %rdi
callq 0x60c0
movq %rax, %rcx
movq -0x550(%rbp), %rax
cmpq %rcx, %rax
jne 0x5502
jmp 0x5521
leaq 0x16dbd(%rip), %rdi     # 0x1c2c6
leaq 0x16bb3(%rip), %rsi     # 0x1c0c3
movl $0x12b, %edx            # imm = 0x12B
leaq 0x16dc5(%rip), %rcx     # 0x1c2e1
callq 0x31e0
movq -0x18(%rbp), %rdi
callq 0x60c0
cmpq -0x280(%rbp), %rax
sete %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0x238(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x31d0
jmp 0x555f
leaq -0x2a0(%rbp), %rdi
callq 0x31d0
jmp 0x5579
leaq -0x228(%rbp), %rdi
callq 0x30a0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x550, %rsp            # imm = 0x550
popq %rbp
retq
leaq -0x228(%rbp), %rdi
callq 0x30a0
movq -0x230(%rbp), %rdi
callq 0x3520
nopw %cs:(%rax,%rax)