// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/events.c
// Function: hourly_events
void hourly_events(void) {
    if (!dawn->player_count) {
        return;
    }

    int event  = rand() % MAX_EVENT_TYPE;
    int player = rand() % dawn->player_count;

    while (dawn->players[player].available != 1) {
        player = rand() % dawn->player_count;
    }

    switch (event) {
        case 0:
            random_reward(dawn->players[player].username);
            break;
        case 1:
            random_punishment(dawn->players[player].username);
            break;
        case 2:
            random_shrine(dawn->players[player].username);
            break;
        case 3:
            call_monster(NULL, 1);
            break;
        case 4:
            update_weather();
            break;
        default:
            PRINTERR("INVALID EVENT")
    }

    for (int i = 0; i < dawn->player_count; i++) {
        dawn->players[i].fullness--;
    }

    //Sending -1 checks all users to see if they have starved
    check_famine(-1);
    fluctuate_market();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
leaq 0x20291(%rip), %rax     # 0x28a70
movq (%rax), %rax
cmpl $0x0, 0x148(%rax)
jne 0x87f0
jmp 0x897b
callq 0x2080
movl $0x5, %ecx
cltd
idivl %ecx
movl %edx, -0x4(%rbp)
callq 0x2080
leaq 0x20264(%rip), %rcx     # 0x28a70
movq (%rcx), %rcx
cltd
idivl 0x148(%rcx)
movl %edx, -0x8(%rbp)
leaq 0x20250(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x8(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpl $0x1, 0x2664(%rax)
je 0x885b
callq 0x2080
leaq 0x20224(%rip), %rcx     # 0x28a70
movq (%rcx), %rcx
cltd
idivl 0x148(%rcx)
movl %edx, -0x8(%rbp)
jmp 0x8819
movl -0x4(%rbp), %eax
movq %rax, -0x18(%rbp)
subq $0x4, %rax
ja 0x8909
movq -0x18(%rbp), %rax
leaq 0x14235(%rip), %rcx     # 0x1caac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x201e9(%rip), %rax     # 0x28a70
movq (%rax), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
movslq -0x8(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rdi
callq 0x8990
jmp 0x8915
leaq 0x201c3(%rip), %rax     # 0x28a70
movq (%rax), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
movslq -0x8(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rdi
callq 0x8ca0
jmp 0x8915
leaq 0x2019d(%rip), %rax     # 0x28a70
movq (%rax), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
movslq -0x8(%rbp), %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addq %rax, %rdi
callq 0x8fd0
jmp 0x8915
xorl %eax, %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x10780
jmp 0x8915
callq 0x93d0
jmp 0x8915
leaq 0x141b0(%rip), %rdi     # 0x1cac0
callq 0x2190
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0x2014a(%rip), %rcx     # 0x28a70
movq (%rcx), %rcx
cmpl 0x148(%rcx), %eax
jge 0x896c
leaq 0x20138(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0xc(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movw 0x26a2(%rax), %cx
addw $-0x1, %cx
movw %cx, 0x26a2(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x891c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x9550
callq 0xfbd0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)