// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
movl %edi, %ebp
cmpl $0x6, %edi
je 0x379e
cmpl $0x9, %ebp
jne 0x3884
movq 0x8(%rbx), %rsi
leaq 0x88(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x3c38
movq 0x10(%rbx), %rsi
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x3c38
movq 0x18(%rbx), %rsi
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3c38
movq 0x20(%rbx), %rdi
callq 0x22a0
movsd %xmm0, 0x8(%rsp)
movq 0x28(%rbx), %rsi
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3c38
xorpd %xmm0, %xmm0
ucomisd 0x8(%rsp), %xmm0
ja 0x3818
movsd 0x8(%rsp), %xmm0
ucomisd 0xb87a(%rip), %xmm0     # 0xf090
jbe 0x3850
movq 0x117b1(%rip), %rdi     # 0x14fd0
leaq 0xbbcf(%rip), %rsi      # 0xf3f5
callq 0x21f0
movq %rax, %rdi
callq 0x2110
movsd 0xb855(%rip), %xmm0     # 0xf090
movapd %xmm0, %xmm1
cmpltsd 0x8(%rsp), %xmm1
andpd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
cmpl $0x9, %ebp
jne 0x38c1
movq 0x30(%rbx), %rdi
callq 0x22a0
movsd %xmm0, 0x20(%rsp)
movq 0x38(%rbx), %rdi
callq 0x22a0
movsd %xmm0, 0x18(%rsp)
movq 0x40(%rbx), %rdi
callq 0x22a0
movsd %xmm0, 0x10(%rsp)
jmp 0x38eb
movq 0x11745(%rip), %rdi     # 0x14fd0
leaq 0xbb1e(%rip), %rsi      # 0xf3b0
callq 0x21f0
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x21f0
leaq 0xbb0f(%rip), %rsi      # 0xf3b8
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2110
pushq $-0x1
popq %rax
jmp 0x3a3e
movsd 0xb7cf(%rip), %xmm0     # 0xf098
movsd %xmm0, 0x10(%rsp)
movsd 0xb7b9(%rip), %xmm0     # 0xf090
movsd %xmm0, 0x18(%rsp)
movsd 0xb7bb(%rip), %xmm0     # 0xf0a0
movsd %xmm0, 0x20(%rsp)
movq 0x116de(%rip), %rdi     # 0x14fd0
leaq 0xbb24(%rip), %rsi      # 0xf41d
callq 0x21f0
leaq 0x88(%rsp), %rsi
movq %rax, %rdi
callq 0x21e0
leaq 0xbb12(%rip), %rsi      # 0xf427
movq %rax, %rdi
callq 0x21f0
leaq 0x48(%rsp), %rsi
movq %rax, %rdi
callq 0x21e0
leaq 0xbafd(%rip), %rsi      # 0xf42e
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x2360
leaq 0xbaee(%rip), %rsi      # 0xf43c
movq %rax, %rdi
callq 0x21f0
leaq 0x28(%rsp), %rsi
movq %rax, %rdi
callq 0x21e0
movq %rax, %rdi
callq 0x2110
movq 0x1165e(%rip), %rdi     # 0x14fd0
leaq 0xbad1(%rip), %rsi      # 0xf44a
callq 0x21f0
movq %rax, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x2360
leaq 0xbacf(%rip), %rsi      # 0xf462
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x2360
leaq 0xbab9(%rip), %rsi      # 0xf469
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x2360
leaq 0xbaa3(%rip), %rsi      # 0xf470
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2110
leaq 0x88(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x68(%rsp), %rdx
leaq 0x28(%rsp), %rcx
movsd 0x8(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x10(%rsp), %xmm3
callq 0x3529
leaq 0x28(%rsp), %rdi
callq 0x20f0
leaq 0x68(%rsp), %rdi
callq 0x20f0
leaq 0x48(%rsp), %rdi
callq 0x20f0
leaq 0x88(%rsp), %rdi
callq 0x20f0
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %rbp
retq
jmp 0x3a59
movq %rax, %rbx
jmp 0x3a66
movq %rax, %rbx
jmp 0x3a70
movq %rax, %rbx
jmp 0x3a7a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x20f0
leaq 0x68(%rsp), %rdi
callq 0x20f0
leaq 0x48(%rsp), %rdi
callq 0x20f0
leaq 0x88(%rsp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x23f0
nop