// File: /workspace/github_cpp_makefile_star2_O1/devernay[P]vlpovutils/vlpov_motionfield.cpp
// Function: main
int main(int argc, char *argv[])
{
    if (argc != 3) {
        fprintf(stderr, USAGE, argv[0]);
        exit(2);
    }
    const char *frame1 = argv[1];
    const char *frame2 = argv[2];
    const char *frame2_basename = mybasename(frame2);

#ifdef VLPOV_OLD
#warning "compiling in comparison with old vlpovutils"
    {
        VLPovImage<double> z1;
        VLPovCameraOld cam1;
        VLPovCameraOld cam2;
        int retval;
    
        retval = vlpov_povread_old(frame1, z1, cam1);
        if(retval != 0) {
            fprintf(stderr,"Error %d while reading %s.{png,depth,txt}\n", retval, frame1);
            exit(1);
        }
        matrix33 K1, R1;
        vector3 t1;
        cam1.intrinsicMatrix(K1);
        //cam1.extrinsicParameters(R1, t1);
        cout << "Intrinsic matrix 1 (old): " << endl << K1 << endl;
        cout << "Extrinsic 1 (old): " << endl << cam1.R << endl << cam1.T << endl;
        z1.save((std::string(frame1)+".zold").c_str());
                
        retval = vlpov_povread_old(frame2, cam2);
        if(retval != 0) {
            fprintf(stderr,"Error %d while reading %s.txt\n", retval, frame2);
            exit(1);
        }
        
        VLPovImage<double> m1x, m1y;
        vlpov_motionfield_old(cam1, z1, cam2, m1x, m1y);
        std::string m1x_name = std::string(frame1)+"."+std::string(frame2_basename)+".mxold";
        std::string m1y_name = std::string(frame1)+"."+std::string(frame2_basename)+".myold";
        retval = m1x.save(m1x_name.c_str());
        if(retval != 0) {
            fprintf(stderr,"Error %d while saving %s\n", retval, m1x_name.c_str());
            exit(1);
        }
    
        m1y.save(m1y_name.c_str());
        if(retval != 0) {
            fprintf(stderr,"Error %d while saving %s\n", retval, m1y_name.c_str());
            exit(1);
        }
    }
#endif // VLPOV_OLD
    
    {
        VLPovImage<double> z1;
        VLPovCamera cam1;
        VLPovCamera cam2;
        int retval;
        
        retval = vlpov_povread(frame1, z1, cam1);
        if(retval != 0) {
            fprintf(stderr,"Error %d while reading %s.{png,depth,txt}\n", retval, frame1);
            exit(1);
        }
 
        cout << "Intrinsic matrix 1(new): " << endl << cam1.K << endl;
        cout << "Extrinsic 1(new): " << endl << cam1.R << endl << cam1.t << endl;
        z1.save((std::string(frame1)+".znew").c_str());
        
        retval = vlpov_povread(frame2, cam2);
        if(retval != 0) {
            fprintf(stderr,"Error %d while reading %s.txt\n", retval, frame2);
            exit(1);
        }
        
        VLPovImage<double> m1x, m1y;
        vlpov_motionfield(cam1, z1, cam2, m1x, m1y);
        std::string m1x_name = std::string(frame1)+"."+std::string(frame2_basename)+".mx";
        std::string m1y_name = std::string(frame1)+"."+std::string(frame2_basename)+".my";
        retval = m1x.save(m1x_name.c_str());
        if(retval != 0) {
            fprintf(stderr,"Error %d while saving %s\n", retval, m1x_name.c_str());
            exit(1);
        }
        
        m1y.save(m1y_name.c_str());
        if(retval != 0) {
            fprintf(stderr,"Error %d while saving %s\n", retval, m1y_name.c_str());
            exit(1);
        }
    }
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b8, %rsp            # imm = 0x4B8
cmpl $0x3, %edi
jne 0x2dcb
movq 0x8(%rsi), %r14
movq 0x10(%rsi), %r15
leaq 0x1(%r15), %rax
movq %r15, %rbx
movzbl -0x1(%rax), %ecx
cmpl $0x2f, %ecx
je 0x25f3
testl %ecx, %ecx
jne 0x25f6
jmp 0x25fb
movq %rax, %rbx
incq %rax
jmp 0x25e4
xorps %xmm0, %xmm0
leaq 0xd0(%rsp), %rsi
movaps %xmm0, (%rsi)
movl $0x3, %eax
leaq 0x2e0(%rsp), %rdx
movq %rax, 0x8(%rdx)
movq %rax, 0x28(%rdx)
movq %rax, 0x48(%rdx)
movq %rax, 0x68(%rdx)
movq %rax, 0x88(%rdx)
movq %rax, 0xa8(%rdx)
movq %rax, 0xc8(%rdx)
movq %rax, 0xf8(%rdx)
movq %rax, 0x100(%rdx)
movl $0x9, %ecx
movq %rcx, 0x108(%rdx)
movq %rax, 0x158(%rdx)
movq %rax, 0x160(%rdx)
movq %rcx, 0x168(%rdx)
movq %rax, 0x1b8(%rdx)
movq %rax, 0x110(%rsp)
movq %rax, 0x130(%rsp)
movq %rax, 0x150(%rsp)
movq %rax, 0x170(%rsp)
movq %rax, 0x190(%rsp)
movq %rax, 0x1b0(%rsp)
movq %rax, 0x1d0(%rsp)
movq %rax, 0x200(%rsp)
movq %rax, 0x208(%rsp)
movq %rcx, 0x210(%rsp)
movq %rax, 0x260(%rsp)
movq %rax, 0x268(%rsp)
movq %rcx, 0x270(%rsp)
movq %rax, 0x2c0(%rsp)
movq %r14, %rdi
callq 0x51d7
testl %eax, %eax
jne 0x2dd3
movq 0xa8b8(%rip), %r12      # 0xcfb0
leaq 0x6bae(%rip), %rsi      # 0x92ad
movl $0x19, %edx
movq %r12, %rdi
callq 0x21c0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0xa885(%rip), %rdi      # 0xcfb0
callq 0x2050
movq %rax, %rdi
callq 0x2110
leaq 0x3d8(%rsp), %rsi
movq %rax, %rdi
callq 0x2fbb
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r12, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x2110
movq 0xa837(%rip), %r12      # 0xcfb0
leaq 0x6b47(%rip), %rsi      # 0x92c7
movl $0x12, %edx
movq %r12, %rdi
callq 0x21c0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq 0xa804(%rip), %rdi      # 0xcfb0
callq 0x2050
movq %rax, %rdi
callq 0x2110
leaq 0x438(%rsp), %rsi
movq %rax, %rdi
callq 0x2fbb
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r12, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x2110
leaq 0x498(%rsp), %rsi
movq %rax, %rdi
callq 0x3382
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r12, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x2110
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
movq %r14, %rsi
callq 0x36ee
leaq 0x6a94(%rip), %rsi      # 0x92da
leaq 0x10(%rsp), %rdi
callq 0x2320
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2878
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x2880
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x50(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x35c6
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x28c1
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2180
leaq 0x20(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x28dc
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2180
leaq 0x108(%rsp), %rsi
movq %r15, %rdi
callq 0x4bf4
testl %eax, %eax
jne 0x2ddd
xorps %xmm0, %xmm0
leaq 0xf0(%rsp), %rcx
movaps %xmm0, (%rcx)
leaq 0xe0(%rsp), %r8
movaps %xmm0, (%r8)
leaq 0x2e0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0x108(%rsp), %rdx
callq 0x3df0
leaq 0x70(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
movq %r14, %rsi
callq 0x36ee
leaq 0x7087(%rip), %rsi      # 0x99ce
leaq 0x70(%rsp), %rdi
callq 0x2320
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2978
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x297f
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x90(%rsp), %rdi
leaq 0xe(%rsp), %rdx
movq %rbx, %rsi
callq 0x36ee
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x98(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r15, %rcx
je 0x29d1
movq 0x40(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x29f6
leaq 0xa0(%rsp), %rdi
movl $0xf, %esi
cmpq %rdi, -0x10(%rdi)
je 0x29f1
movq 0xa0(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x2a0a
movq 0x90(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x2070
jmp 0x2a1b
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21a0
movq %r13, 0x10(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x2a3b
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x2a43
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x6898(%rip), %rsi      # 0x92ff
leaq 0x10(%rsp), %rdi
callq 0x2320
movq %r12, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2a94
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x2a9c
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x2acb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2180
leaq 0xa0(%rsp), %rbp
movq -0x10(%rbp), %rdi
cmpq %rbp, %rdi
je 0x2aec
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x2b03
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2180
leaq 0x80(%rsp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x2b25
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2180
leaq 0x90(%rsp), %rdi
leaq 0xe(%rsp), %rdx
movq %r14, %rsi
callq 0x36ee
leaq 0x6e8d(%rip), %rsi      # 0x99ce
leaq 0x90(%rsp), %rdi
callq 0x2320
movq %r12, 0x70(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2b74
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0x2b7c
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x78(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xb0(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %rbx, %rsi
callq 0x36ee
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %r8
movq 0xb8(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r12, %rcx
je 0x2bd1
movq 0x80(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x2bf6
leaq 0xc0(%rsp), %rdi
movl $0xf, %esi
cmpq %rdi, -0x10(%rdi)
je 0x2bf1
movq 0xc0(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x2c0a
movq 0xb0(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x2070
jmp 0x2c1b
leaq 0xb0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21a0
movq %r15, 0x30(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x2c3b
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x2c42
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x669d(%rip), %rsi      # 0x9303
leaq 0x30(%rsp), %rdi
callq 0x2320
movq %r13, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2c93
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x2c9b
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x2cca
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2180
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2ceb
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x2d05
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x90(%rsp), %rdi
cmpq %rbp, %rdi
leaq 0x60(%rsp), %rbx
je 0x2d27
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x50(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x35c6
testl %eax, %eax
jne 0x2de7
movq 0x10(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x35c6
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x2d6a
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x50(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2d81
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x2d93
callq 0x2200
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2da5
callq 0x2200
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x2db7
callq 0x2200
xorl %eax, %eax
addq $0x4b8, %rsp            # imm = 0x4B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rdi
callq 0x2370
movl %eax, %edi
movq %r14, %rsi
callq 0x2397
movl %eax, %edi
movq %r15, %rsi
callq 0x23bd
leaq 0x50(%rsp), %rdi
movl %eax, %esi
callq 0x23e3
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e12
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2180
jmp 0x2e12
movq %rax, %rbx
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2e38
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2180
jmp 0x2e38
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e57
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2180
jmp 0x2e57
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2f5c
movq 0xa0(%rsp), %rsi
jmp 0x2f54
movq %rax, %rbx
jmp 0x2f5c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x2e9c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2180
jmp 0x2e9c
movq %rax, %rbx
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2ec2
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2180
jmp 0x2ec2
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x2ede
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2180
jmp 0x2ede
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f78
movq 0x80(%rsp), %rsi
jmp 0x2f70
jmp 0x2eff
movq %rax, %rbx
jmp 0x2f78
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x2f23
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2180
jmp 0x2f23
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2fa1
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2180
jmp 0x2fa1
jmp 0x2f9e
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x2f5c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2f78
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2180
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x2f8a
callq 0x2200
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2fa1
callq 0x2200
jmp 0x2fa1
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x2fb3
callq 0x2200
movq %rbx, %rdi
callq 0x22e0