// File: hugosantos[P]dbeacon/dbeacon.cpp
// Function: handle_single_event()
static void handle_single_event() {
	timer t = *timers.begin();
	timers.erase(timers.begin());

	switch (t.type) {
	case SENDING_EVENT:
		send_probe();
		send_count++;
		break;
	case SSM_SENDING_EVENT:
		send_ssm_probe();
		send_ssm_count++;
		break;
	case REPORT_EVENT:
	case SSM_REPORT_EVENT:
	case MAP_REPORT_EVENT:
	case WEBSITE_REPORT_EVENT:
		send_report(t.type);
		break;
	case GARBAGE_COLLECT_EVENT:
		handle_gc();
		break;
	case DUMP_EVENT:
		do_dump();
		break;
	case DUMP_BW_EVENT:
	case DUMP_BIG_BW_EVENT:
		do_bw_dump(t.type == DUMP_BIG_BW_EVENT);
		break;
	}

	if (t.type == WILLSEND_EVENT) {
		insert_event(SENDING_EVENT, 100);
		send_count = 0;
	} else if (t.type == WILLSEND_SSM_EVENT) {
		insert_event(SSM_SENDING_EVENT, 100);
		send_ssm_count = 0;
	} else if (t.type == SENDING_EVENT && send_count == probeBurstLength) {
		insert_event(WILLSEND_EVENT, timeFact(1, true));
	} else if (t.type == SSM_SENDING_EVENT && send_ssm_count == probeBurstLength) {
		insert_event(WILLSEND_SSM_EVENT, timeFact(1, true));
	} else if (t.type == REPORT_EVENT) {
		insert_event(REPORT_EVENT, timeFact(reportI));
	} else if (t.type == SSM_REPORT_EVENT) {
		insert_event(SSM_REPORT_EVENT, timeFact(ssmReportI));
	} else if (t.type == MAP_REPORT_EVENT) {
		insert_event(MAP_REPORT_EVENT, timeFact(mapReportI));
	} else if (t.type == WEBSITE_REPORT_EVENT) {
		insert_event(WEBSITE_REPORT_EVENT, timeFact(websiteReportI));
	} else {
		insert_sorted_event(t);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0x20aa9(%rip), %rdi     # 0x29928
movq %rdi, -0x40(%rbp)
callq 0xb020
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
callq 0xf3e0
movq -0x40(%rbp), %rdi
movl 0x8(%rax), %ecx
movl %ecx, -0x8(%rbp)
movq (%rax), %rax
movq %rax, -0x10(%rbp)
callq 0xb020
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xb1b0
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xf400
movq %rax, -0x30(%rbp)
movl -0x10(%rbp), %eax
movq %rax, -0x38(%rbp)
subq $0x55, %rax
ja 0x8f44
movq -0x38(%rbp), %rax
leaq 0x1221b(%rip), %rcx     # 0x1b100
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x9090
movl 0x22aa7(%rip), %eax     # 0x2b9a0
addl $0x1, %eax
movl %eax, 0x22a9e(%rip)     # 0x2b9a0
jmp 0x8f44
callq 0x90e0
movl 0x22a95(%rip), %eax     # 0x2b9a4
addl $0x1, %eax
movl %eax, 0x22a8c(%rip)     # 0x2b9a4
jmp 0x8f44
movl -0x10(%rbp), %edi
callq 0x63b0
jmp 0x8f44
callq 0x9130
jmp 0x8f44
callq 0x9340
jmp 0x8f44
cmpl $0x3, -0x10(%rbp)
sete %al
movzbl %al, %edi
andl $0x1, %edi
callq 0xa450
cmpl $0x5, -0x10(%rbp)
jne 0x8f68
movl $0x4, %edi
movl $0x64, %esi
callq 0x5fd0
movl $0x0, 0x22a3d(%rip)     # 0x2b9a0
jmp 0x907b
cmpl $0x7, -0x10(%rbp)
jne 0x8f8c
movl $0x6, %edi
movl $0x64, %esi
callq 0x5fd0
movl $0x0, 0x22a1d(%rip)     # 0x2b9a4
jmp 0x9079
cmpl $0x4, -0x10(%rbp)
jne 0x8fb8
cmpl $0xa, 0x22a07(%rip)     # 0x2b9a0
jne 0x8fb8
movl $0x1, %esi
movl %esi, %edi
callq 0x6cc0
movl %eax, %esi
movl $0x5, %edi
callq 0x5fd0
jmp 0x9077
cmpl $0x6, -0x10(%rbp)
jne 0x8fe4
cmpl $0xa, 0x229df(%rip)     # 0x2b9a4
jne 0x8fe4
movl $0x1, %esi
movl %esi, %edi
callq 0x6cc0
movl %eax, %esi
movl $0x7, %edi
callq 0x5fd0
jmp 0x9075
cmpl $0x52, -0x10(%rbp)
jne 0x9004
movl $0x2, %edi
xorl %esi, %esi
callq 0x6cc0
movl %eax, %esi
movl $0x52, %edi
callq 0x5fd0
jmp 0x9073
cmpl $0x53, -0x10(%rbp)
jne 0x9024
movl $0x4, %edi
xorl %esi, %esi
callq 0x6cc0
movl %eax, %esi
movl $0x53, %edi
callq 0x5fd0
jmp 0x9071
cmpl $0x54, -0x10(%rbp)
jne 0x9044
movl $0x6, %edi
xorl %esi, %esi
callq 0x6cc0
movl %eax, %esi
movl $0x54, %edi
callq 0x5fd0
jmp 0x906f
cmpl $0x55, -0x10(%rbp)
jne 0x9064
movl $0x18, %edi
xorl %esi, %esi
callq 0x6cc0
movl %eax, %esi
movl $0x55, %edi
callq 0x5fd0
jmp 0x906d
leaq -0x10(%rbp), %rdi
callq 0x6ae0
jmp 0x906f
jmp 0x9071
jmp 0x9073
jmp 0x9075
jmp 0x9077
jmp 0x9079
jmp 0x907b
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)