// File: /workspace/github_cpp_makefile_star2_O3/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 0x2db9
movq 0x8(%rsi), %r14
movq 0x10(%rsi), %r15
leaq 0x1(%r15), %rax
movq %r15, %rbx
movzbl -0x1(%rax), %ecx
cmpl $0x2f, %ecx
je 0x25e3
testl %ecx, %ecx
jne 0x25e6
jmp 0x25eb
movq %rax, %rbx
incq %rax
jmp 0x25d4
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 0x5179
testl %eax, %eax
jne 0x2dc1
movq 0xa8c8(%rip), %r12      # 0xcfb0
leaq 0x6bbe(%rip), %rsi      # 0x92ad
movl $0x19, %edx
movq %r12, %rdi
callq 0x21b0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0xa895(%rip), %rdi      # 0xcfb0
callq 0x2050
movq %rax, %rdi
callq 0x2110
leaq 0x3d8(%rsp), %rsi
movq %rax, %rdi
callq 0x2fa9
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r12, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x2110
movq 0xa847(%rip), %r12      # 0xcfb0
leaq 0x6b57(%rip), %rsi      # 0x92c7
movl $0x12, %edx
movq %r12, %rdi
callq 0x21b0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0xa814(%rip), %rdi      # 0xcfb0
callq 0x2050
movq %rax, %rdi
callq 0x2110
leaq 0x438(%rsp), %rsi
movq %rax, %rdi
callq 0x2fa9
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r12, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x2110
leaq 0x498(%rsp), %rsi
movq %rax, %rdi
callq 0x3377
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
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 0x36e2
leaq 0x6aa4(%rip), %rsi      # 0x92da
leaq 0x10(%rsp), %rdi
callq 0x2310
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2868
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x2870
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 0x35ba
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x28b1
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x20(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x28cc
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x108(%rsp), %rsi
movq %r15, %rdi
callq 0x4bc8
testl %eax, %eax
jne 0x2dcb
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 0x3dec
leaq 0x70(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
movq %r14, %rsi
callq 0x36e2
leaq 0x70a7(%rip), %rsi      # 0x99de
leaq 0x70(%rsp), %rdi
callq 0x2310
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2968
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x296f
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 0x36e2
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x98(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r15, %rcx
je 0x29c1
movq 0x40(%rsp), %rdi
movq 0x90(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x29ed
leaq 0xa0(%rsp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x29e8
movq 0xa0(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x29f9
leaq 0x30(%rsp), %rdi
callq 0x2070
jmp 0x2a0a
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2190
movq %r13, 0x10(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x2a2a
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x2a32
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 0x68a9(%rip), %rsi      # 0x92ff
leaq 0x10(%rsp), %rdi
callq 0x2310
movq %r12, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2a83
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x2a8b
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 0x2aba
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0xa0(%rsp), %rbp
movq -0x10(%rbp), %rdi
cmpq %rbp, %rdi
je 0x2adb
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x2af2
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x80(%rsp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x2b14
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0x90(%rsp), %rdi
leaq 0xe(%rsp), %rdx
movq %r14, %rsi
callq 0x36e2
leaq 0x6eae(%rip), %rsi      # 0x99de
leaq 0x90(%rsp), %rdi
callq 0x2310
movq %r12, 0x70(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2b63
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0x2b6b
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 0x36e2
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %r8
movq 0xb8(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r12, %rcx
je 0x2bc0
movq 0x80(%rsp), %rdi
movq 0xb0(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x2bec
leaq 0xc0(%rsp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x2be7
movq 0xc0(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x2bf8
leaq 0x70(%rsp), %rdi
callq 0x2070
jmp 0x2c09
leaq 0xb0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2190
movq %r15, 0x30(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x2c29
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x2c30
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 0x66af(%rip), %rsi      # 0x9303
leaq 0x30(%rsp), %rdi
callq 0x2310
movq %r13, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2c81
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x2c89
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 0x2cb8
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2170
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2cd9
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x2cf3
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x90(%rsp), %rdi
cmpq %rbp, %rdi
leaq 0x60(%rsp), %rbx
je 0x2d15
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x50(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
callq 0x35ba
testl %eax, %eax
jne 0x2dd5
movq 0x10(%rsp), %rsi
leaq 0xe0(%rsp), %rdi
callq 0x35ba
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x2d58
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x50(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2d6f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x2d81
callq 0x21f0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2d93
callq 0x21f0
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x2da5
callq 0x21f0
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 0x2360
movl %eax, %edi
movq %r14, %rsi
callq 0x2387
movl %eax, %edi
movq %r15, %rsi
callq 0x23ad
leaq 0x50(%rsp), %rdi
movl %eax, %esi
callq 0x23d3
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e00
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2e00
movq %rax, %rbx
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2e26
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2e26
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e45
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2e45
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2f4a
movq 0xa0(%rsp), %rsi
jmp 0x2f42
movq %rax, %rbx
jmp 0x2f4a
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x2e8a
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2e8a
movq %rax, %rbx
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2eb0
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2eb0
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x2ecc
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2ecc
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f66
movq 0x80(%rsp), %rsi
jmp 0x2f5e
jmp 0x2eed
movq %rax, %rbx
jmp 0x2f66
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x2f11
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2f11
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f8f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2f8f
jmp 0x2f8c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r13, %rdi
je 0x2f4a
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2f66
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x2f78
callq 0x21f0
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2f8f
callq 0x21f0
jmp 0x2f8f
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x2fa1
callq 0x21f0
movq %rbx, %rdi
callq 0x22d0