// File: manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImg<double>::save_medcon_external(char const*) const
const CImg<T>& save_medcon_external(const char *const filename) const {
      if (!filename)
        throw CImgArgumentException(_cimg_instance
                                    "save_medcon_external(): Specified filename is (null).",
                                    cimg_instance);
      if (is_empty()) { cimg::fempty(0,filename); return *this; }

      char command[1024] = { 0 }, filetmp[512] = { 0 }, body[512] = { 0 };
      std::FILE *file;
      do {
        cimg_snprintf(filetmp,sizeof(filetmp),"%s.hdr",cimg::filenamerand());
        if ((file=std::fopen(filetmp,"rb"))!=0) cimg::fclose(file);
      } while (file);
      save_analyze(filetmp);
      cimg_snprintf(command,sizeof(command),"%s -w -c dicom -o \"%s\" -f \"%s\"",
                    cimg::medcon_path(),
                    CImg<charT>::string(filename)._system_strescape().data(),
                    CImg<charT>::string(filetmp)._system_strescape().data());
      cimg::system(command);
      std::remove(filetmp);
      cimg::split_filename(filetmp,body);
      cimg_snprintf(filetmp,sizeof(filetmp),"%s.img",body);
      std::remove(filetmp);

      file = std::fopen(filename,"rb");
      if (!file) {
        cimg_snprintf(command,sizeof(command),"m000-%s",filename);
        file = std::fopen(command,"rb");
        if (!file) {
          cimg::fclose(cimg::fopen(filename,"r"));
          throw CImgIOException(_cimg_instance
                                "save_medcon_external(): Failed to save file '%s' with external command 'medcon'.",
                                cimg_instance,
                                filename);
        }
      }
      cimg::fclose(file);
      std::rename(command,filename);
      return *this;
    }

// Assembly:
pushq %rbx
subq $0x950, %rsp            # imm = 0x950
movq %rdi, 0x940(%rsp)
movq %rsi, 0x938(%rsp)
movq 0x940(%rsp), %rax
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0x938(%rsp)
jne 0x99f03
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0xd0(%rsp), %rax
movq %rcx, 0xa0(%rsp)
movl (%rax), %ecx
movl %ecx, 0xa8(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0xac(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0xb0(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0xb4(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0xb8(%rsp)
movb 0x10(%rax), %dl
leaq 0x4eb91(%rip), %rcx     # 0xe89d2
leaq 0x2fc99(%rip), %rax     # 0xc9ae1
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0xc0(%rsp)
callq 0x118f0
movq %rax, 0xc8(%rsp)
jmp 0x99e66
movl 0xb4(%rsp), %r9d
movl 0xb0(%rsp), %r8d
movl 0xac(%rsp), %ecx
movl 0xa8(%rsp), %edx
movq 0xa0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %r10
movq 0xc8(%rsp), %r11
movq %rsp, %rax
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rsi, (%rax)
leaq 0x526f9(%rip), %rsi     # 0xec5b2
xorl %eax, %eax
callq 0x12220
jmp 0x99ec2
movq 0xa0(%rsp), %rdi
leaq 0x65c8f(%rip), %rsi     # 0xffb60
leaq -0x87a78(%rip), %rdx    # 0x12460
callq 0x5920
movq 0xa0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x930(%rsp)
movl %eax, 0x92c(%rsp)
callq 0x53a0
jmp 0x9a36b
movq 0xd0(%rsp), %rdi
callq 0x10320
testb $0x1, %al
jne 0x99f16
jmp 0x99f3c
movq 0x938(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x9c310
movq 0xd0(%rsp), %rax
movq %rax, 0x948(%rsp)
jmp 0x9a35a
leaq 0x520(%rsp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x52a0
leaq 0x320(%rsp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x52a0
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x52a0
leaq 0x320(%rsp), %rax
movq %rax, 0x98(%rsp)
callq 0x5c7a0
movq 0x98(%rsp), %rdi
movq %rax, %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x50175(%rip), %rdx     # 0xea119
movb $0x0, %al
callq 0x5890
leaq 0x320(%rsp), %rdi
leaq 0x4f1a4(%rip), %rsi     # 0xe915e
callq 0x55c0
movq %rax, 0x118(%rsp)
cmpq $0x0, %rax
je 0x99fda
movq 0x118(%rsp), %rdi
callq 0x5c6f0
jmp 0x99fdc
cmpq $0x0, 0x118(%rsp)
jne 0x99f78
movq 0xd0(%rsp), %rdi
xorl %eax, %eax
movl %eax, 0x7c(%rsp)
movl %eax, %edx
movq %rdx, 0x68(%rsp)
leaq 0x320(%rsp), %rsi
callq 0x9a380
movq 0x68(%rsp), %rdi
movl 0x7c(%rsp), %esi
leaq 0x520(%rsp), %rax
movq %rax, 0x70(%rsp)
callq 0x5c120
movl 0x7c(%rsp), %ecx
movq %rax, 0x80(%rsp)
movq 0x938(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
movq %rdi, 0x88(%rsp)
movl $0x1, %edx
callq 0x7ab40
movq 0x88(%rsp), %rdi
callq 0x7abe0
movq %rax, 0x90(%rsp)
jmp 0x9a069
movq 0x90(%rsp), %rdi
callq 0x1a3e0
movq %rax, 0x60(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0x320(%rsp), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x7ab40
jmp 0x9a099
leaq 0xd8(%rsp), %rdi
callq 0x7abe0
movq %rax, 0x58(%rsp)
jmp 0x9a0ad
movq 0x58(%rsp), %rdi
callq 0x1a3e0
movq 0x70(%rsp), %rdi
movq 0x80(%rsp), %rcx
movq 0x60(%rsp), %r8
movq %rax, %r9
movl $0x400, %esi            # imm = 0x400
leaq 0x5253e(%rip), %rdx     # 0xec616
movb $0x0, %al
callq 0x5890
leaq 0xd8(%rsp), %rdi
callq 0x1a320
leaq 0xf8(%rsp), %rdi
callq 0x1a320
leaq 0x520(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x66380
leaq 0x320(%rsp), %rdi
callq 0x59c0
leaq 0x320(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x63280
leaq 0x320(%rsp), %rdi
leaq 0x120(%rsp), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x50057(%rip), %rdx     # 0xea19f
movb $0x0, %al
callq 0x5890
leaq 0x320(%rsp), %rdi
callq 0x59c0
movq 0x938(%rsp), %rdi
leaq 0x4eff3(%rip), %rsi     # 0xe915e
callq 0x55c0
movq %rax, 0x118(%rsp)
cmpq $0x0, 0x118(%rsp)
jne 0x9a328
leaq 0x520(%rsp), %rdi
movq 0x938(%rsp), %rcx
movl $0x400, %esi            # imm = 0x400
leaq 0x52492(%rip), %rdx     # 0xec635
movb $0x0, %al
callq 0x5890
leaq 0x520(%rsp), %rdi
leaq 0x4efa5(%rip), %rsi     # 0xe915e
callq 0x55c0
movq %rax, 0x118(%rsp)
cmpq $0x0, 0x118(%rsp)
jne 0x9a326
movq 0x938(%rsp), %rdi
leaq 0x3a4ce(%rip), %rsi     # 0xd46b2
callq 0x654a0
movq %rax, %rdi
callq 0x5c6f0
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0xd0(%rsp), %rax
movq %rcx, 0x28(%rsp)
movl (%rax), %ecx
movl %ecx, 0x30(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x34(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x38(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0x3c(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x40(%rsp)
movb 0x10(%rax), %dl
leaq 0x4e799(%rip), %rcx     # 0xe89d2
leaq 0x2f8a1(%rip), %rax     # 0xc9ae1
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x48(%rsp)
callq 0x118f0
movq %rax, 0x50(%rsp)
jmp 0x9a258
movl 0x3c(%rsp), %r9d
movl 0x38(%rsp), %r8d
movl 0x34(%rsp), %ecx
movl 0x30(%rsp), %edx
movq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %r10
movq 0x50(%rsp), %r11
movq 0x938(%rsp), %rbx
movq %rsp, %rax
movq %rbx, 0x18(%rax)
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rsi, (%rax)
leaq 0x5239e(%rip), %rsi     # 0xec63d
xorl %eax, %eax
callq 0x5c880
jmp 0x9a2a8
movq 0x28(%rsp), %rdi
leaq 0x659bc(%rip), %rsi     # 0xffc70
leaq -0x3d7fb(%rip), %rdx    # 0x5cac0
callq 0x5920
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x930(%rsp)
movl %eax, 0x92c(%rsp)
jmp 0x9a2f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x930(%rsp)
movl %eax, 0x92c(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x1a320
leaq 0xf8(%rsp), %rdi
callq 0x1a320
jmp 0x9a36b
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x930(%rsp)
movl %eax, 0x92c(%rsp)
callq 0x53a0
jmp 0x9a36b
jmp 0x9a328
movq 0x118(%rsp), %rdi
callq 0x5c6f0
leaq 0x520(%rsp), %rdi
movq 0x938(%rsp), %rsi
callq 0x52f0
movq 0xd0(%rsp), %rax
movq %rax, 0x948(%rsp)
movq 0x948(%rsp), %rax
addq $0x950, %rsp            # imm = 0x950
popq %rbx
retq
movq 0x930(%rsp), %rdi
callq 0x5970
nopl (%rax,%rax)