// File: manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImgList<double>::save_ffmpeg_external(char const*, unsigned int, char const*, unsigned int) const
const CImgList<T>& save_ffmpeg_external(const char *const filename, const unsigned int fps=25,
                                            const char *const codec=0, const unsigned int bitrate=2048) const {
      if (!filename)
        throw CImgArgumentException(_cimglist_instance
                                    "save_ffmpeg_external(): Specified filename is (null).",
                                    cimglist_instance);
      if (is_empty()) { cimg::fempty(0,filename); return *this; }

      const char
        *const ext = cimg::split_filename(filename),
        *const _codec = codec?codec:!cimg::strcasecmp(ext,"flv")?"flv":"mpeg2video";

      char command[1024] = { 0 }, filetmp[512] = { 0 }, filetmp2[512] = { 0 };
      CImgList<charT> filenames;
      std::FILE *file = 0;
      cimglist_for(*this,l) if (!_data[l].is_sameXYZ(_data[0]))
        throw CImgInstanceException(_cimglist_instance
                                    "save_ffmpeg_external(): Invalid instance dimensions for file '%s'.",
                                    cimglist_instance,
                                    filename);
      do {
        cimg_snprintf(filetmp,sizeof(filetmp),"%s%c%s",cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());
        cimg_snprintf(filetmp2,sizeof(filetmp2),"%s_000001.ppm",filetmp);
        if ((file=std::fopen(filetmp2,"rb"))!=0) cimg::fclose(file);
      } while (file);
      cimglist_for(*this,l) {
        cimg_snprintf(filetmp2,sizeof(filetmp2),"%s_%.6u.ppm",filetmp,l+1);
        CImg<charT>::string(filetmp2).move_to(filenames);
        if (_data[l]._depth>1 || _data[l]._spectrum!=3) _data[l].get_resize(-100,-100,1,3).save_pnm(filetmp2);
        else _data[l].save_pnm(filetmp2);
      }
#if cimg_OS!=2
      cimg_snprintf(command,sizeof(command),"%s -i \"%s_%%6d.ppm\" -vcodec %s -b %uk -r %u -y \"%s\" >/dev/null 2>&1",
                    cimg::ffmpeg_path(),
                    CImg<charT>::string(filetmp)._system_strescape().data(),
                    _codec,bitrate,fps,
                    CImg<charT>::string(filename)._system_strescape().data());
#else
      cimg_snprintf(command,sizeof(command),"\"%s -i \"%s_%%6d.ppm\" -vcodec %s -b %uk -r %u -y \"%s\"\" >NUL 2>&1",
                    cimg::ffmpeg_path(),
                    CImg<charT>::string(filetmp)._system_strescape().data(),
                    _codec,bitrate,fps,
                    CImg<charT>::string(filename)._system_strescape().data());
#endif
      cimg::system(command);
      file = std::fopen(filename,"rb");
      if (!file)
        throw CImgIOException(_cimglist_instance
                              "save_ffmpeg_external(): Failed to save file '%s' with external command 'ffmpeg'.",
                              cimglist_instance,
                              filename);
      else cimg::fclose(file);
      cimglist_for(*this,l) std::remove(filenames[l]);
      return *this;
    }

// Assembly:
subq $0xa28, %rsp            # imm = 0xA28
movq %rdi, 0xa18(%rsp)
movq %rsi, 0xa10(%rsp)
movl %edx, 0xa0c(%rsp)
movq %rcx, 0xa00(%rsp)
movl %r8d, 0x9fc(%rsp)
movq 0xa18(%rsp), %rax
movq %rax, 0x120(%rsp)
cmpq $0x0, 0xa10(%rsp)
jne 0xb3df8
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0x120(%rsp), %rax
movq %rcx, 0x108(%rsp)
movq %rcx, 0x100(%rsp)
movl (%rax), %ecx
movl %ecx, 0x110(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x114(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x118(%rsp)
callq 0x7c860
movq 0x108(%rsp), %rdi
movl 0x110(%rsp), %edx
movl 0x114(%rsp), %ecx
movq 0x118(%rsp), %r8
movq %rax, %r9
leaq 0x38e9e(%rip), %rsi     # 0xecc4c
xorl %eax, %eax
callq 0x12220
jmp 0xb3db7
movq 0x100(%rsp), %rdi
leaq 0x4bd9a(%rip), %rsi     # 0xffb60
leaq -0xa196d(%rip), %rdx    # 0x12460
callq 0x5920
movq 0x100(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x9f0(%rsp)
movl %eax, 0x9ec(%rsp)
callq 0x53a0
jmp 0xb4672
movq 0x120(%rsp), %rdi
callq 0x5ce60
testb $0x1, %al
jne 0xb3e0b
jmp 0xb3e31
movq 0xa10(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x9c310
movq 0x120(%rsp), %rax
movq %rax, 0xa20(%rsp)
jmp 0xb4662
movq 0xa10(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x63280
movq %rax, 0x9e0(%rsp)
cmpq $0x0, 0xa00(%rsp)
je 0xb3e67
movq 0xa00(%rsp), %rax
movq %rax, 0xf8(%rsp)
jmp 0xb3ea1
movq 0x9e0(%rsp), %rdi
leaq 0x3528e(%rip), %rsi     # 0xe9104
callq 0x633b0
cmpl $0x0, %eax
setne %dl
xorb $-0x1, %dl
leaq 0x38e1a(%rip), %rax     # 0xecca5
leaq 0x35272(%rip), %rcx     # 0xe9104
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0xf8(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x9d8(%rsp)
leaq 0x5d0(%rsp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x52a0
leaq 0x3d0(%rsp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x52a0
leaq 0x1d0(%rsp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x52a0
leaq 0x1c0(%rsp), %rdi
callq 0x7b940
movq $0x0, 0x1b8(%rsp)
movl $0x0, 0x1b4(%rsp)
movq 0x120(%rsp), %rcx
movl 0x1b4(%rsp), %eax
cmpl (%rcx), %eax
jge 0xb4064
movq 0x120(%rsp), %rax
movq 0x8(%rax), %rsi
movslq 0x1b4(%rsp), %rax
shlq $0x5, %rax
movq %rsi, %rdi
addq %rax, %rdi
callq 0xb4680
movb %al, 0xf7(%rsp)
jmp 0xb3f54
movb 0xf7(%rsp), %al
testb $0x1, %al
jne 0xb404c
jmp 0xb3f65
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0x120(%rsp), %rax
movq %rcx, 0xd8(%rsp)
movq %rcx, 0xd0(%rsp)
movl (%rax), %ecx
movl %ecx, 0xe0(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0xe4(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0xe8(%rsp)
callq 0x7c860
movq 0xd8(%rsp), %rdi
movl 0xe0(%rsp), %edx
movl 0xe4(%rsp), %ecx
movq 0xe8(%rsp), %r8
movq %rax, %r9
movq 0xa10(%rsp), %rsi
movq %rsp, %rax
movq %rsi, (%rax)
leaq 0x38ccc(%rip), %rsi     # 0xeccb0
xorl %eax, %eax
callq 0x11fd0
jmp 0xb3fed
movq 0xd0(%rsp), %rdi
leaq 0x4bb4c(%rip), %rsi     # 0xffb48
leaq -0xa1df3(%rip), %rdx    # 0x12210
callq 0x5920
jmp 0xb467f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x9f0(%rsp)
movl %eax, 0x9ec(%rsp)
jmp 0xb4653
movq 0xd0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x9f0(%rsp)
movl %eax, 0x9ec(%rsp)
callq 0x53a0
jmp 0xb4653
jmp 0xb404e
movl 0x1b4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1b4(%rsp)
jmp 0xb3f11
jmp 0xb4066
leaq 0x3d0(%rsp), %rax
movq %rax, 0xc0(%rsp)
xorl %esi, %esi
movl %esi, %edi
callq 0x5c290
movq %rax, 0xc8(%rsp)
jmp 0xb4089
callq 0x5c7a0
movq %rax, 0xb8(%rsp)
jmp 0xb4098
movq 0xb8(%rsp), %r9
movq 0xc8(%rsp), %rcx
movq 0xc0(%rsp), %rdi
leaq 0x34e42(%rip), %rdx     # 0xe8ef9
xorl %eax, %eax
movb %al, 0xa7(%rsp)
movl $0x200, %esi            # imm = 0x200
movq %rsi, 0x98(%rsp)
movl $0x2f, %r8d
callq 0x5890
movq 0x98(%rsp), %rsi
movb 0xa7(%rsp), %al
leaq 0x36dea(%rip), %rdx     # 0xeaed8
leaq 0x1d0(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
leaq 0x3d0(%rsp), %rcx
callq 0x5890
movq 0xa8(%rsp), %rdi
leaq 0x35044(%rip), %rsi     # 0xe915e
callq 0x55c0
movq %rax, 0xb0(%rsp)
jmp 0xb4129
movq 0xb0(%rsp), %rax
movq %rax, 0x1b8(%rsp)
cmpq $0x0, %rax
je 0xb4150
movq 0x1b8(%rsp), %rdi
callq 0x5c6f0
jmp 0xb414e
jmp 0xb4150
jmp 0xb4152
cmpq $0x0, 0x1b8(%rsp)
jne 0xb4066
movl $0x0, 0x1b0(%rsp)
movq 0x120(%rsp), %rcx
movl 0x1b0(%rsp), %eax
cmpl (%rcx), %eax
jge 0xb4365
movl 0x1b0(%rsp), %r8d
incl %r8d
leaq 0x36d7d(%rip), %rdx     # 0xeaf12
xorl %eax, %eax
movl %eax, 0x94(%rsp)
leaq 0x1d0(%rsp), %rdi
movq %rdi, 0x88(%rsp)
movl $0x200, %esi            # imm = 0x200
leaq 0x3d0(%rsp), %rcx
callq 0x5890
movq 0x88(%rsp), %rsi
movl 0x94(%rsp), %ecx
leaq 0x190(%rsp), %rdi
movl $0x1, %edx
callq 0x7ab40
jmp 0xb41e3
leaq 0x190(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7b960
jmp 0xb41ff
leaq 0x190(%rsp), %rdi
callq 0x1a320
movq 0x120(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0x1b0(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x1, 0x8(%rax)
ja 0xb4252
movq 0x120(%rsp), %rax
movq 0x8(%rax), %rax
movslq 0x1b0(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x3, 0xc(%rax)
je 0xb431f
movq 0x120(%rsp), %rax
movq 0x8(%rax), %rsi
movslq 0x1b0(%rsp), %rax
shlq $0x5, %rax
addq %rax, %rsi
movq %rsp, %rax
movl $0x0, 0x8(%rax)
movl $0x1, (%rax)
leaq 0x170(%rsp), %rdi
movl $0xffffff9c, %ecx       # imm = 0xFFFFFF9C
movl $0x1, %r8d
movl $0x3, %r9d
xorps %xmm3, %xmm3
movl %ecx, %edx
movaps %xmm3, %xmm0
movaps %xmm3, %xmm1
movaps %xmm3, %xmm2
callq 0x677c0
jmp 0xb42ab
leaq 0x170(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
xorl %edx, %edx
callq 0x99880
jmp 0xb42c4
leaq 0x170(%rsp), %rdi
callq 0xa540
jmp 0xb434d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x9f0(%rsp)
movl %eax, 0x9ec(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x1a320
jmp 0xb4653
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x9f0(%rsp)
movl %eax, 0x9ec(%rsp)
leaq 0x170(%rsp), %rdi
callq 0xa540
jmp 0xb4653
movq 0x120(%rsp), %rax
movq 0x8(%rax), %rdi
movslq 0x1b0(%rsp), %rax
shlq $0x5, %rax
addq %rax, %rdi
leaq 0x1d0(%rsp), %rsi
xorl %edx, %edx
callq 0x99880
jmp 0xb434b
jmp 0xb434d
jmp 0xb434f
movl 0x1b0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1b0(%rsp)
jmp 0xb416c
leaq 0x5d0(%rsp), %rax
movq %rax, 0x78(%rsp)
xorl %esi, %esi
movl %esi, %edi
callq 0x91ef0
movq %rax, 0x80(%rsp)
jmp 0xb4385
leaq 0x150(%rsp), %rdi
leaq 0x3d0(%rsp), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x7ab40
jmp 0xb43a3
leaq 0x150(%rsp), %rdi
callq 0x7abe0
movq %rax, 0x70(%rsp)
jmp 0xb43b7
movq 0x70(%rsp), %rdi
callq 0x1a3e0
movq %rax, 0x58(%rsp)
movq 0x9d8(%rsp), %rax
movq %rax, 0x60(%rsp)
movl 0x9fc(%rsp), %eax
movl %eax, 0x68(%rsp)
movl 0xa0c(%rsp), %eax
movl %eax, 0x6c(%rsp)
movq 0xa10(%rsp), %rsi
leaq 0x130(%rsp), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x7ab40
jmp 0xb4407
leaq 0x130(%rsp), %rdi
callq 0x7abe0
movq %rax, 0x50(%rsp)
jmp 0xb441b
movq 0x50(%rsp), %rdi
callq 0x1a3e0
movl 0x6c(%rsp), %esi
movl 0x68(%rsp), %edx
movq 0x78(%rsp), %rdi
movq 0x80(%rsp), %rcx
movq 0x58(%rsp), %r8
movq 0x60(%rsp), %r9
movq %rax, %r10
movq %rsp, %rax
movq %r10, 0x10(%rax)
movl %esi, 0x8(%rax)
movl %edx, (%rax)
leaq 0x388bc(%rip), %rdx     # 0xecd16
xorl %eax, %eax
movl %eax, 0x4c(%rsp)
movl $0x400, %esi            # imm = 0x400
callq 0x5890
leaq 0x130(%rsp), %rdi
callq 0x1a320
leaq 0x150(%rsp), %rdi
callq 0x1a320
movl 0x4c(%rsp), %eax
movl %eax, %esi
leaq 0x5d0(%rsp), %rdi
callq 0x66380
jmp 0xb4499
movq 0xa10(%rsp), %rdi
leaq 0x34cb6(%rip), %rsi     # 0xe915e
callq 0x55c0
movq %rax, 0x40(%rsp)
jmp 0xb44b4
movq 0x40(%rsp), %rax
movq %rax, 0x1b8(%rsp)
cmpq $0x0, 0x1b8(%rsp)
jne 0xb45c6
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0x120(%rsp), %rax
movq %rcx, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movl (%rax), %ecx
movl %ecx, 0x30(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x34(%rsp)
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
callq 0x7c860
movq 0x28(%rsp), %rdi
movl 0x30(%rsp), %edx
movl 0x34(%rsp), %ecx
movq 0x38(%rsp), %r8
movq %rax, %r9
movq 0xa10(%rsp), %rsi
movq %rsp, %rax
movq %rsi, (%rax)
leaq 0x38826(%rip), %rsi     # 0xecd5a
xorl %eax, %eax
callq 0x5c880
jmp 0xb453d
movq 0x20(%rsp), %rdi
leaq 0x4b727(%rip), %rsi     # 0xffc70
leaq -0x57a90(%rip), %rdx    # 0x5cac0
callq 0x5920
jmp 0xb467f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x9f0(%rsp)
movl %eax, 0x9ec(%rsp)
jmp 0xb4591
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x9f0(%rsp)
movl %eax, 0x9ec(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x1a320
leaq 0x150(%rsp), %rdi
callq 0x1a320
jmp 0xb4653
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x9f0(%rsp)
movl %eax, 0x9ec(%rsp)
callq 0x53a0
jmp 0xb4653
movq 0x1b8(%rsp), %rdi
callq 0x5c6f0
jmp 0xb45d5
jmp 0xb45d7
movl $0x0, 0x12c(%rsp)
movq 0x120(%rsp), %rcx
movl 0x12c(%rsp), %eax
cmpl (%rcx), %eax
jge 0xb4634
leaq 0x1c0(%rsp), %rdi
callq 0x7bb10
movq %rax, %rdi
movslq 0x12c(%rsp), %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x1e140
movq %rax, %rdi
callq 0x59c0
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x12c(%rsp)
jmp 0xb45e2
movq 0x120(%rsp), %rax
movq %rax, 0xa20(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0x1a360
jmp 0xb4662
leaq 0x1c0(%rsp), %rdi
callq 0x1a360
jmp 0xb4672
movq 0xa20(%rsp), %rax
addq $0xa28, %rsp            # imm = 0xA28
retq
movq 0x9f0(%rsp), %rdi
callq 0x5970
nop