// File: /workspace/github_cpp_makefile_star2_O1/Alcaro[P]bridges/arlib/game-x11.cpp
// Function: gameview_x11::process_event(_XEvent*)
void process_event(XEvent* ev)
{
	got_event = true;
	switch (ev->type)
	{
		case Expose: break; // just set got_event, nothing else needed
		case FocusIn:
			focus = true;
			set_all_keys();
			break;
		case FocusOut:
			focus = false;
			break;
		case KeyPress:
		case KeyRelease:
			set_key(ev->xkey.keycode, (ev->type == KeyPress));
			break;
		case ButtonPress:
		case ButtonRelease:
			static_assert(Button1Mask == 256); // guaranteed by X11 spec
			static_assert(Button2Mask == 512);
			static_assert(Button3Mask == 1024);
			if (ev->xbutton.button >= 1 && ev->xbutton.button <= 3)
				send_mouse(ev->xbutton.x, ev->xbutton.y, ev->xbutton.state^(Button1Mask >> 1 << ev->xbutton.button));
			break;
		case MotionNotify:
			send_mouse(ev->xmotion.x, ev->xmotion.y, ev->xmotion.state);
			break;
		case LeaveNotify:
			if (!(ev->xcrossing.state & (Button1Mask | Button2Mask | Button3Mask))) // if a button is held, we'll get a MotionNotify soon
				send_mouse(-0x8000000, -0x8000000, ev->xcrossing.state);
			break;
		case ClientMessage:
			if (ev->xclient.message_type == atoms.WM_PROTOCOLS && ev->xclient.format == 32)
			{
				Atom subtype = ev->xclient.data.l[0];
				if (subtype == atoms.WM_DELETE_WINDOW)
				{
					cb_exit();
				}
				else if (subtype == atoms._NET_WM_PING)
				{
					ev->xclient.window = XRootWindow(display, window_x11.screen);
					XSendEvent(display, ev->xclient.window, false, SubstructureRedirectMask|SubstructureNotifyMask, ev);
				}
#ifndef ARLIB_OPT
				else puts("AAAAA unknown WM_PROTOCOLS");
#endif
			}
#ifndef ARLIB_OPT
			else puts("AAAAA unknown ClientMessage");
#endif
			break;
#ifndef ARLIB_OPT
		default:
			printf("AAAAA unknown event %d\n",ev->type);
			break;
#endif
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r9
movb $0x1, 0x1a(%rdi)
movl (%rsi), %esi
leal -0x2(%rsi), %eax
cmpl $0xa, %eax
ja 0xa524
leaq 0x2509f(%rip), %rcx     # 0x2f554
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0x54(%rbx), %eax
xorl %edx, %edx
cmpl $0x2, %esi
sete %dl
movq %r9, %rdi
movl %eax, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xa6b8
movl 0x54(%rbx), %ecx
leal -0x1(%rcx), %eax
cmpl $0x2, %eax
ja 0xa5c7
movl $0x80, %eax
shll %cl, %eax
xorl 0x50(%rbx), %eax
movl 0x40(%rbx), %esi
shrl $0x6, %eax
andb $0x1c, %al
movl $0x76325410, %r8d       # imm = 0x76325410
movl %eax, %ecx
shrl %cl, %r8d
movl 0x44(%rbx), %edx
movq 0x2b0(%r9), %rdi
movq 0x2b8(%r9), %rax
andl $0x7, %r8d
movl %r8d, %ecx
jmp 0xa5fc
cmpl $0x21, %esi
jne 0xa55e
movq 0x28(%rbx), %rax
cmpq 0x20(%r9), %rax
jne 0xa5cf
cmpl $0x20, 0x30(%rbx)
jne 0xa5cf
movq 0x38(%rbx), %rax
cmpq 0x28(%r9), %rax
jne 0xa605
movq 0x60(%r9), %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmpq *0x68(%r9)
leaq 0x25095(%rip), %rdi     # 0x2f5fa
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3050
movb $0x1, 0x18(%r9)
movq %r9, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xa648
movb $0x0, 0x18(%r9)
jmp 0xa5c7
movl 0x40(%rbx), %esi
movl 0x50(%rbx), %ecx
shrl $0x6, %ecx
andb $0x1c, %cl
movl $0x76325410, %eax       # imm = 0x76325410
shrl %cl, %eax
movl 0x44(%rbx), %edx
movq 0x2b0(%r9), %rdi
movq 0x2b8(%r9), %r8
andl $0x7, %eax
movl %eax, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
jmpq *%r8
testb $0x7, 0x61(%rbx)
je 0xa5e2
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x25008(%rip), %rdi     # 0x2f5de
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3590
movq 0x2b0(%r9), %rdi
movq 0x2b8(%r9), %rax
movl $0xf8000000, %esi       # imm = 0xF8000000
movl $0xf8000000, %edx       # imm = 0xF8000000
xorl %ecx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
jmpq *%rax
cmpq 0x30(%r9), %rax
jne 0xa63e
movq 0x8(%r9), %rdi
movl 0x3bd3b(%rip), %esi     # 0x46350
movq %r9, %r14
callq 0x35d0
movq %rax, 0x20(%rbx)
movq 0x8(%r14), %rdi
movl $0x180000, %ecx         # imm = 0x180000
movq %rax, %rsi
xorl %edx, %edx
movq %rbx, %r8
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x30c0
leaq 0x24f7e(%rip), %rdi     # 0x2f5c3
jmp 0xa5d6
nop