// File: /workspace/github_cpp_makefile_star2_O3/enbock[P]Warp10Server/ulib/src/EventDispatcher.cpp
// Function: u::EventDispatcher::dispatchEvent(u::Event*)
Event* EventDispatcher::dispatchEvent(Event *event)
{
	lock();

	Vector<Callback>* pVec = getEventVector(event->_type);
	if(pVec != null)
	{
		Vector<Callback> vec = *pVec;
		unlock();

		int64 i=0, l = vec.size();
		for(i=0; i<l; i++)
		{
			Callback cb = vec.at(i);
			trace(
				"DispatchEvent: " + *(event->_type)
				+ "\033[36m -> "+cb.toString()
			);
			Event* ev = event->clone();
			ev->_target = this;
			cb.arg = ev;

			if(ThreadSystem::create(&cb) == false)
			{
				// thread system is terminating
				ev->destroy();
			}
		}

		return event;
	}
	else
	{
		trace(
			"\033[32mNo listener for " + *event->type()
			+ " on target "+ toString() + "."
		);
	}
	unlock();
	return event;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rsi, 0x20(%rsp)
movq %rdi, %r14
callq 0x40992e
movq 0x70(%r14), %rsi
movq %r14, 0x48(%rsp)
movq 0x78(%r14), %rax
subq %rsi, %rax
testq %rax, %rax
jle 0x407dce
movq 0x20(%rsp), %rcx
movq 0x38(%rcx), %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rdx # imm = 0x2E8BA2E8BA2E8BA3
mulq %rdx
shrq $0x4, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
addq $0x40, %rsi
cmpq %rcx, -0x40(%rsi)
je 0x407e44
addq $0x58, %rsi
decq %rdx
jne 0x407dbf
movq $0x6106a0, %rdi         # imm = 0x6106A0
leaq 0x19129d(%rip), %rsi    # 0x599079
movl $0x4, %edx
callq 0x4779a0
movq 0x20(%rsp), %rdi
callq 0x405f6e
leaq 0x38(%rax), %rdx
leaq 0x1913f6(%rip), %rsi    # 0x5991f1
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x40629b
leaq 0x1913f8(%rip), %rsi    # 0x599207
movq %r14, %rdi
callq 0x489580
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4081a9
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x4081b0
leaq -0x38(%rsi), %r14
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0x409146
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x409b56
leaq 0x1fd89c(%rip), %rax    # 0x605708
movq %rax, 0x50(%rsp)
movq 0x48(%rsp), %rdi
callq 0x4098e6
movq 0x90(%rsp), %rax
subq 0x88(%rsp), %rax
testq %rax, %rax
jle 0x40818d
movabsq $0x2e8ba2e8ba2e8ba3, %rcx # imm = 0x2E8BA2E8BA2E8BA3
mulq %rcx
shrq $0x4, %rdx
leaq 0x38(%rsp), %r15
cmpq $0x1, %rdx
adcq $0x0, %rdx
movq %rdx, 0xa0(%rsp)
xorl %r12d, %r12d
leaq 0x120(%rsp), %rbp
movq $0x6106a0, %r14         # imm = 0x6106A0
xorl %r13d, %r13d
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
movabsq $0x2e8ba2e8ba2e8ba3, %rax # imm = 0x2E8BA2E8BA2E8BA3
imulq %rax, %rdx
cmpq %r13, %rdx
jbe 0x4083ef
addq %r12, %rsi
movq %rbp, %rdi
callq 0x40599a
movl $0x4, %edx
movq %r14, %rdi
leaq 0x191162(%rip), %rsi    # 0x599079
callq 0x4779a0
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rdx
addq $0x38, %rdx
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x19129c(%rip), %rsi    # 0x5991d7
callq 0x40629b
movq %rbx, %rdi
leaq 0x19129d(%rip), %rsi    # 0x5991e7
callq 0x489580
movq %r15, 0x28(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x407f72
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x407f79
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xc8(%rsp), %rdi
movq %rbp, %rsi
callq 0x405a58
movq 0x28(%rsp), %rcx
movl $0xf, %edi
cmpq %r15, %rcx
je 0x407fb5
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %r8
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x407ff2
movl $0xf, %edi
leaq 0x110(%rsp), %r9
cmpq %r9, %rsi
je 0x407fed
movq 0x110(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x407ffe
leaq 0x28(%rsp), %rdi
callq 0x489440
jmp 0x40800f
leaq 0x100(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x488dc0
leaq 0x10(%rsp), %rsi
movq %rsi, (%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x408032
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x408038
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r14, %r15
movq %r14, %rdi
callq 0x4779a0
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
leaq 0x19100a(%rip), %rsi    # 0x599085
callq 0x4779a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x458af0
movsbl %al, %esi
movq %r14, %rdi
callq 0x4774a0
movq %rax, %rdi
callq 0x476a70
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4080c2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40dd80
movq 0x100(%rsp), %rdi
leaq 0x110(%rsp), %rax
cmpq %rax, %rdi
je 0x4080e7
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x40dd80
leaq 0xc8(%rsp), %rdi
callq 0x409a3a
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x408110
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40dd80
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x408135
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x40dd80
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq %rax, %r14
movq 0x48(%rsp), %rax
movq %rax, 0x40(%r14)
movq %r14, 0x170(%rsp)
movq %rbp, %rdi
callq 0x40b9ac
testb %al, %al
jne 0x408168
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
movq %rbp, %rdi
callq 0x409a3a
incq %r13
addq $0x58, %r12
cmpq %r13, 0xa0(%rsp)
movq %r15, %r14
leaq 0x38(%rsp), %r15
jne 0x407ecf
leaq 0x50(%rsp), %rdi
callq 0x409a3a
leaq 0x88(%rsp), %rdi
callq 0x40877c
jmp 0x4083d8
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x48(%rsp), %rsi
movq (%rsi), %rax
leaq 0x120(%rsp), %rdi
callq *0x18(%rax)
movq (%rsp), %rcx
movq 0x8(%rsp), %r8
movq 0x160(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r15, %rcx
je 0x4081ff
movq 0x10(%rsp), %rdi
leaq 0x168(%rsp), %r12
movq -0x10(%r12), %rsi
cmpq %rdi, %rax
jbe 0x408228
movl $0xf, %edi
cmpq %r12, %rsi
je 0x408223
movq 0x168(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x408232
movq %rsp, %rdi
callq 0x489440
jmp 0x408243
leaq 0x158(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x488dc0
leaq 0x60(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x408267
movq %rsi, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x40826d
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x1951bc(%rip), %rsi    # 0x59d44d
leaq 0x50(%rsp), %rdi
callq 0x489580
leaq 0xd8(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x4082cb
movq %rsi, 0xc8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xd8(%rsp)
jmp 0x4082d6
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %r13, %rsi
movq 0x8(%rax), %rdx
movq %rdx, 0xd0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq $0x6106a0, %rdi         # imm = 0x6106A0
callq 0x4779a0
movq %rax, %r14
leaq 0x190d7e(%rip), %rsi    # 0x599085
movl $0x4, %edx
movq %rax, %rdi
callq 0x4779a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x458af0
movsbl %al, %esi
movq %r14, %rdi
callq 0x4774a0
movq %rax, %rdi
callq 0x476a70
movq 0xc8(%rsp), %rdi
cmpq %r13, %rdi
je 0x408358
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x40dd80
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x408373
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x40dd80
movq 0x158(%rsp), %rdi
cmpq %r12, %rdi
je 0x408390
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x40dd80
leaq 0x120(%rsp), %rdi
callq 0x409a3a
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x4083b3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40dd80
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4083ce
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40dd80
movq 0x48(%rsp), %rdi
callq 0x4098e6
movq 0x20(%rsp), %rax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x190e5a(%rip), %rdi    # 0x599250
movq %r13, %rsi
xorl %eax, %eax
callq 0x458600
jmp 0x4084a8
movq %rax, %rbx
movq %r15, %rdi
jmp 0x408553
movq %rax, %rbx
jmp 0x408444
movq %rax, %rbx
jmp 0x40845f
movq %rax, %rbx
jmp 0x40846c
movq %rax, %rbx
jmp 0x408482
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r13, %rdi
je 0x408444
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x40dd80
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40845f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x40dd80
leaq 0x120(%rsp), %rdi
callq 0x404a8c
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x408482
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40dd80
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x408558
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40dd80
jmp 0x408558
jmp 0x4084a8
movq %rax, %rbx
jmp 0x408541
jmp 0x4084c3
jmp 0x4084c3
movq %rax, %rbx
jmp 0x40850f
movq %rax, %rbx
jmp 0x4084f3
movq %rax, %rbx
jmp 0x4084e6
movq %rax, %rbx
jmp 0x408534
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4084e6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40dd80
leaq 0xc8(%rsp), %rdi
callq 0x404a8c
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x40850f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40dd80
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x408534
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x40dd80
leaq 0x120(%rsp), %rdi
callq 0x409a3a
leaq 0x50(%rsp), %rdi
callq 0x409a3a
leaq 0x88(%rsp), %rdi
callq 0x40877c
movq %rbx, %rdi
callq 0x4b7fb0