// File: slafi[P]EventSystem/EventSystem/main.cpp
// Function: main
int main()
{
	cout << "Testing Event System..." << endl << endl;

	// Create a new event
	Event event{};

	// Create an event handler
	EventHandler event_handler(callback_3);

	// Add three event handlers
	event += callback_1;
	event += callback_2;	
	event.add_handler(event_handler);

	cout << "Registered event handlers: " << event.get_number_of_subscribed_handlers() << endl;

	// Create an EventArgs instance
	map<int, string> arg_list = { {1, "property1"}, {2, "property2"}, {3, "property3"} };
	int event_type = 100;

	EventArgs* args = new EventArgs(event_type, &arg_list);
	
	// Raise event
	event(args);

	cout << endl << "Event handler #3 will be discarded because it's napping!" << endl;

	// Remove second event handler
	event -= event_handler;

	cout << endl << "Registered event handlers: " << event.get_number_of_subscribed_handlers() << endl;

	// Raise event again
	event(args);

	// Pause console
	pause_console();
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movl $0x0, -0x4(%rbp)
movq 0xaa37(%rip), %rdi      # 0xcfd0
leaq 0x5a74(%rip), %rsi      # 0x8014
callq 0x21d0
movq %rax, %rdi
movq 0xaa09(%rip), %rsi      # 0xcfb8
movq %rsi, -0x1b0(%rbp)
callq 0x2210
movq -0x1b0(%rbp), %rsi
movq %rax, %rdi
callq 0x2210
xorps %xmm0, %xmm0
movaps %xmm0, -0x20(%rbp)
movq $0x0, -0x10(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x2f30
leaq 0x537(%rip), %rsi       # 0x2b20
leaq -0x70(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x2f50
movq -0x1a8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x2fe0
jmp 0x260b
leaq -0x70(%rbp), %rdi
callq 0x3030
leaq 0x545(%rip), %rsi       # 0x2b60
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x2f50
movq -0x1b8(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5ae0
jmp 0x2640
leaq -0xa0(%rbp), %rdi
callq 0x3030
leaq 0x7ad(%rip), %rsi       # 0x2e00
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x2f50
movq -0x1c0(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5ae0
jmp 0x2678
leaq -0xc0(%rbp), %rdi
callq 0x3030
leaq -0x20(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5940
jmp 0x2693
movq 0xa936(%rip), %rdi      # 0xcfd0
leaq 0x598b(%rip), %rsi      # 0x802c
callq 0x21d0
movq %rax, -0x1c8(%rbp)
jmp 0x26af
leaq -0x20(%rbp), %rdi
callq 0x3050
movq %rax, -0x1d0(%rbp)
jmp 0x26c1
movq -0x1d0(%rbp), %rsi
movq -0x1c8(%rbp), %rdi
callq 0x2060
movq %rax, -0x1d8(%rbp)
jmp 0x26dd
movq -0x1d8(%rbp), %rdi
movq 0xa8cd(%rip), %rsi      # 0xcfb8
callq 0x2210
jmp 0x26f2
leaq -0x178(%rbp), %rdi
movq %rdi, -0x180(%rbp)
movl $0x1, -0x184(%rbp)
leaq 0x5937(%rip), %rdx      # 0x8048
leaq -0x184(%rbp), %rsi
callq 0x3070
jmp 0x271f
leaq -0x150(%rbp), %rdi
movq %rdi, -0x180(%rbp)
movl $0x2, -0x188(%rbp)
leaq 0x5914(%rip), %rdx      # 0x8052
leaq -0x188(%rbp), %rsi
callq 0x3070
jmp 0x274c
leaq -0x128(%rbp), %rdi
movq %rdi, -0x180(%rbp)
movl $0x3, -0x18c(%rbp)
leaq 0x58f1(%rip), %rdx      # 0x805c
leaq -0x18c(%rbp), %rsi
callq 0x3070
jmp 0x2779
leaq -0x178(%rbp), %rax
movq %rax, -0x100(%rbp)
movq $0x3, -0xf8(%rbp)
leaq -0x18e(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x3110
movq -0x1e0(%rbp), %r8
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
leaq -0xf0(%rbp), %rdi
leaq -0x18d(%rbp), %rcx
callq 0x3130
jmp 0x27cf
leaq -0x18e(%rbp), %rdi
callq 0x3200
leaq -0x178(%rbp), %rax
movq %rax, -0x1f0(%rbp)
addq $0x78, %rax
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x30f0
movq -0x1f0(%rbp), %rcx
movq -0x1f8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1e8(%rbp)
jne 0x27f4
movl $0x64, -0x194(%rbp)
movl $0x30, %edi
callq 0x21e0
movq %rax, -0x200(%rbp)
jmp 0x2842
movq -0x200(%rbp), %rdi
movl -0x194(%rbp), %esi
leaq -0xf0(%rbp), %rdx
callq 0x7790
jmp 0x285d
movq -0x200(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5a80
jmp 0x287d
movq 0xa74c(%rip), %rdi      # 0xcfd0
movq 0xa72d(%rip), %rsi      # 0xcfb8
callq 0x2210
movq %rax, -0x208(%rbp)
jmp 0x2899
movq -0x208(%rbp), %rdi
leaq 0x57bf(%rip), %rsi      # 0x8066
callq 0x21d0
movq %rax, -0x210(%rbp)
jmp 0x28b5
movq -0x210(%rbp), %rdi
movq 0xa6f5(%rip), %rsi      # 0xcfb8
callq 0x2210
jmp 0x28ca
leaq -0x20(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5b50
jmp 0x28d9
movq 0xa6f0(%rip), %rdi      # 0xcfd0
movq 0xa6d1(%rip), %rsi      # 0xcfb8
callq 0x2210
movq %rax, -0x218(%rbp)
jmp 0x28f5
movq -0x218(%rbp), %rdi
leaq 0x5729(%rip), %rsi      # 0x802c
callq 0x21d0
movq %rax, -0x220(%rbp)
jmp 0x2911
leaq -0x20(%rbp), %rdi
callq 0x3050
movq %rax, -0x228(%rbp)
jmp 0x2923
movq -0x228(%rbp), %rsi
movq -0x220(%rbp), %rdi
callq 0x2060
movq %rax, -0x230(%rbp)
jmp 0x293f
movq -0x230(%rbp), %rdi
movq 0xa66b(%rip), %rsi      # 0xcfb8
callq 0x2210
jmp 0x2954
movq -0x1a0(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5a80
jmp 0x2966
callq 0x2ee0
jmp 0x296d
movl $0x0, -0x4(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x3220
leaq -0x50(%rbp), %rdi
callq 0x3240
leaq -0x20(%rbp), %rdi
callq 0x3260
movl -0x4(%rbp), %eax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3030
jmp 0x2b03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3030
jmp 0x2afa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x3030
jmp 0x2afa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x2afa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movq -0x180(%rbp), %rax
leaq -0x178(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x238(%rbp)
je 0x2a5a
movq -0x238(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x240(%rbp)
callq 0x30f0
movq -0x240(%rbp), %rax
leaq -0x178(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x238(%rbp)
jne 0x2a29
jmp 0x2afa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x18e(%rbp), %rdi
callq 0x3200
leaq -0x178(%rbp), %rax
movq %rax, -0x250(%rbp)
addq $0x78, %rax
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x258(%rbp)
callq 0x30f0
movq -0x250(%rbp), %rcx
movq -0x258(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x248(%rbp)
jne 0x2a90
jmp 0x2afa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x2aee
movq -0x200(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movl $0x30, %esi
callq 0x21f0
leaq -0xf0(%rbp), %rdi
callq 0x3220
leaq -0x50(%rbp), %rdi
callq 0x3240
leaq -0x20(%rbp), %rdi
callq 0x3260
movq -0x78(%rbp), %rdi
callq 0x22f0
nopw %cs:(%rax,%rax)