// File: /workspace/github_cpp_makefile_star2_O2/manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImg<double>::_load_analyze(_IO_FILE*, char const*, float*)
CImg<T>& _load_analyze(std::FILE *const file, const char *const filename, float *const voxel_size=0) {
      if (!file && !filename)
        throw CImgArgumentException(_cimg_instance
                                    "load_analyze(): Specified filename is (null).",
                                    cimg_instance);

      std::FILE *nfile_header = 0, *nfile = 0;
      if (!file) {
        char body[1024] = { 0 };
        const char *const ext = cimg::split_filename(filename,body);
        if (!cimg::strcasecmp(ext,"hdr")) { // File is an Analyze header file.
          nfile_header = cimg::fopen(filename,"rb");
          std::sprintf(body + std::strlen(body),".img");
          nfile = cimg::fopen(body,"rb");
        } else if (!cimg::strcasecmp(ext,"img")) { // File is an Analyze data file.
          nfile = cimg::fopen(filename,"rb");
          std::sprintf(body + std::strlen(body),".hdr");
          nfile_header = cimg::fopen(body,"rb");
        } else nfile_header = nfile = cimg::fopen(filename,"rb"); // File is a Niftii file.
      } else nfile_header = nfile = file; // File is a Niftii file.
      if (!nfile || !nfile_header)
        throw CImgIOException(_cimg_instance
                              "load_analyze(): Invalid Analyze7.5 or NIFTI header in file '%s'.",
                              cimg_instance,
                              filename?filename:"(FILE*)");

      // Read header.
      bool endian = false;
      unsigned int header_size;
      cimg::fread(&header_size,1,nfile_header);
      if (!header_size)
        throw CImgIOException(_cimg_instance
                              "load_analyze(): Invalid zero-sized header in file '%s'.",
                              cimg_instance,
                              filename?filename:"(FILE*)");

      if (header_size>=4096) { endian = true; cimg::invert_endianness(header_size); }
      unsigned char *const header = new unsigned char[header_size];
      cimg::fread(header+4,header_size-4,nfile_header);
      if (!file && nfile_header!=nfile) cimg::fclose(nfile_header);
      if (endian) {
        cimg::invert_endianness((short*)(header+40),5);
        cimg::invert_endianness((short*)(header+70),1);
        cimg::invert_endianness((short*)(header+72),1);
        cimg::invert_endianness((float*)(header+76),4);
        cimg::invert_endianness((float*)(header+112),1);
      }
      unsigned short *dim = (unsigned short*)(header+40), dimx = 1, dimy = 1, dimz = 1, dimv = 1;
      if (!dim[0])
        cimg::warn(_cimg_instance
                   "load_analyze(): File '%s' defines an image with zero dimensions.",
                   cimg_instance,
                   filename?filename:"(FILE*)");

      if (dim[0]>4)
        cimg::warn(_cimg_instance
                   "load_analyze(): File '%s' defines an image with %u dimensions, reading only the 4 first.",
                   cimg_instance,
                   filename?filename:"(FILE*)",dim[0]);

      if (dim[0]>=1) dimx = dim[1];
      if (dim[0]>=2) dimy = dim[2];
      if (dim[0]>=3) dimz = dim[3];
      if (dim[0]>=4) dimv = dim[4];
      float scalefactor = *(float*)(header+112); if (scalefactor==0) scalefactor=1;
      const unsigned short datatype = *(short*)(header+70);
      if (voxel_size) {
        const float *vsize = (float*)(header+76);
        voxel_size[0] = vsize[1]; voxel_size[1] = vsize[2]; voxel_size[2] = vsize[3];
      }
      delete[] header;

      // Read pixel data.
      assign(dimx,dimy,dimz,dimv);
      switch (datatype) {
      case 2 : {
        unsigned char *const buffer = new unsigned char[dimx*dimy*dimz*dimv];
        cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
        cimg_foroff(*this,off) _data[off] = (T)(buffer[off]*scalefactor);
        delete[] buffer;
      } break;
      case 4 : {
        short *const buffer = new short[dimx*dimy*dimz*dimv];
        cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
        if (endian) cimg::invert_endianness(buffer,dimx*dimy*dimz*dimv);
        cimg_foroff(*this,off) _data[off] = (T)(buffer[off]*scalefactor);
        delete[] buffer;
      } break;
      case 8 : {
        int *const buffer = new int[dimx*dimy*dimz*dimv];
        cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
        if (endian) cimg::invert_endianness(buffer,dimx*dimy*dimz*dimv);
        cimg_foroff(*this,off) _data[off] = (T)(buffer[off]*scalefactor);
        delete[] buffer;
      } break;
      case 16 : {
        float *const buffer = new float[dimx*dimy*dimz*dimv];
        cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
        if (endian) cimg::invert_endianness(buffer,dimx*dimy*dimz*dimv);
        cimg_foroff(*this,off) _data[off] = (T)(buffer[off]*scalefactor);
        delete[] buffer;
      } break;
      case 64 : {
        double *const buffer = new double[dimx*dimy*dimz*dimv];
        cimg::fread(buffer,dimx*dimy*dimz*dimv,nfile);
        if (endian) cimg::invert_endianness(buffer,dimx*dimy*dimz*dimv);
        cimg_foroff(*this,off) _data[off] = (T)(buffer[off]*scalefactor);
        delete[] buffer;
      } break;
      default :
        if (!file) cimg::fclose(nfile);
        throw CImgIOException(_cimg_instance
                              "load_analyze(): Unable to load datatype %d in file '%s'",
                              cimg_instance,
                              datatype,filename?filename:"(FILE*)");
      }
      if (!file) cimg::fclose(nfile);
      return *this;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
movq %rcx, 0x20(%rsp)
movq %rdi, %r13
movq %rsi, %rax
orq %rdx, %rax
je 0x3a177
movq %rdx, %rbp
movq %rsi, %r12
movq %rsi, %rbx
movq %rsi, %r15
testq %rsi, %rsi
movq %rdx, 0x18(%rsp)
jne 0x39c32
leaq 0x40(%rsp), %r14
movl $0x400, %edx            # imm = 0x400
movq %r14, %rdi
xorl %esi, %esi
callq 0x4280
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2cc28
movq %rax, %r14
leaq 0x3c673(%rip), %rsi     # 0x761f7
movq %rax, %rdi
callq 0x2ccbe
testl %eax, %eax
je 0x39bbc
leaq 0x3c6e6(%rip), %rsi     # 0x7627d
movq %r14, %rdi
callq 0x2ccbe
movq %rbp, %rdi
movl %eax, %ebp
leaq 0x3b690(%rip), %rsi     # 0x7523b
callq 0x2dca5
movq %rax, %rbx
testl %ebp, %ebp
je 0x39c01
movq %rbx, %r15
jmp 0x39c2d
leaq 0x3b678(%rip), %r14     # 0x7523b
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2dca5
movq %rax, %r15
movq %r12, %rbx
leaq 0x40(%rsp), %r12
movq %r12, %rdi
callq 0x41e0
movl $0x676d692e, 0x40(%rsp,%rax) # imm = 0x676D692E
movb $0x0, 0x44(%rsp,%rax)
movq %r12, %rdi
movq %rbx, %r12
movq %r14, %rsi
callq 0x2dca5
movq %rax, %rbx
jmp 0x39c32
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x41e0
movl $0x7264682e, 0x40(%rsp,%rax) # imm = 0x7264682E
movb $0x0, 0x44(%rsp,%rax)
leaq 0x3b619(%rip), %rsi     # 0x7523b
movq %r14, %rdi
callq 0x2dca5
movq %rax, %r15
movq 0x18(%rsp), %rbp
testq %rbx, %rbx
je 0x3a1df
testq %r15, %r15
je 0x3a1df
leaq 0x40(%rsp), %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x3a371
movl (%r14), %eax
testl %eax, %eax
je 0x3a248
movq %rbx, 0x30(%rsp)
movl %eax, %r14d
movl %eax, 0xc(%rsp)
cmpl $0x1000, %eax           # imm = 0x1000
jb 0x39c85
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x3a477
movl (%r14), %r14d
movl %r14d, %edi
callq 0x4040
movq %rax, %rbp
leaq 0x4(%rax), %rdi
addl $-0x4, %r14d
movq %r14, %rsi
movq %r15, %rdx
callq 0x36072
testq %r12, %r12
jne 0x39cb7
cmpq 0x30(%rsp), %r15
je 0x39cb7
movq %r15, %rdi
callq 0x2a2f8
cmpl $0x1000, 0xc(%rsp)      # imm = 0x1000
jb 0x39d04
leaq 0x28(%rbp), %rdi
pushq $0x5
popq %rsi
callq 0x3a488
leaq 0x46(%rbp), %rdi
pushq $0x1
popq %r14
movq %r14, %rsi
callq 0x3a488
leaq 0x48(%rbp), %rdi
movq %r14, %rsi
callq 0x3a488
leaq 0x4c(%rbp), %rdi
pushq $0x4
popq %rsi
callq 0x38732
movq %rbp, %rdi
addq $0x70, %rdi
movq %r14, %rsi
callq 0x38732
movzwl 0x28(%rbp), %edi
testw %di, %di
jne 0x39d71
leaq 0x1aad4(%rip), %rax     # 0x547e8
cmpb $0x0, 0x10(%r13)
leaq 0x1bea2(%rip), %r10     # 0x55bc2
cmovneq %rax, %r10
movq 0x18(%rsp), %rax
testq %rax, %rax
movl (%r13), %esi
movl 0x4(%r13), %edx
movl 0x8(%r13), %ecx
movl 0xc(%r13), %r8d
movq 0x18(%r13), %r9
leaq 0x3b820(%rip), %r11     # 0x75567
cmovneq %rax, %r11
subq $0x8, %rsp
leaq 0x3b349(%rip), %rbx     # 0x7509f
leaq 0x3c655(%rip), %rdi     # 0x763b2
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
callq 0x97a7
addq $0x20, %rsp
movzwl 0x28(%rbp), %edi
cmpw $0x5, %di
movq %r13, 0x10(%rsp)
jb 0x39de1
leaq 0x1aa65(%rip), %rax     # 0x547e8
leaq 0x1be38(%rip), %r10     # 0x55bc2
cmpb $0x0, 0x10(%r13)
cmovneq %rax, %r10
movq 0x18(%rsp), %rax
testq %rax, %rax
movl (%r13), %esi
movl 0x4(%r13), %edx
movl 0x8(%r13), %ecx
movl 0xc(%r13), %r8d
movq 0x18(%r13), %r9
leaq 0x3b7b1(%rip), %r11     # 0x75567
cmovneq %rax, %r11
movzwl %di, %ebx
leaq 0x3b2db(%rip), %r14     # 0x7509f
leaq 0x3c656(%rip), %rdi     # 0x76421
xorl %eax, %eax
pushq %rbx
pushq %r11
pushq %r14
pushq %r10
callq 0x97a7
addq $0x20, %rsp
movzwl 0x28(%rbp), %edi
pushq $0x1
popq %r13
movw $0x1, %ax
testw %di, %di
movq %r12, 0x38(%rsp)
je 0x39e19
movzwl 0x2a(%rbp), %ecx
cmpw $0x1, %di
je 0x39e1d
movzwl 0x2c(%rbp), %edx
cmpw $0x3, %di
jb 0x39e21
movzwl 0x2e(%rbp), %eax
movq 0x20(%rsp), %rsi
je 0x39e26
movzwl 0x30(%rbp), %r13d
jmp 0x39e26
movw $0x1, %cx
movw $0x1, %dx
movq 0x20(%rsp), %rsi
movzwl %dx, %r15d
movzwl %cx, %r12d
movzwl %ax, %r14d
movss 0x70(%rbp), %xmm0
xorps %xmm2, %xmm2
cmpeqss %xmm0, %xmm2
movss 0x1a3d9(%rip), %xmm1    # 0x54220
andps %xmm2, %xmm1
andnps %xmm0, %xmm2
orps %xmm1, %xmm2
movaps %xmm2, 0x20(%rsp)
movzwl 0x46(%rbp), %ebx
testq %rsi, %rsi
je 0x39e71
movsd 0x50(%rbp), %xmm0
movsd %xmm0, (%rsi)
movss 0x58(%rbp), %xmm0
movss %xmm0, 0x8(%rsi)
movq %rbp, %rdi
callq 0x4670
movq 0x10(%rsp), %rdi
movl %r12d, %esi
movl %r15d, %edx
movl %r14d, %ecx
movl %r13d, %r8d
callq 0x988e
cmpl $0x40, %ebx
je 0x39fb7
cmpl $0x4, %ebx
movq 0x30(%rsp), %rbp
je 0x39f31
cmpl $0x8, %ebx
je 0x3a040
cmpl $0x10, %ebx
je 0x3a0c7
cmpl $0x2, %ebx
jne 0x3a2c5
imull %r14d, %r12d
imull %r13d, %r15d
imull %r12d, %r15d
movq %r15, %rdi
callq 0x4040
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x36072
movq 0x10(%rsp), %rbx
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
imulq %rax, %rcx
movl 0x8(%rbx), %edx
movl 0xc(%rbx), %eax
imulq %rdx, %rax
imulq %rcx, %rax
movq 0x18(%rbx), %rcx
xorl %edx, %edx
movaps 0x20(%rsp), %xmm1
cmpq %rdx, %rax
je 0x3a14a
movzbl (%r12,%rdx), %esi
cvtsi2ss %esi, %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
jmp 0x39f0d
imull %r14d, %r12d
imull %r13d, %r15d
imull %r12d, %r15d
leaq (%r15,%r15), %rdi
callq 0x4040
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x3a4a2
cmpl $0x1000, 0xc(%rsp)      # imm = 0x1000
jb 0x39f6c
movq %r12, %rdi
movq %r15, %rsi
callq 0x3a488
movq 0x10(%rsp), %rbx
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
imulq %rax, %rcx
movl 0x8(%rbx), %edx
movl 0xc(%rbx), %eax
imulq %rdx, %rax
imulq %rcx, %rax
movq 0x18(%rbx), %rcx
xorl %edx, %edx
movaps 0x20(%rsp), %xmm1
cmpq %rdx, %rax
je 0x3a14a
movswl (%r12,%rdx,2), %esi
cvtsi2ss %esi, %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
jmp 0x39f93
imull %r14d, %r12d
imull %r13d, %r15d
imull %r12d, %r15d
leaq (,%r15,8), %rdi
callq 0x4040
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
movq 0x30(%rsp), %rbp
movq %rbp, %rdx
callq 0x3a5c1
cmpl $0x1000, 0xc(%rsp)      # imm = 0x1000
jb 0x39ffb
movq %r12, %rdi
movq %r15, %rsi
callq 0x3a6c7
movq 0x10(%rsp), %rbx
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
imulq %rax, %rcx
movl 0x8(%rbx), %edx
movl 0xc(%rbx), %eax
imulq %rdx, %rax
imulq %rcx, %rax
cvtss2sd 0x20(%rsp), %xmm0
movq 0x18(%rbx), %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x3a14a
movsd (%r12,%rdx,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
jmp 0x3a023
imull %r14d, %r12d
imull %r13d, %r15d
imull %r12d, %r15d
leaq (,%r15,4), %rdi
callq 0x4040
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x363e1
cmpl $0x1000, 0xc(%rsp)      # imm = 0x1000
jb 0x3a07f
movq %r12, %rdi
movq %r15, %rsi
callq 0x3a5a4
movq 0x10(%rsp), %rbx
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
imulq %rax, %rcx
movl 0x8(%rbx), %edx
movl 0xc(%rbx), %eax
imulq %rdx, %rax
imulq %rcx, %rax
movq 0x18(%rbx), %rcx
xorl %edx, %edx
movaps 0x20(%rsp), %xmm1
cmpq %rdx, %rax
je 0x3a14a
cvtsi2ssl (%r12,%rdx,4), %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
jmp 0x3a0a6
imull %r14d, %r12d
imull %r13d, %r15d
imull %r12d, %r15d
leaq (,%r15,4), %rdi
callq 0x4040
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x38089
cmpl $0x1000, 0xc(%rsp)      # imm = 0x1000
jb 0x3a106
movq %r12, %rdi
movq %r15, %rsi
callq 0x38732
movq 0x10(%rsp), %rbx
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
imulq %rax, %rcx
movl 0x8(%rbx), %edx
movl 0xc(%rbx), %eax
imulq %rdx, %rax
imulq %rcx, %rax
movq 0x18(%rbx), %rcx
xorl %edx, %edx
movaps 0x20(%rsp), %xmm1
cmpq %rdx, %rax
je 0x3a14a
movss (%r12,%rdx,4), %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
jmp 0x3a12d
movq %r12, %rdi
callq 0x4670
cmpq $0x0, 0x38(%rsp)
jne 0x3a162
movq %rbp, %rdi
callq 0x2a2f8
movq %rbx, %rax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
movl (%r13), %edx
movl 0x4(%r13), %ecx
movl 0x8(%r13), %r8d
movl 0xc(%r13), %r9d
leaq 0x1a64d(%rip), %rax     # 0x547e8
leaq 0x1ba20(%rip), %r10     # 0x55bc2
cmpb $0x0, 0x10(%r13)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x3aee9(%rip), %r11     # 0x7509f
leaq 0x3c0c4(%rip), %rsi     # 0x76281
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%r13)
callq 0x9d52
addq $0x20, %rsp
leaq 0x55a86(%rip), %rsi     # 0x8fc60
jmp 0x3a2b6
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
leaq 0x1a5f5(%rip), %rax     # 0x547e8
leaq 0x1b9c8(%rip), %r10     # 0x55bc2
cmpb $0x0, 0x10(%r13)
cmovneq %rax, %r10
testq %rbp, %rbp
movl (%r13), %edx
movl 0x4(%r13), %ecx
movl 0x8(%r13), %r8d
movl 0xc(%r13), %r9d
leaq 0x3b34a(%rip), %r11     # 0x75567
cmovneq %rbp, %r11
leaq 0x3ae77(%rip), %rbx     # 0x7509f
leaq 0x3c0ae(%rip), %rsi     # 0x762dd
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
pushq 0x18(%r13)
callq 0x2a3de
addq $0x20, %rsp
jmp 0x3a2af
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
leaq 0x1a58c(%rip), %rax     # 0x547e8
leaq 0x1b95f(%rip), %r10     # 0x55bc2
cmpb $0x0, 0x10(%r13)
cmovneq %rax, %r10
testq %rbp, %rbp
movl (%r13), %edx
movl 0x4(%r13), %ecx
movl 0x8(%r13), %r8d
movl 0xc(%r13), %r9d
leaq 0x3b2e1(%rip), %r11     # 0x75567
cmovneq %rbp, %r11
leaq 0x3ae0e(%rip), %rbx     # 0x7509f
leaq 0x3c0b4(%rip), %rsi     # 0x7634c
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
pushq 0x18(%r13)
callq 0x2a3de
addq $0x20, %rsp
leaq 0x55a4a(%rip), %rsi     # 0x8fd00
movq 0x55d1b(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
cmpq $0x0, 0x38(%rsp)
jne 0x3a2d7
movq 0x30(%rsp), %rdi
callq 0x2a2f8
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
leaq 0x1a4fd(%rip), %rax     # 0x547e8
leaq 0x1b8d0(%rip), %r10     # 0x55bc2
movq 0x10(%rsp), %r12
cmpb $0x0, 0x10(%r12)
cmovneq %rax, %r10
movq 0x18(%rsp), %rax
testq %rax, %rax
movl (%r12), %edx
movl 0x4(%r12), %ecx
movl 0x8(%r12), %r8d
movl 0xc(%r12), %r9d
leaq 0x3b244(%rip), %r11     # 0x75567
cmovneq %rax, %r11
subq $0x8, %rsp
leaq 0x3ad6d(%rip), %r15     # 0x7509f
leaq 0x3c16f(%rip), %rsi     # 0x764a8
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r15
pushq %r10
pushq 0x18(%r12)
callq 0x2a3de
addq $0x30, %rsp
jmp 0x3a2af
jmp 0x3a35e
jmp 0x3a35e
jmp 0x3a35e
movq %rax, %rbx
movq %r14, %rdi
callq 0x4390
movq %rbx, %rdi
callq 0x4950