// File: /workspace/github_cpp_makefile_star2_O2/manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImgDisplay::_assign(unsigned int, unsigned int, char const*, unsigned int, bool, bool)
void _assign(const unsigned int dimw, const unsigned int dimh, const char *const ptitle=0,
                 const unsigned int normalization_type=3,
                 const bool fullscreen_flag=false, const bool closed_flag=false) {
      cimg::mutex(14);

      // Allocate space for window title
      const char *const nptitle = ptitle?ptitle:"";
      const unsigned int s = std::strlen(nptitle) + 1;
      char *const tmp_title = s?new char[s]:0;
      if (s) std::memcpy(tmp_title,nptitle,s*sizeof(char));

      // Destroy previous display window if existing
      if (!is_empty()) assign();

      // Open X11 display and retrieve graphical properties.
      Display* &dpy = cimg::X11_attr().display;
      if (!dpy) {
        dpy = XOpenDisplay(0);
        if (!dpy)
          throw CImgDisplayException(_cimgdisplay_instance
                                     "assign(): Failed to open X11 display.",
                                     cimgdisplay_instance);

        cimg::X11_attr().nb_bits = DefaultDepth(dpy,DefaultScreen(dpy));
        if (cimg::X11_attr().nb_bits!=8 && cimg::X11_attr().nb_bits!=16 &&
            cimg::X11_attr().nb_bits!=24 && cimg::X11_attr().nb_bits!=32)
          throw CImgDisplayException(_cimgdisplay_instance
                                     "assign(): Invalid %u bits screen mode detected "
                                     "(only 8, 16, 24 and 32 bits modes are managed).",
                                     cimgdisplay_instance,
                                     cimg::X11_attr().nb_bits);
        XVisualInfo vtemplate;
        vtemplate.visualid = XVisualIDFromVisual(DefaultVisual(dpy,DefaultScreen(dpy)));
        int nb_visuals;
        XVisualInfo *vinfo = XGetVisualInfo(dpy,VisualIDMask,&vtemplate,&nb_visuals);
        if (vinfo && vinfo->red_mask<vinfo->blue_mask) cimg::X11_attr().is_blue_first = true;
        cimg::X11_attr().byte_order = ImageByteOrder(dpy);
        XFree(vinfo);

        XLockDisplay(dpy);
        cimg::X11_attr().events_thread = new pthread_t;
        pthread_create(cimg::X11_attr().events_thread,0,_events_thread,0);
      } else XLockDisplay(dpy);

      // Set display variables.
      _width = cimg::min(dimw,(unsigned int)screen_width());
      _height = cimg::min(dimh,(unsigned int)screen_height());
      _normalization = normalization_type<4?normalization_type:3;
      _is_fullscreen = fullscreen_flag;
      _window_x = _window_y = 0;
      _is_closed = closed_flag;
      _title = tmp_title;
      flush();

      // Create X11 window (and LUT, if 8bits display)
      if (_is_fullscreen) {
        if (!_is_closed) _init_fullscreen();
        const unsigned int sx = screen_width(), sy = screen_height();
        XSetWindowAttributes winattr;
        winattr.override_redirect = 1;
        _window = XCreateWindow(dpy,DefaultRootWindow(dpy),(sx-_width)/2,(sy-_height)/2,_width,_height,0,0,
                                InputOutput,CopyFromParent,CWOverrideRedirect,&winattr);
      } else
        _window = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,_width,_height,0,0L,0L);

      XSelectInput(dpy,_window,
                   ExposureMask | StructureNotifyMask | ButtonPressMask | KeyPressMask | PointerMotionMask |
                   EnterWindowMask | LeaveWindowMask | ButtonReleaseMask | KeyReleaseMask);

      XStoreName(dpy,_window,_title?_title:" ");
      if (cimg::X11_attr().nb_bits==8) {
        _colormap = XCreateColormap(dpy,_window,DefaultVisual(dpy,DefaultScreen(dpy)),AllocAll);
        _set_colormap(_colormap,3);
        XSetWindowColormap(dpy,_window,_colormap);
      }

      static const char *const _window_class = cimg_appname;
      XClassHint *const window_class = XAllocClassHint();
      window_class->res_name = (char*)_window_class;
      window_class->res_class = (char*)_window_class;
      XSetClassHint(dpy,_window,window_class);
      XFree(window_class);

      _window_width = _width;
      _window_height = _height;

      // Create XImage
#ifdef cimg_use_xshm
      _shminfo = 0;
      if (XShmQueryExtension(dpy)) {
        _shminfo = new XShmSegmentInfo;
        _image = XShmCreateImage(dpy,DefaultVisual(dpy,DefaultScreen(dpy)),cimg::X11_attr().nb_bits,
                                 ZPixmap,0,_shminfo,_width,_height);
        if (!_image) { delete _shminfo; _shminfo = 0; }
        else {
          _shminfo->shmid = shmget(IPC_PRIVATE,_image->bytes_per_line*_image->height,IPC_CREAT|0777);
          if (_shminfo->shmid==-1) { XDestroyImage(_image); delete _shminfo; _shminfo = 0; }
          else {
            _shminfo->shmaddr = _image->data = (char*)(_data = shmat(_shminfo->shmid,0,0));
            if (_shminfo->shmaddr==(char*)-1) {
              shmctl(_shminfo->shmid,IPC_RMID,0); XDestroyImage(_image); delete _shminfo; _shminfo = 0;
            } else {
              _shminfo->readOnly = 0;
              cimg::X11_attr().is_shm_enabled = true;
              XErrorHandler oldXErrorHandler = XSetErrorHandler(_assign_xshm);
              XShmAttach(dpy,_shminfo);
              XSync(dpy,0);
              XSetErrorHandler(oldXErrorHandler);
              if (!cimg::X11_attr().is_shm_enabled) {
                shmdt(_shminfo->shmaddr); shmctl(_shminfo->shmid,IPC_RMID,0); XDestroyImage(_image);
                delete _shminfo; _shminfo = 0;
              }
            }
          }
        }
      }
      if (!_shminfo)
#endif
        {
          const unsigned long buf_size = (unsigned long)_width*_height*(cimg::X11_attr().nb_bits==8?1:
                                                                        (cimg::X11_attr().nb_bits==16?2:4));
          _data = std::malloc(buf_size);
          _image = XCreateImage(dpy,DefaultVisual(dpy,DefaultScreen(dpy)),cimg::X11_attr().nb_bits,
                                ZPixmap,0,(char*)_data,_width,_height,8,0);
        }

      _wm_window_atom = XInternAtom(dpy,"WM_DELETE_WINDOW",0);
      _wm_protocol_atom = XInternAtom(dpy,"WM_PROTOCOLS",0);
      XSetWMProtocols(dpy,_window,&_wm_window_atom,1);

      if (_is_fullscreen) XGrabKeyboard(dpy,_window,1,GrabModeAsync,GrabModeAsync,CurrentTime);
      cimg::X11_attr().wins[cimg::X11_attr().nb_wins++]=this;
      if (!_is_closed) _map_window(); else { _window_x = _window_y = cimg::type<int>::min(); }
      XUnlockDisplay(dpy);
      cimg::mutex(14,0);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %r9d, 0x4(%rsp)
movl %r8d, (%rsp)
movq %rcx, %rbp
movl %edx, %r13d
movl %esi, %r15d
movq %rdi, %rbx
pushq $0xe
popq %rdi
pushq $0x1
popq %r12
movl %r12d, %esi
callq 0xa419
testq %rbp, %rbp
leaq 0x3beeb(%rip), %r14     # 0x547e8
cmovneq %rbp, %r14
movq %r14, %rdi
callq 0x41e0
incl %eax
jne 0x18918
movq $0x0, 0x8(%rsp)
jmp 0x18935
movl %eax, %ebp
movq %rbp, %rdi
callq 0x4040
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x4410
cmpl $0x0, 0x18(%rbx)
je 0x18949
cmpl $0x0, 0x1c(%rbx)
je 0x18949
movq %rbx, %rdi
callq 0x1841e
callq 0x1a004
movq %rax, %r14
movq 0x2068(%rax), %rdi
testq %rdi, %rdi
je 0x18967
callq 0x4270
jmp 0x18a98
xorl %edi, %edi
callq 0x46e0
movq %rax, 0x2068(%r14)
testq %rax, %rax
je 0x18e42
movq 0xe8(%rax), %rcx
movslq 0xe0(%rax), %rax
shlq $0x7, %rax
movl 0x38(%rcx,%rax), %ebp
callq 0x1a004
movl %ebp, 0x2070(%rax)
callq 0x1a004
cmpl $0x8, 0x2070(%rax)
je 0x189db
callq 0x1a004
cmpl $0x10, 0x2070(%rax)
je 0x189db
callq 0x1a004
cmpl $0x18, 0x2070(%rax)
je 0x189db
callq 0x1a004
cmpl $0x20, 0x2070(%rax)
jne 0x18eab
movq 0x2068(%r14), %rax
movq 0xe8(%rax), %rcx
movslq 0xe0(%rax), %rax
shlq $0x7, %rax
movq 0x40(%rcx,%rax), %rdi
callq 0x48e0
leaq 0x18(%rsp), %rdx
movq %rax, 0x8(%rdx)
movq 0x2068(%r14), %rdi
pushq $0x1
popq %rsi
leaq 0x14(%rsp), %rcx
callq 0x4420
movq %rax, %rbp
testq %rax, %rax
je 0x18a39
movq 0x20(%rbp), %rax
cmpq 0x30(%rbp), %rax
jae 0x18a39
callq 0x1a004
movb $0x1, 0x2074(%rax)
movq 0x2068(%r14), %rax
movl 0x50(%rax), %r12d
callq 0x1a004
testl %r12d, %r12d
setne 0x2076(%rax)
movq %rbp, %rdi
callq 0x4630
movq 0x2068(%r14), %rdi
callq 0x4270
pushq $0x8
popq %rdi
callq 0x4540
movq %rax, %rbp
callq 0x1a004
movq %rbp, 0x8(%rax)
callq 0x1a004
movq 0x8(%rax), %rdi
leaq 0x2c9f(%rip), %rdx      # 0x1b72a
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x49c0
pushq $0x1
popq %r12
movb 0xc0(%rsp), %bpl
callq 0xc76c
cmpl %eax, %r15d
cmovbl %r15d, %eax
movl %eax, 0x18(%rbx)
callq 0xc814
cmpl %eax, %r13d
cmovbl %r13d, %eax
movl (%rsp), %edx
cmpl $0x3, %edx
pushq $0x3
popq %rcx
cmovbl %edx, %ecx
movl %eax, 0x1c(%rbx)
movl %ecx, 0x20(%rbx)
movl 0x4(%rsp), %eax
movb %al, 0x30(%rbx)
movl $0x0, 0x450(%rbx)
movl 0x450(%rbx), %eax
movl %eax, 0x44c(%rbx)
movb %bpl, 0x460(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rbx)
movq %rbx, %rdi
callq 0x19fb8
cmpb $0x1, 0x30(%rbx)
jne 0x18b7c
cmpb $0x0, 0x460(%rbx)
jne 0x18b19
movq %rbx, %rdi
callq 0x1b81a
callq 0xc76c
movl %eax, %ebp
callq 0xc814
leaq 0x18(%rsp), %r10
movl %r12d, 0x58(%r10)
movq 0x2068(%r14), %rdi
movq 0xe8(%rdi), %rcx
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x10(%rcx,%rdx), %rsi
movl 0x18(%rbx), %r8d
movl 0x1c(%rbx), %r9d
subl %r8d, %ebp
shrl %ebp
subl %r9d, %eax
shrl %eax
movl %ebp, %edx
movl %eax, %ecx
pushq %r10
pushq $0x200                  # imm = 0x200
pushq $0x0
pushq %r12
pushq $0x0
pushq $0x0
callq 0x4830
addq $0x30, %rsp
jmp 0x18bbf
movq 0x2068(%r14), %rdi
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rcx
shlq $0x7, %rcx
movq 0x10(%rax,%rcx), %rsi
movl 0x18(%rbx), %r8d
movl 0x1c(%rbx), %r9d
subq $0x20, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
andl $0x0, (%rsp)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4170
addq $0x20, %rsp
movq %rax, 0x4d0(%rbx)
movq 0x2068(%r14), %rdi
movl $0x2807f, %edx          # imm = 0x2807F
movq %rax, %rsi
callq 0x42e0
movq 0x2068(%r14), %rdi
movq 0x4d0(%rbx), %rsi
movq 0x38(%rbx), %rax
testq %rax, %rax
leaq 0x5eda2(%rip), %rdx     # 0x77998
cmovneq %rax, %rdx
callq 0x40b0
callq 0x1a004
cmpl $0x8, 0x2070(%rax)
jne 0x18c6d
movq 0x2068(%r14), %rdi
movq 0x4d0(%rbx), %rsi
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rcx
shlq $0x7, %rcx
movq 0x40(%rax,%rcx), %rdx
pushq $0x1
popq %rcx
callq 0x4310
leaq 0x4e0(%rbx), %rsi
movq %rax, 0x4e0(%rbx)
pushq $0x3
popq %rdx
movq %rbx, %rdi
callq 0x1ba3e
movq 0x2068(%r14), %rdi
movq 0x4d0(%rbx), %rsi
movq 0x4e0(%rbx), %rdx
callq 0x4860
callq 0x47e0
movq %rax, %r15
leaq 0x5bb92(%rip), %rax     # 0x7480e
movq %rax, (%r15)
movq %rax, 0x8(%r15)
movq 0x2068(%r14), %rdi
movq 0x4d0(%rbx), %rsi
movq %r15, %rdx
callq 0x42b0
movq %r15, %rdi
callq 0x4630
movl 0x18(%rbx), %eax
movl 0x1c(%rbx), %r15d
movl %eax, 0x40(%rbx)
movl %r15d, 0x44(%rbx)
imulq %rax, %r15
callq 0x1a004
cmpl $0x8, 0x2070(%rax)
jne 0x18cc6
pushq $0x1
popq %rax
jmp 0x18cdf
callq 0x1a004
xorl %ecx, %ecx
cmpl $0x10, 0x2070(%rax)
setne %cl
leaq 0x2(,%rcx,2), %rax
imulq %rax, %r15
movq %r15, %rdi
callq 0x46a0
movq %rax, 0x4f0(%rbx)
movq 0x2068(%r14), %r15
movq 0xe8(%r15), %rax
movslq 0xe0(%r15), %rcx
shlq $0x7, %rcx
movq 0x40(%rax,%rcx), %r12
callq 0x1a004
movl 0x2070(%rax), %edx
movq 0x4f0(%rbx), %r9
movl 0x18(%rbx), %eax
movl 0x1c(%rbx), %ecx
subq $0x20, %rsp
movl %ecx, 0x8(%rsp)
movl %eax, (%rsp)
andl $0x0, 0x18(%rsp)
movl $0x8, 0x10(%rsp)
pushq $0x2
popq %rcx
movq %r15, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x4610
addq $0x20, %rsp
movq %rax, 0x4e8(%rbx)
movq 0x2068(%r14), %rdi
leaq 0x5baa9(%rip), %rsi     # 0x74813
xorl %edx, %edx
callq 0x43b0
leaq 0x4c0(%rbx), %r15
movq %rax, 0x4c0(%rbx)
movq 0x2068(%r14), %rdi
leaq 0x5ba97(%rip), %rsi     # 0x74824
xorl %edx, %edx
callq 0x43b0
movq %rax, 0x4c8(%rbx)
movq 0x2068(%r14), %rdi
movq 0x4d0(%rbx), %rsi
pushq $0x1
popq %rcx
movq %r15, %rdx
callq 0x42a0
cmpb $0x1, 0x30(%rbx)
jne 0x18dd8
movq 0x2068(%r14), %rdi
movq 0x4d0(%rbx), %rsi
pushq $0x1
popq %rcx
movl %ecx, %edx
movl %ecx, %r8d
xorl %r9d, %r9d
callq 0x4600
callq 0x1a004
movq %rax, %r15
callq 0x1a004
movl (%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, (%rax)
movq %rbx, 0x68(%r15,%rcx,8)
cmpb $0x0, 0x460(%rbx)
je 0x18e12
movl $0x80000000, 0x450(%rbx) # imm = 0x80000000
movl 0x450(%rbx), %eax
movl %eax, 0x44c(%rbx)
jmp 0x18e1a
movq %rbx, %rdi
callq 0x1bb9a
movq 0x2068(%r14), %rdi
callq 0x41f0
pushq $0xe
popq %rdi
xorl %esi, %esi
callq 0xa419
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
movl 0x18(%rbx), %edx
movq 0x38(%rbx), %rax
testq %rax, %rax
pushq $0x5b
popq %r9
pushq $0x22
popq %rsi
cmovnel %esi, %r9d
movl 0x1c(%rbx), %ecx
leaq 0x5b90f(%rip), %r10     # 0x7477d
cmovneq %rax, %r10
movl 0x20(%rbx), %r8d
pushq $0x5d
popq %r11
cmovnel %esi, %r11d
leaq 0x5b8a9(%rip), %rsi     # 0x7472e
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1b624
popq %rax
popq %rcx
leaq 0x76e24(%rip), %rsi     # 0x8fcc0
movq 0x77135(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
movl 0x18(%rbx), %ebp
movl 0x1c(%rbx), %r15d
movl 0x20(%rbx), %r12d
movq 0x38(%rbx), %rbx
callq 0x1a004
testq %rbx, %rbx
leaq 0x5b8a7(%rip), %r10     # 0x7477d
cmovneq %rbx, %r10
pushq $0x5b
popq %r9
pushq $0x22
popq %rcx
cmovnel %ecx, %r9d
pushq $0x5d
popq %r11
cmovnel %ecx, %r11d
movl 0x2070(%rax), %ebx
subq $0x8, %rsp
leaq 0x5b888(%rip), %rsi     # 0x74786
movq %r14, %rdi
movl %ebp, %edx
movl %r15d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
pushq %rbx
pushq %r11
pushq %r10
callq 0x1b624
addq $0x20, %rsp
jmp 0x18e95
jmp 0x18f20
movq %rax, %rbx
movq %r14, %rdi
callq 0x4390
movq %rbx, %rdi
callq 0x4950
nop