// File: /workspace/github_cpp_makefile_star2_O2/manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImgDisplay::_handle_events(_XEvent const*)
void _handle_events(const XEvent *const pevent) {
      Display *const dpy = cimg::X11_attr().display;
      XEvent event = *pevent;
      switch (event.type) {
      case ClientMessage : {
        if ((int)event.xclient.message_type==(int)_wm_protocol_atom &&
            (int)event.xclient.data.l[0]==(int)_wm_window_atom) {
          XUnmapWindow(cimg::X11_attr().display,_window);
          _is_closed = _is_event = true;
          pthread_cond_broadcast(&cimg::X11_attr().wait_event);
        }
      } break;
      case ConfigureNotify : {
        while (XCheckWindowEvent(dpy,_window,StructureNotifyMask,&event)) {}
        const unsigned int nw = event.xconfigure.width, nh = event.xconfigure.height;
        const int nx = event.xconfigure.x, ny = event.xconfigure.y;
        if (nw && nh && (nw!=_window_width || nh!=_window_height)) {
          _window_width = nw; _window_height = nh; _mouse_x = _mouse_y = -1;
          XResizeWindow(dpy,_window,_window_width,_window_height);
          _is_resized = _is_event = true;
          pthread_cond_broadcast(&cimg::X11_attr().wait_event);
        }
        if (nx!=_window_x || ny!=_window_y) {
          _window_x = nx; _window_y = ny; _is_moved = _is_event = true;
          pthread_cond_broadcast(&cimg::X11_attr().wait_event);
        }
      } break;
      case Expose : {
        while (XCheckWindowEvent(dpy,_window,ExposureMask,&event)) {}
        _paint(false);
        if (_is_fullscreen) {
          XWindowAttributes attr;
          XGetWindowAttributes(dpy,_window,&attr);
          while (attr.map_state!=IsViewable) XSync(dpy,0);
          XSetInputFocus(dpy,_window,RevertToParent,CurrentTime);
        }
      } break;
      case ButtonPress : {
        do {
          _mouse_x = event.xmotion.x; _mouse_y = event.xmotion.y;
          if (_mouse_x<0 || _mouse_y<0 || _mouse_x>=width() || _mouse_y>=height()) _mouse_x = _mouse_y = -1;
          switch (event.xbutton.button) {
          case 1 : set_button(1); break;
          case 3 : set_button(2); break;
          case 2 : set_button(3); break;
          }
        } while (XCheckWindowEvent(dpy,_window,ButtonPressMask,&event));
      } break;
      case ButtonRelease : {
        do {
          _mouse_x = event.xmotion.x; _mouse_y = event.xmotion.y;
          if (_mouse_x<0 || _mouse_y<0 || _mouse_x>=width() || _mouse_y>=height()) _mouse_x = _mouse_y = -1;
          switch (event.xbutton.button) {
          case 1 : set_button(1,false); break;
          case 3 : set_button(2,false); break;
          case 2 : set_button(3,false); break;
          case 4 : set_wheel(1); break;
          case 5 : set_wheel(-1); break;
          }
        } while (XCheckWindowEvent(dpy,_window,ButtonReleaseMask,&event));
      } break;
      case KeyPress : {
        char tmp = 0; KeySym ksym;
        XLookupString(&event.xkey,&tmp,1,&ksym,0);
        set_key((unsigned int)ksym,true);
      } break;
      case KeyRelease : {
        char keys_return[32];  // Check that the key has been physically unpressed.
        XQueryKeymap(dpy,keys_return);
        const unsigned int kc = event.xkey.keycode, kc1 = kc/8, kc2 = kc%8;
        const bool is_key_pressed = kc1>=32?false:(keys_return[kc1]>>kc2)&1;
        if (!is_key_pressed) {
          char tmp = 0; KeySym ksym;
          XLookupString(&event.xkey,&tmp,1,&ksym,0);
          set_key((unsigned int)ksym,false);
        }
      } break;
      case EnterNotify: {
        while (XCheckWindowEvent(dpy,_window,EnterWindowMask,&event)) {}
        _mouse_x = event.xmotion.x;
        _mouse_y = event.xmotion.y;
        if (_mouse_x<0 || _mouse_y<0 || _mouse_x>=width() || _mouse_y>=height()) _mouse_x = _mouse_y = -1;
      } break;
      case LeaveNotify : {
        while (XCheckWindowEvent(dpy,_window,LeaveWindowMask,&event)) {}
        _mouse_x = _mouse_y =-1; _is_event = true;
        pthread_cond_broadcast(&cimg::X11_attr().wait_event);
      } break;
      case MotionNotify : {
        while (XCheckWindowEvent(dpy,_window,PointerMotionMask,&event)) {}
        _mouse_x = event.xmotion.x;
        _mouse_y = event.xmotion.y;
        if (_mouse_x<0 || _mouse_y<0 || _mouse_x>=width() || _mouse_y>=height()) _mouse_x = _mouse_y = -1;
        _is_event = true;
        pthread_cond_broadcast(&cimg::X11_attr().wait_event);
      } break;
      }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %r15
movq %rdi, %rbx
callq 0x1a004
movq 0x2068(%rax), %r14
leaq 0x10(%rsp), %r12
movl $0xc0, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x4410
movl (%r12), %ecx
leal -0x2(%rcx), %eax
cmpl $0x14, %eax
ja 0x1bd02
leaq 0x38631(%rip), %rcx     # 0x542f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x8(%rsp), %rsi
movb $0x0, (%rsi)
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rbp
leaq 0xd0(%rsp), %r14
movl %ebp, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x4480
movl (%r14), %esi
movq %rbx, %rdi
movl %ebp, %edx
jmp 0x1c0cd
cmpl $0x21, %ecx
jne 0x1c1c2
movl 0x38(%rsp), %eax
cmpl 0x4c8(%rbx), %eax
jne 0x1c1c2
movl 0x48(%rsp), %eax
cmpl 0x4c0(%rbx), %eax
jne 0x1c1c2
callq 0x1a004
movq 0x2068(%rax), %rdi
movq 0x4d0(%rbx), %rsi
callq 0x47b0
movb $0x1, 0x463(%rbx)
movb 0x463(%rbx), %al
movb %al, 0x460(%rbx)
callq 0x1a004
leaq 0x10(%rax), %rdi
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4180
leaq 0x10(%rsp), %r15
movq 0x4d0(%rbx), %rsi
movl $0x20000, %edx          # imm = 0x20000
movq %r14, %rdi
movq %r15, %rcx
callq 0x4370
testl %eax, %eax
jne 0x1bd7a
movl 0x48(%rsp), %eax
movl 0x4c(%rsp), %ecx
movl 0x40(%rsp), %ebp
movl 0x44(%rsp), %r15d
testl %eax, %eax
setne %dl
testl %ecx, %ecx
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x1be16
cmpl 0x40(%rbx), %eax
jne 0x1bdc4
cmpl 0x44(%rbx), %ecx
je 0x1be16
movl %eax, 0x40(%rbx)
movl %ecx, 0x44(%rbx)
movl $0xffffffff, 0x458(%rbx) # imm = 0xFFFFFFFF
movl 0x458(%rbx), %eax
movl %eax, 0x454(%rbx)
movq 0x4d0(%rbx), %rsi
movl 0x40(%rbx), %edx
movl 0x44(%rbx), %ecx
movq %r14, %rdi
callq 0x4790
movb $0x1, 0x463(%rbx)
movb 0x463(%rbx), %al
movb %al, 0x461(%rbx)
callq 0x1a004
leaq 0x10(%rax), %rdi
callq 0x4180
cmpl 0x44c(%rbx), %ebp
jne 0x1be2b
cmpl 0x450(%rbx), %r15d
je 0x1c1c2
movl %ebp, 0x44c(%rbx)
movl %r15d, 0x450(%rbx)
movb $0x1, 0x463(%rbx)
movb 0x463(%rbx), %al
movb %al, 0x462(%rbx)
jmp 0x1beef
pushq $0x40
popq %r15
leaq 0x10(%rsp), %r12
movq 0x4d0(%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x4370
testl %eax, %eax
jne 0x1be59
movl 0x50(%rsp), %eax
movl %eax, 0x454(%rbx)
movl 0x54(%rsp), %eax
movl %eax, 0x458(%rbx)
cmpl $0x0, 0x454(%rbx)
js 0x1bed2
cmpl $0x0, 0x458(%rbx)
js 0x1bed2
movl 0x454(%rbx), %eax
cmpl 0x18(%rbx), %eax
jge 0x1bed2
movl 0x458(%rbx), %eax
cmpl 0x1c(%rbx), %eax
jge 0x1bed2
jmp 0x1bee8
pushq $0x20
popq %r15
leaq 0x10(%rsp), %r12
movq 0x4d0(%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x4370
testl %eax, %eax
jne 0x1beb9
movl $0xffffffff, 0x458(%rbx) # imm = 0xFFFFFFFF
movl 0x458(%rbx), %eax
movl %eax, 0x454(%rbx)
movb $0x1, 0x463(%rbx)
callq 0x1a004
leaq 0x10(%rax), %rdi
callq 0x4180
jmp 0x1c1c2
leaq 0x39aeb(%rip), %r13     # 0x559f4
pushq $0x1
popq %rbp
pushq $0x4
popq %r15
leaq 0x10(%rsp), %r12
movl 0x50(%rsp), %eax
movl %eax, 0x454(%rbx)
movl 0x54(%rsp), %eax
movl %eax, 0x458(%rbx)
cmpl $0x0, 0x454(%rbx)
js 0x1bf51
cmpl $0x0, 0x458(%rbx)
js 0x1bf51
movl 0x454(%rbx), %eax
cmpl 0x18(%rbx), %eax
jge 0x1bf51
movl 0x458(%rbx), %eax
cmpl 0x1c(%rbx), %eax
jl 0x1bf67
movl $0xffffffff, 0x458(%rbx) # imm = 0xFFFFFFFF
movl 0x458(%rbx), %eax
movl %eax, 0x454(%rbx)
movl 0x64(%rsp), %eax
decl %eax
cmpl $0x2, %eax
ja 0x1bf83
movl %eax, %eax
movl (%r13,%rax,4), %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x1c2d4
movq 0x4d0(%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x4370
testl %eax, %eax
jne 0x1bf15
jmp 0x1c1c2
pushq $0x8
popq %r15
leaq 0x10(%rsp), %r12
leaq 0x38397(%rip), %r13     # 0x5434c
pushq $0x1
popq %rbp
movl 0x50(%rsp), %eax
movl %eax, 0x454(%rbx)
movl 0x54(%rsp), %eax
movl %eax, 0x458(%rbx)
cmpl $0x0, 0x454(%rbx)
js 0x1bff4
cmpl $0x0, 0x458(%rbx)
js 0x1bff4
movl 0x454(%rbx), %eax
cmpl 0x18(%rbx), %eax
jge 0x1bff4
movl 0x458(%rbx), %eax
cmpl 0x1c(%rbx), %eax
jl 0x1c00a
movl $0xffffffff, 0x458(%rbx) # imm = 0xFFFFFFFF
movl 0x458(%rbx), %eax
movl %eax, 0x454(%rbx)
movl 0x64(%rsp), %eax
decl %eax
cmpl $0x4, %eax
ja 0x1c04e
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq %rbx, %rdi
movl %ebp, %esi
jmp 0x1c047
movq %rbx, %rdi
pushq $-0x1
popq %rsi
jmp 0x1c03a
movq %rbx, %rdi
pushq $0x2
jmp 0x1c046
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1c31a
jmp 0x1c04e
movq %rbx, %rdi
pushq $0x3
popq %rsi
xorl %edx, %edx
callq 0x1c2d4
movq 0x4d0(%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x4370
testl %eax, %eax
jne 0x1bfb8
jmp 0x1c1c2
leaq 0xd0(%rsp), %rsi
movq %r14, %rdi
callq 0x45e0
movl 0x64(%rsp), %eax
cmpq $0xff, %rax
ja 0x1c0a5
movl %eax, %ecx
shrl $0x3, %ecx
movzbl 0xd0(%rsp,%rcx), %ecx
andl $0x7, %eax
btl %eax, %ecx
jb 0x1c1c2
leaq 0x7(%rsp), %rsi
movb $0x0, (%rsi)
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
leaq 0x8(%rsp), %r14
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x4480
movl (%r14), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1c342
jmp 0x1c1c2
pushq $0x10
popq %r15
leaq 0x10(%rsp), %r12
movq 0x4d0(%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x4370
testl %eax, %eax
jne 0x1c0e0
movl 0x50(%rsp), %eax
movl %eax, 0x454(%rbx)
movl 0x54(%rsp), %eax
movl %eax, 0x458(%rbx)
cmpl $0x0, 0x454(%rbx)
js 0x1c139
cmpl $0x0, 0x458(%rbx)
js 0x1c139
movl 0x454(%rbx), %eax
cmpl 0x18(%rbx), %eax
jge 0x1c139
movl 0x458(%rbx), %eax
cmpl 0x1c(%rbx), %eax
jl 0x1c1c2
movl $0xffffffff, 0x458(%rbx) # imm = 0xFFFFFFFF
movl 0x458(%rbx), %eax
movl %eax, 0x454(%rbx)
jmp 0x1c1c2
leaq 0x10(%rsp), %r15
movq 0x4d0(%rbx), %rsi
movl $0x8000, %edx           # imm = 0x8000
movq %r14, %rdi
movq %r15, %rcx
callq 0x4370
testl %eax, %eax
jne 0x1c156
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1c202
cmpb $0x1, 0x30(%rbx)
jne 0x1c1c2
movq 0x4d0(%rbx), %rsi
leaq 0xd0(%rsp), %rdx
movq %r14, %rdi
callq 0x4960
cmpl $0x2, 0x12c(%rsp)
je 0x1c1ae
movq %r14, %rdi
xorl %esi, %esi
callq 0x4a10
jmp 0x1c198
movq 0x4d0(%rbx), %rsi
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x43e0
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq