// File: /workspace/github_c_makefile_star2_O3/Ziddykins[P]Dawn/src/status.c
// Function: event_handler
void event_handler(int sig) {
    assert(sig == SIGALRM);
    struct event * e;
    do {
        e = retr_event(); //handle event
        switch (e->event) {
            case MSGSEND:
            {
                pop_hist_msg();
                process_messages();
                break;
            }
            case HEALING:
            {
                int j;
                for (j=0; j < dawn->player_count; j++) {
                    if ((dawn->players[j].health + 5) <= dawn->players[j].max_health) {
                        dawn->players[j].health += 5;
                    } else {
                        dawn->players[j].health = dawn->players[j].max_health;
                    }
                }
                add_event(HEALING, 0, HEALING_INTERVAL, NORMAL);
                break;
            }
            case SAVING:
            {
                persistent_save();
                add_event(SAVING, 0, SAVING_INTERVAL, NORMAL);
                break;
            }
            case HOURLY:
            {
                hourly_events();
                add_event(HOURLY, 0, 3600, NORMAL);
                break;
            }
            case TRAVEL:
            {
                if(dawn->players[e->data].travel_timer.active) {
                    char out[MAX_MESSAGE_BUFFER];
                    dawn->players[e->data].pos_x = dawn->players[e->data].travel_timer.pos.x;
                    dawn->players[e->data].pos_y = dawn->players[e->data].travel_timer.pos.y;
                    sprintf(out, "PRIVMSG %s :%s has arrived at %d,%d\r\n", dawn->active_room, dawn->players[e->data].username,
                            dawn->players[e->data].pos_x, dawn->players[e->data].pos_y);
                    add_msg(out, strlen(out));
                    dawn->players[e->data].travel_timer.active = 0;
                    //check_special_location(dawn, e->data); DEPRECATED
                }
                break;
            }
            case LOTTERY_COLLECT:
            {
                lottery_collect();
                add_event(LOTTERY_COLLECT, 0, LOTTERY_COLLECT_INTERVAL, NORMAL);
                break;
            }
            case LOTTERY_REWARD:
            {
                lottery_reward();
                add_event(LOTTERY_REWARD, 0, LOTTERY_REWARD_INTERVAL, NORMAL);
                break;
            }
            case BOUNTY_RESET:
            {
                dawn->gbounty.amount = 0;
                gen_global_bounty();
                add_event(BOUNTY_RESET, 0, BOUNTY_RESET_INTERVAL, NORMAL);
                break;
            }
            case BOUNTY_INIT:
            {

                memset(&dawn->gbounty, 0, sizeof(dawn->gbounty));
                gen_global_bounty();
                break;
            }
        }
        free(e);
    } while(is_next_due());
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
cmpl $0xe, %edi
jne 0xf5b2
leaq 0x8ea1(%rip), %r12      # 0x18264
leaq 0x909b(%rip), %rbx      # 0x18465
movq %rsp, %r14
callq 0xfb51
movq %rax, %r15
movl (%rax), %eax
cmpq $0x8, %rax
ja 0xf554
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x1268f(%rip), %rax     # 0x21a80
movslq 0x148(%rax), %rcx
testq %rcx, %rcx
jle 0xf435
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
xorl %edx, %edx
movq 0x27f0(%rax,%rdx), %rsi
addq $0x5, %rsi
movslq 0x2810(%rax,%rdx), %rdi
cmpq %rdi, %rsi
cmovgeq %rdi, %rsi
movq %rsi, 0x27f0(%rax,%rdx)
addq $0x26a8, %rdx           # imm = 0x26A8
cmpq %rdx, %rcx
jne 0xf406
xorl %edi, %edi
jmp 0xf533
callq 0xd108
callq 0xcfbe
jmp 0xf554
callq 0x7080
movl $0x2, %edi
xorl %esi, %esi
movl $0xe10, %edx            # imm = 0xE10
jmp 0xf54d
movq 0x12618(%rip), %rdx     # 0x21a80
movslq 0x4(%r15), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
cmpl $0x0, 0x12ec(%rdx,%rax)
je 0xf554
leaq 0x1a0(%rdx), %rsi
leaq (%rsi,%rax), %rcx
movl 0x1144(%rsi,%rax), %r8d
movl 0x1148(%rsi,%rax), %r9d
movl %r8d, 0x25ec(%rsi,%rax)
movl %r9d, 0x25f0(%rsi,%rax)
addq $0x100, %rdx            # imm = 0x100
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
callq 0x20c0
movq %r14, %rdi
movq %rax, %rsi
callq 0xcefe
movq 0x125a6(%rip), %rax     # 0x21a80
movslq 0x4(%r15), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
movl $0x0, 0x12ec(%rax,%rcx)
jmp 0xf554
movq 0x12587(%rip), %rax     # 0x21a80
movl $0x0, 0x198(%rax)
callq 0x3758
movl $0x7, %edi
xorl %esi, %esi
movl $0x15180, %edx          # imm = 0x15180
jmp 0xf54d
callq 0xda24
movl $0x1, %edi
xorl %esi, %esi
movl $0x384, %edx            # imm = 0x384
jmp 0xf54d
callq 0x7989
movl $0x5, %edi
xorl %esi, %esi
movl $0x708, %edx            # imm = 0x708
jmp 0xf54d
callq 0x79fd
movl $0x6, %edi
xorl %esi, %esi
movl $0xa8c0, %edx           # imm = 0xA8C0
xorl %ecx, %ecx
callq 0xf887
movq %r15, %rdi
callq 0x2240
callq 0xfb90
testl %eax, %eax
jne 0xf3cd
jmp 0xf5a3
movq 0x1250e(%rip), %rax     # 0x21a80
xorps %xmm0, %xmm0
movups %xmm0, 0x188(%rax)
movups %xmm0, 0x178(%rax)
movups %xmm0, 0x168(%rax)
movups %xmm0, 0x158(%rax)
movq $0x0, 0x198(%rax)
callq 0x3758
jmp 0xf554
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x8e78(%rip), %rdi      # 0x18431
leaq 0x8e80(%rip), %rsi      # 0x18440
leaq 0x8e86(%rip), %rcx      # 0x1844d
movl $0xe8, %edx
callq 0x2100