// File: srajangarg[P]image-morph/src/morph.cpp
// Function: main
int
main(int argc, char * argv[])
{
  if (argc != 6 && argc != 9)
  {
    std::cout << "Usage: " << argv[0] << " image1 image2 segments_file time[0..1] output.png [a  b  p]" << std::endl;
    return -1;
  }

  std::string img1_path  =  argv[1];
  std::string img2_path  =  argv[2];
  std::string seg_path   =  argv[3];
  double t               =  std::atof(argv[4]);
  std::string out_path   =  argv[5];

  // sanity checks
  if (t < 0.0 || t > 1.0)
  {
    std::cout << "Time t out of range: clamping to [0..1]" << std::endl;
    if (t > 1.0)
      t = 1.0;
    else
      t = 0.0;
  }

  double a = 0.5;
  double b = 1;
  double p = 0.2;
  if (argc == 9)
  {
    a = std::atof(argv[6]);
    b = std::atof(argv[7]);
    p = std::atof(argv[8]);
  }

  std::cout << "Morphing " << img1_path << " into " << img2_path << " at time t = " << t << ", generating " << out_path
            << std::endl;
  std::cout << "Using parameters { a : " << a << ", b : " << b << ", p : " << p << " }" << std::endl;

  morphDriver(img1_path, img2_path, seg_path, t, out_path, a, b, p);

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x6, -0x8(%rbp)
je 0x5a41
cmpl $0x9, -0x8(%rbp)
je 0x5a41
movq 0x1c5cc(%rip), %rdi     # 0x21fc8
leaq 0x1698d(%rip), %rsi     # 0x1c390
callq 0x32c0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x32c0
movq %rax, %rdi
leaq 0x16977(%rip), %rsi     # 0x1c398
callq 0x32c0
movq %rax, %rdi
movq 0x1c580(%rip), %rsi     # 0x21fb0
callq 0x3310
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5f5c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xf0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x3530
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x69f0
jmp 0x5a79
leaq -0x31(%rbp), %rdi
callq 0x3330
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x100(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x3530
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x69f0
jmp 0x5aba
leaq -0x69(%rbp), %rdi
callq 0x3330
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x110(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x3530
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x69f0
jmp 0x5b01
leaq -0x91(%rbp), %rdi
callq 0x3330
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x33b0
movsd %xmm0, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x120(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x3530
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
callq 0x69f0
jmp 0x5b60
leaq -0xc1(%rbp), %rdi
callq 0x3330
xorps %xmm0, %xmm0
ucomisd -0xa0(%rbp), %xmm0
ja 0x5b93
movsd -0xa0(%rbp), %xmm0
movsd 0x164ff(%rip), %xmm1    # 0x1c088
ucomisd %xmm1, %xmm0
jbe 0x5c8b
movq 0x1c42e(%rip), %rdi     # 0x21fc8
leaq 0x16834(%rip), %rsi     # 0x1c3d5
callq 0x32c0
movq %rax, -0x128(%rbp)
jmp 0x5baf
movq -0x128(%rbp), %rdi
movq 0x1c3f3(%rip), %rsi     # 0x21fb0
callq 0x3310
jmp 0x5bc4
movsd -0xa0(%rbp), %xmm0
movsd 0x164b4(%rip), %xmm1    # 0x1c088
ucomisd %xmm1, %xmm0
jbe 0x5c7e
movsd 0x164a2(%rip), %xmm0    # 0x1c088
movsd %xmm0, -0xa0(%rbp)
jmp 0x5c89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x3330
jmp 0x5f68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x3330
jmp 0x5f51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x3330
jmp 0x5f48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xc1(%rbp), %rdi
callq 0x3330
jmp 0x5f3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x31d0
jmp 0x5f3c
xorps %xmm0, %xmm0
movsd %xmm0, -0xa0(%rbp)
jmp 0x5c8b
movsd 0x16405(%rip), %xmm0    # 0x1c098
movsd %xmm0, -0xd0(%rbp)
movsd 0x163e5(%rip), %xmm0    # 0x1c088
movsd %xmm0, -0xd8(%rbp)
movsd 0x163dd(%rip), %xmm0    # 0x1c090
movsd %xmm0, -0xe0(%rbp)
cmpl $0x9, -0x8(%rbp)
jne 0x5d00
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x33b0
movsd %xmm0, -0xd0(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x33b0
movsd %xmm0, -0xd8(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x33b0
movsd %xmm0, -0xe0(%rbp)
movq 0x1c2c1(%rip), %rdi     # 0x21fc8
leaq 0x166ef(%rip), %rsi     # 0x1c3fd
callq 0x32c0
movq %rax, -0x130(%rbp)
jmp 0x5d1c
movq -0x130(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x32b0
movq %rax, -0x138(%rbp)
jmp 0x5d35
movq -0x138(%rbp), %rdi
leaq 0x166c4(%rip), %rsi     # 0x1c407
callq 0x32c0
movq %rax, -0x140(%rbp)
jmp 0x5d51
movq -0x140(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x32b0
movq %rax, -0x148(%rbp)
jmp 0x5d6a
movq -0x148(%rbp), %rdi
leaq 0x16696(%rip), %rsi     # 0x1c40e
callq 0x32c0
movq %rax, -0x150(%rbp)
jmp 0x5d86
movq -0x150(%rbp), %rdi
movsd -0xa0(%rbp), %xmm0
callq 0x3560
movq %rax, -0x158(%rbp)
jmp 0x5da3
movq -0x158(%rbp), %rdi
leaq 0x1666b(%rip), %rsi     # 0x1c41c
callq 0x32c0
movq %rax, -0x160(%rbp)
jmp 0x5dbf
movq -0x160(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x32b0
movq %rax, -0x168(%rbp)
jmp 0x5ddb
movq -0x168(%rbp), %rdi
movq 0x1c1c7(%rip), %rsi     # 0x21fb0
callq 0x3310
jmp 0x5df0
movq 0x1c1d1(%rip), %rdi     # 0x21fc8
leaq 0x1662c(%rip), %rsi     # 0x1c42a
callq 0x32c0
movq %rax, -0x170(%rbp)
jmp 0x5e0c
movq -0x170(%rbp), %rdi
movsd -0xd0(%rbp), %xmm0
callq 0x3560
movq %rax, -0x178(%rbp)
jmp 0x5e29
movq -0x178(%rbp), %rdi
leaq 0x1660b(%rip), %rsi     # 0x1c442
callq 0x32c0
movq %rax, -0x180(%rbp)
jmp 0x5e45
movq -0x180(%rbp), %rdi
movsd -0xd8(%rbp), %xmm0
callq 0x3560
movq %rax, -0x188(%rbp)
jmp 0x5e62
movq -0x188(%rbp), %rdi
leaq 0x165d9(%rip), %rsi     # 0x1c449
callq 0x32c0
movq %rax, -0x190(%rbp)
jmp 0x5e7e
movq -0x190(%rbp), %rdi
movsd -0xe0(%rbp), %xmm0
callq 0x3560
movq %rax, -0x198(%rbp)
jmp 0x5e9b
movq -0x198(%rbp), %rdi
leaq 0x165a7(%rip), %rsi     # 0x1c450
callq 0x32c0
movq %rax, -0x1a0(%rbp)
jmp 0x5eb7
movq -0x1a0(%rbp), %rdi
movq 0x1c0eb(%rip), %rsi     # 0x21fb0
callq 0x3310
jmp 0x5ecc
movsd -0xa0(%rbp), %xmm0
movsd -0xd0(%rbp), %xmm1
movsd -0xd8(%rbp), %xmm2
movsd -0xe0(%rbp), %xmm3
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x90(%rbp), %rdx
leaq -0xc0(%rbp), %rcx
callq 0x55a0
jmp 0x5f09
movl $0x0, -0x4(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x31d0
leaq -0x90(%rbp), %rdi
callq 0x31d0
leaq -0x68(%rbp), %rdi
callq 0x31d0
leaq -0x30(%rbp), %rdi
callq 0x31d0
jmp 0x5f5c
leaq -0x90(%rbp), %rdi
callq 0x31d0
leaq -0x68(%rbp), %rdi
callq 0x31d0
leaq -0x30(%rbp), %rdi
callq 0x31d0
jmp 0x5f68
movl -0x4(%rbp), %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x3520
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)