// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq 0x4b3b(%rip), %rdi      # 0x6fd0
leaq 0x1b68(%rip), %rsi      # 0x4004
callq 0x2190
movq %rax, %rdi
callq 0x20a0
movq %rax, %rdi
callq 0x20a0
andq $0x0, -0x30(%rbp)
leaq -0xc8(%rbp), %rsi
andq $0x0, 0x8(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
leaq 0x2e0(%rip), %rax       # 0x27b0
movq %rax, (%rsi)
leaq 0xb96(%rip), %r14       # 0x3070
movq %r14, 0x18(%rsi)
leaq 0xb99(%rip), %r15       # 0x307e
movq %r15, 0x10(%rsi)
leaq -0xf8(%rbp), %rdi
callq 0x2a6a
leaq -0xc8(%rbp), %rbx
movq %rbx, %rdi
callq 0x2a90
andq $0x0, 0x8(%rbx)
leaq 0x2c0(%rip), %rax       # 0x27d0
movq %rax, (%rbx)
movq %r14, 0x18(%rbx)
movq %r15, 0x10(%rbx)
leaq -0x40(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x33fa
movq %rbx, %rdi
callq 0x2a90
andq $0x0, 0x8(%rbx)
leaq 0x43a(%rip), %rax       # 0x2979
movq %rax, (%rbx)
movq %r14, 0x18(%rbx)
movq %r15, 0x10(%rbx)
leaq -0x40(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x33fa
leaq -0xc8(%rbp), %rdi
callq 0x2a90
leaq -0x40(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x331c
movq 0x4a53(%rip), %rdi      # 0x6fd0
leaq 0x1a98(%rip), %rsi      # 0x401c
callq 0x2190
movq -0x38(%rbp), %rsi
subq -0x40(%rbp), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x20a0
leaq -0x4c(%rbp), %rsi
movl $0x1, (%rsi)
leaq 0x1a82(%rip), %rdx      # 0x4038
movq %rbx, %rdi
callq 0x2ab0
leaq -0xa0(%rbp), %r15
leaq -0x48(%rbp), %rsi
movl $0x2, (%rsi)
leaq 0x1a6c(%rip), %rdx      # 0x4042
movq %r15, %rdi
callq 0x2ab0
leaq -0x78(%rbp), %r15
leaq -0x44(%rbp), %rsi
movl $0x3, (%rsi)
leaq 0x1a59(%rip), %rdx      # 0x404c
movq %r15, %rdi
callq 0x2ab0
leaq -0x128(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
pushq $0x3
popq %rdx
leaq -0x22(%rbp), %rcx
leaq -0x21(%rbp), %r8
callq 0x2ad6
pushq $0x58
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0xc8, %rdi
callq 0x2090
addq $-0x28, %rbx
cmpq $-0x20, %rbx
jne 0x261c
pushq $0x30
popq %rdi
callq 0x21a0
movq %rax, %rbx
pushq $0x64
popq %rsi
leaq -0x128(%rbp), %rdx
movq %rax, %rdi
callq 0x3a74
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x33d8
movq 0x496a(%rip), %rdi      # 0x6fd0
callq 0x20a0
leaq 0x19e4(%rip), %rsi      # 0x4056
movq %rax, %rdi
callq 0x2190
movq %rax, %rdi
callq 0x20a0
leaq -0x40(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x3448
movq 0x4937(%rip), %rdi      # 0x6fd0
callq 0x20a0
leaq 0x1977(%rip), %rsi      # 0x401c
movq %rax, %rdi
callq 0x2190
movq -0x38(%rbp), %rsi
subq -0x40(%rbp), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x20a0
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x33d8
callq 0x2a36
leaq -0x128(%rbp), %rdi
callq 0x2c54
leaq -0xf8(%rbp), %rdi
callq 0x2a90
leaq -0x40(%rbp), %rdi
callq 0x2cd0
xorl %eax, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
pushq $0x30
popq %rsi
movq %rbx, %rdi
callq 0x21b0
jmp 0x2787
movq %rax, %r14
pushq $0x58
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0xc8, %rdi
callq 0x2090
addq $-0x28, %rbx
cmpq $-0x20, %rbx
jne 0x2723
jmp 0x2793
jmp 0x2741
movq %rax, %r14
leaq -0x28(%r15), %r12
addq $-0x20, %r15
movq %r15, %rdi
callq 0x2090
movq %r12, %r15
cmpq %rbx, %r12
jne 0x2744
jmp 0x2793
jmp 0x277f
jmp 0x2762
movq %rax, %r14
leaq -0xc8(%rbp), %rdi
callq 0x2a90
jmp 0x2793
movq %rax, %r14
leaq -0xc8(%rbp), %rdi
jmp 0x279a
movq %rax, %r14
jmp 0x2793
movq %rax, %r14
leaq -0x128(%rbp), %rdi
callq 0x2c54
leaq -0xf8(%rbp), %rdi
callq 0x2a90
leaq -0x40(%rbp), %rdi
callq 0x2cd0
movq %r14, %rdi
callq 0x2250