// File: kallaballa[P]PixelStencil/./CImg.h
// Function: cimg_library::cimg::file_type(_IO_FILE*, char const*)
inline const char *file_type(std::FILE *const file, const char *const filename) {
      if (!file && !filename)
        throw CImgArgumentException("cimg::file_type(): Specified filename is (null).");
      static const char
        *const _pnm = "pnm",
        *const _pfm = "pfm",
        *const _bmp = "bmp",
        *const _gif = "gif",
        *const _jpg = "jpg",
        *const _off = "off",
        *const _pan = "pan",
        *const _png = "png",
        *const _tif = "tif",
        *const _inr = "inr",
        *const _dcm = "dcm";
      std::FILE *const nfile = file?file:cimg::fopen(filename,"rb");
      const char *f_type = 0, *head;
      char header[2048] = { 0 }, item[1024] = { 0 };
      const unsigned char *const uheader = (unsigned char*)header;
      int err; char cerr;
      const unsigned int siz = (unsigned int)std::fread(header,2048,1,nfile);   // Read first 2048 bytes.
      if (!file) cimg::fclose(nfile);

      if (!std::strncmp(header,"OFF\n",4)) f_type = _off; // Check for OFF format.
      else if (!std::strncmp(header,"#INRIMAGE",9)) f_type = _inr; // Check for INRIMAGE format.
      else if (!std::strncmp(header,"PANDORE",7)) f_type = _pan; // Check for PANDORE format.
      else if (!std::strncmp(header+128,"DICM",4)) f_type = _dcm; // Check for DICOM format.
      else if (uheader[0]==0xFF && uheader[1]==0xD8 && uheader[2]==0xFF) f_type = _jpg;  // Check for JPEG format.
      else if (header[0]=='B' && header[1]=='M') f_type = _bmp;  // Check for BMP format.
      else if (header[0]=='G' && header[1]=='I' && header[2]=='F' && header[3]=='8' && header[5]=='a' && // Check for GIF format.
               (header[4]=='7' || header[4]=='9')) f_type = _gif;
      else if (uheader[0]==0x89 && uheader[1]==0x50 && uheader[2]==0x4E && uheader[3]==0x47 &&  // Check for PNG format.
               uheader[4]==0x0D && uheader[5]==0x0A && uheader[6]==0x1A && uheader[7]==0x0A) f_type = _png;
      else if ((uheader[0]==0x49 && uheader[1]==0x49) || (uheader[0]==0x4D && uheader[1]==0x4D)) f_type = _tif; // Check for TIFF format.
      else { // Check for PNM or PFM format.
        head = header;
        while (head<header+siz && (err=std::sscanf(head,"%1023[^\n]",item))!=EOF && (*item=='#' || !err))
          head+=1+(err?std::strlen(item):0);
        if (std::sscanf(item," P%d",&err)==1) f_type = _pnm;
        else if (std::sscanf(item," P%c",&cerr)==1 && (cerr=='f' || cerr=='F')) f_type = _pfm;
      }
      return f_type;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc80, %rsp            # imm = 0xC80
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0xb76f
cmpq $0x0, -0x10(%rbp)
jne 0xb76f
movl $0x4008, %edi           # imm = 0x4008
callq 0x4190
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc60(%rbp)
leaq 0x39898(%rip), %rsi     # 0x44fc7
xorl %eax, %eax
callq 0x8cd0
jmp 0xb738
movq -0xc60(%rbp), %rdi
leaq 0x444a2(%rip), %rsi     # 0x4fbe8
leaq -0x290d(%rip), %rdx     # 0x8e40
callq 0x4600
movq -0xc60(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x4270
jmp 0xbbec
cmpq $0x0, -0x8(%rbp)
je 0xb783
movq -0x8(%rbp), %rax
movq %rax, -0xc68(%rbp)
jmp 0xb79a
movq -0x10(%rbp), %rdi
leaq 0x36e94(%rip), %rsi     # 0x42622
callq 0xb540
movq %rax, -0xc68(%rbp)
movq -0xc68(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x840(%rbp), %rdi
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x41c0
leaq -0xc40(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x41c0
leaq -0x840(%rbp), %rax
movq %rax, -0xc48(%rbp)
leaq -0x840(%rbp), %rdi
movq -0x28(%rbp), %rcx
movl $0x800, %esi            # imm = 0x800
movl $0x1, %edx
callq 0x4540
movl %eax, -0xc54(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0xb811
movq -0x28(%rbp), %rdi
callq 0xd0a0
leaq -0x840(%rbp), %rdi
leaq 0x397dd(%rip), %rsi     # 0x44ffc
movl $0x4, %edx
callq 0x4180
cmpl $0x0, %eax
jne 0xb83e
leaq 0x397c3(%rip), %rax     # 0x44ff8
movq %rax, -0x30(%rbp)
jmp 0xbbdf
leaq -0x840(%rbp), %rdi
leaq 0x397b5(%rip), %rsi     # 0x45001
movl $0x9, %edx
callq 0x4180
cmpl $0x0, %eax
jne 0xb86b
leaq 0x36d4a(%rip), %rax     # 0x425ac
movq %rax, -0x30(%rbp)
jmp 0xbbdd
leaq -0x840(%rbp), %rdi
leaq 0x39072(%rip), %rsi     # 0x448eb
movl $0x7, %edx
callq 0x4180
cmpl $0x0, %eax
jne 0xb898
leaq 0x36d21(%rip), %rax     # 0x425b0
movq %rax, -0x30(%rbp)
jmp 0xbbdb
leaq -0x840(%rbp), %rdi
addq $0x80, %rdi
leaq 0x3975e(%rip), %rsi     # 0x4500b
movl $0x4, %edx
callq 0x4180
cmpl $0x0, %eax
jne 0xb8cc
leaq 0x36cd7(%rip), %rax     # 0x4259a
movq %rax, -0x30(%rbp)
jmp 0xbbd9
movq -0xc48(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xff, %eax
jne 0xb911
movq -0xc48(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xd8, %eax
jne 0xb911
movq -0xc48(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0xff, %eax
jne 0xb911
leaq 0x36c33(%rip), %rax     # 0x4253b
movq %rax, -0x30(%rbp)
jmp 0xbbd7
movsbl -0x840(%rbp), %eax
cmpl $0x42, %eax
jne 0xb939
movsbl -0x83f(%rbp), %eax
cmpl $0x4d, %eax
jne 0xb939
leaq 0x36c07(%rip), %rax     # 0x42537
movq %rax, -0x30(%rbp)
jmp 0xbbd5
movsbl -0x840(%rbp), %eax
cmpl $0x47, %eax
jne 0xb99d
movsbl -0x83f(%rbp), %eax
cmpl $0x49, %eax
jne 0xb99d
movsbl -0x83e(%rbp), %eax
cmpl $0x46, %eax
jne 0xb99d
movsbl -0x83d(%rbp), %eax
cmpl $0x38, %eax
jne 0xb99d
movsbl -0x83b(%rbp), %eax
cmpl $0x61, %eax
jne 0xb99d
movsbl -0x83c(%rbp), %eax
cmpl $0x37, %eax
je 0xb98d
movsbl -0x83c(%rbp), %eax
cmpl $0x39, %eax
jne 0xb99d
leaq 0x36c02(%rip), %rax     # 0x42596
movq %rax, -0x30(%rbp)
jmp 0xbbd3
movq -0xc48(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x89, %eax
jne 0xba32
movq -0xc48(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x50, %eax
jne 0xba32
movq -0xc48(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x4e, %eax
jne 0xba32
movq -0xc48(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x47, %eax
jne 0xba32
movq -0xc48(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0xd, %eax
jne 0xba32
movq -0xc48(%rbp), %rax
movzbl 0x5(%rax), %eax
cmpl $0xa, %eax
jne 0xba32
movq -0xc48(%rbp), %rax
movzbl 0x6(%rax), %eax
cmpl $0x1a, %eax
jne 0xba32
movq -0xc48(%rbp), %rax
movzbl 0x7(%rax), %eax
cmpl $0xa, %eax
jne 0xba32
leaq 0x38575(%rip), %rax     # 0x43f9e
movq %rax, -0x30(%rbp)
jmp 0xbbd1
movq -0xc48(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x49, %eax
jne 0xba51
movq -0xc48(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x49, %eax
je 0xba70
movq -0xc48(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x4d, %eax
jne 0xba80
movq -0xc48(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x4d, %eax
jne 0xba80
leaq 0x36aea(%rip), %rax     # 0x42561
movq %rax, -0x30(%rbp)
jmp 0xbbcf
leaq -0x840(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
leaq -0x840(%rbp), %rdx
movl -0xc54(%rbp), %eax
addq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0xc69(%rbp)
jae 0xbb0c
movq -0x38(%rbp), %rdi
leaq -0xc40(%rbp), %rdx
leaq 0x37e5d(%rip), %rsi     # 0x4391b
movb $0x0, %al
callq 0x4340
movl %eax, %ecx
movl %ecx, -0xc4c(%rbp)
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0xc69(%rbp)
je 0xbb0c
movsbl -0xc40(%rbp), %ecx
movb $0x1, %al
cmpl $0x23, %ecx
movb %al, -0xc6a(%rbp)
je 0xbb00
cmpl $0x0, -0xc4c(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0xc6a(%rbp)
movb -0xc6a(%rbp), %al
movb %al, -0xc69(%rbp)
movb -0xc69(%rbp), %al
testb $0x1, %al
jne 0xbb18
jmp 0xbb59
cmpl $0x0, -0xc4c(%rbp)
je 0xbb36
leaq -0xc40(%rbp), %rdi
callq 0x4160
movq %rax, -0xc78(%rbp)
jmp 0xbb41
xorl %eax, %eax
movq %rax, -0xc78(%rbp)
jmp 0xbb41
movq -0xc78(%rbp), %rax
addq $0x1, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xba8b
leaq -0xc40(%rbp), %rdi
leaq 0x394a9(%rip), %rsi     # 0x45010
leaq -0xc4c(%rbp), %rdx
movb $0x0, %al
callq 0x4340
cmpl $0x1, %eax
jne 0xbb87
leaq 0x3977c(%rip), %rax     # 0x452fd
movq %rax, -0x30(%rbp)
jmp 0xbbcd
leaq -0xc40(%rbp), %rdi
leaq 0x37f46(%rip), %rsi     # 0x43adb
leaq -0xc4d(%rbp), %rdx
movb $0x0, %al
callq 0x4340
cmpl $0x1, %eax
jne 0xbbcb
movsbl -0xc4d(%rbp), %eax
cmpl $0x66, %eax
je 0xbbc0
movsbl -0xc4d(%rbp), %eax
cmpl $0x46, %eax
jne 0xbbcb
leaq 0x36996(%rip), %rax     # 0x4255d
movq %rax, -0x30(%rbp)
jmp 0xbbcd
jmp 0xbbcf
jmp 0xbbd1
jmp 0xbbd3
jmp 0xbbd5
jmp 0xbbd7
jmp 0xbbd9
jmp 0xbbdb
jmp 0xbbdd
jmp 0xbbdf
movq -0x30(%rbp), %rax
addq $0xc80, %rsp            # imm = 0xC80
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x4620
nopw %cs:(%rax,%rax)
nop