// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xaa8, %rsp            # imm = 0xAA8
leaq 0x1978c(%rip), %r13     # 0x1fa80
movq (%r13), %rax
cmpl $0x0, 0x148(%rax)
je 0x68fd
callq 0x2080
movl %eax, %ebx
callq 0x2080
movq (%r13), %rcx
cltd
idivl 0x148(%rcx)
movslq %edx, %rax
imulq $0x26a8, %rax, %rsi     # imm = 0x26A8
cmpl $0x1, 0x2804(%rcx,%rsi)
jne 0x630c
pushq $0x5
popq %rdi
movl %ebx, %eax
cltd
idivl %edi
cmpl $0x4, %edx
ja 0x690f
leaq (%rcx,%rsi), %rbx
addq $0x1a0, %rbx            # imm = 0x1A0
leaq 0xc751(%rip), %rax      # 0x12aa4
movslq (%rax,%rdx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %rbx, %rdi
callq 0xc860
movl %eax, %r14d
callq 0x2080
pushq $0x3
popq %rcx
cltd
idivl %ecx
movl %edx, %ebp
cmpl $0x2, %edx
je 0x6654
cmpl $0x1, %ebp
je 0x66e4
testl %ebp, %ebp
jne 0x6921
callq 0x2080
movq (%r13), %rcx
movslq %r14d, %r15
imulq $0x26a8, %r15, %rsi     # imm = 0x26A8
imull $0x4b, 0x2808(%rcx,%rsi), %edi
cltd
idivl %edi
movslq %edx, %rax
leal 0x1(%rdx), %r8d
movq 0x27e8(%rcx,%rsi), %rdx
addq %rdx, %rax
incq %rax
movq %rax, 0x27e8(%rcx,%rsi)
addq $0x100, %rcx            # imm = 0x100
leaq 0xc8aa(%rip), %rsi      # 0x12c81
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rcx, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
jmp 0x6745
callq 0x6946
jmp 0x68c2
movq %rbx, %rdi
callq 0xc860
movl %eax, %ebp
callq 0x2080
pushq $0x3
popq %rcx
cltd
idivl %ecx
cmpl $0x2, %edx
je 0x652b
cmpl $0x1, %edx
je 0x65d8
testl %edx, %edx
jne 0x6918
movq (%r13), %rdx
movslq %ebp, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
movslq 0x2810(%rdx,%rax), %rcx
movq %rcx, 0x27f0(%rdx,%rax)
movl 0x2814(%rdx,%rax), %ecx
movl %ecx, 0x2820(%rdx,%rax)
addq $0x100, %rdx            # imm = 0x100
leaq 0xcbb0(%rip), %rsi      # 0x13014
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2050
jmp 0x6644
pushq $0x1
popq %rsi
xorl %edi, %edi
callq 0xab2c
jmp 0x68c2
movq %rbx, %rdi
callq 0xc860
movl %eax, %ebp
callq 0x2080
pushq $0x3
popq %rcx
cltd
idivl %ecx
cmpl $0x2, %edx
je 0x668e
cmpl $0x1, %edx
je 0x6823
testl %edx, %edx
jne 0x6935
callq 0x2080
pushq $0x19
popq %rcx
cltd
idivl %ecx
movl %edx, %r15d
incl %r15d
leaq 0x16d90(%rip), %rax     # 0x1d264
movl (%rax), %edx
leaq 0x1a0(%rsp), %rdi
movq %rbx, %rsi
callq 0x20e0
leaq 0x260(%rsp), %rdi
movq (%r13), %r14
leaq 0x100(%r14), %r12
leaq 0x16d60(%rip), %rax     # 0x1d260
movl (%rax), %edx
movq %r12, %rsi
callq 0x20e0
movslq %r15d, %r8
movslq %ebp, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
subq %r8, 0x27f0(%r14,%rax)
leaq 0xc992(%rip), %rsi      # 0x12eb8
jmp 0x688d
callq 0x2080
movq (%r13), %r12
movslq %ebp, %rcx
imulq $0x26a8, %rcx, %rbp     # imm = 0x26A8
imull $0xa, 0x2808(%r12,%rbp), %ecx
cltd
idivl %ecx
movl %edx, %r14d
leal 0x1(%r14), %eax
movl %eax, 0xc(%rsp)
leaq 0x16d08(%rip), %rax     # 0x1d264
movl (%rax), %edx
leaq 0x1a0(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x20e0
leaq 0x260(%rsp), %rdi
leaq 0x100(%r12), %rsi
leaq 0x16cd8(%rip), %rax     # 0x1d260
movl (%rax), %edx
callq 0x20e0
movslq %r14d, %rax
movq 0x27f8(%r12,%rbp), %rcx
addq %rcx, %rax
incq %rax
movq %rax, 0x27f8(%r12,%rbp)
movq %r15, %rdi
callq 0xd117
leaq 0xcb2a(%rip), %rsi      # 0x130e1
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x260(%rsp), %rdx
movq %rbx, %rcx
movl 0xc(%rsp), %r8d
xorl %eax, %eax
callq 0x2050
jmp 0x6644
movq (%r13), %rdx
movslq %ebp, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
movq 0x27f0(%rdx,%rax), %rsi
addq $0xf, %rsi
movq %rsi, 0x27f0(%rdx,%rax)
movslq 0x2810(%rdx,%rax), %rcx
cmpq %rcx, %rsi
jl 0x6617
addq %rdx, %rax
addq $0x1a0, %rax            # imm = 0x1A0
movq %rcx, 0x2650(%rax)
addq $0x100, %rdx            # imm = 0x100
movl $0xf, (%rsp)
leaq 0xca3e(%rip), %rsi      # 0x1306a
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
movq %rbx, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
callq 0x20c0
movq %r14, %rdi
jmp 0x6816
movq (%r13), %rdx
movslq %r14d, %r15
imulq $0x26a8, %r15, %rax     # imm = 0x26A8
incl 0x283c(%rdx,%rax)
addq $0x100, %rdx            # imm = 0x100
leaq 0xc74c(%rip), %rsi      # 0x12dc3
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
jmp 0x6745
movq (%r13), %rdx
movslq %ebp, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addw $-0x5, 0x2842(%rdx,%rax)
addq $0x100, %rdx            # imm = 0x100
leaq 0xc895(%rip), %rsi      # 0x12f48
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
callq 0x20c0
movq %r14, %rdi
movq %rax, %rsi
callq 0xbd04
movl %ebp, %edi
callq 0x6a28
jmp 0x68c2
callq 0x2080
movq (%r13), %rcx
movslq %r14d, %r15
imulq $0x26a8, %r15, %rsi     # imm = 0x26A8
imull $0x7d, 0x2808(%rcx,%rsi), %edi
cltd
idivl %edi
movslq %edx, %rax
leal 0x1(%rdx), %r9d
movq 0x27e8(%rcx,%rsi), %rdx
addq %rdx, %rax
incq %rax
movq %rax, 0x27e8(%rcx,%rsi)
addq $0x100, %rcx            # imm = 0x100
leaq 0xc5e2(%rip), %rsi      # 0x12d0f
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rcx, %rdx
movq %rbx, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
callq 0x20c0
movq %r14, %rdi
movq %rax, %rsi
callq 0xbd04
movq (%r13), %rsi
imulq $0x26a8, %r15, %rax     # imm = 0x26A8
leaq (%rsi,%rax), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x22e0
cmpl $0x1, %ebp
ja 0x68c2
testl %eax, %eax
jne 0x68c2
callq 0x2080
movq (%r13), %rbx
cltd
idivl 0x148(%rbx)
movslq %edx, %rax
imulq $0x26a8, %rax, %r12     # imm = 0x26A8
cmpl $0x1, 0x2804(%rbx,%r12)
jne 0x6784
leaq (%rbx,%r12), %r14
addq $0x1a0, %r14            # imm = 0x1A0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x22e0
testl %eax, %eax
je 0x6784
leaq 0x100(%rbx), %rdx
movq 0x27e8(%rbx), %r9
leaq 0xc68e(%rip), %rsi      # 0x12e66
leaq 0x1a0(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x2050
movq (%r13), %rax
movq 0x27e8(%rax), %rcx
addq %rcx, 0x27e8(%rax,%r12)
andq $0x0, 0x27e8(%rax)
movq %r15, %rdi
callq 0x20c0
movq %r15, %rdi
movq %rax, %rsi
callq 0xbd04
jmp 0x68c2
callq 0x2080
pushq $0x2d
popq %rcx
cltd
idivl %ecx
movl %edx, %r15d
incl %r15d
leaq 0x16a29(%rip), %rax     # 0x1d264
movl (%rax), %edx
leaq 0x1a0(%rsp), %rdi
movq %rbx, %rsi
callq 0x20e0
leaq 0x260(%rsp), %rdi
movq (%r13), %r14
leaq 0x100(%r14), %r12
leaq 0x169f9(%rip), %rax     # 0x1d260
movl (%rax), %edx
movq %r12, %rsi
callq 0x20e0
movslq %r15d, %r8
movslq %ebp, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
subq %r8, 0x27f0(%r14,%rax)
leaq 0xc67b(%rip), %rsi      # 0x12f08
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
movq %r15, %rdi
callq 0x20c0
movq %r15, %rdi
movq %rax, %rsi
callq 0xbd04
leaq 0x1a0(%rsp), %rdi
callq 0x3824
movq (%r13), %rax
movl 0x148(%rax), %edx
xorl %ecx, %ecx
testl %edx, %edx
cmovlel %ecx, %edx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
cmpq %rcx, %rdx
je 0x68f0
decw 0x2842(%rax,%rcx)
addq $0x26a8, %rcx           # imm = 0x26A8
jmp 0x68da
pushq $-0x1
popq %rdi
callq 0x6a28
callq 0xa584
addq $0xaa8, %rsp            # imm = 0xAA8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc1a2(%rip), %rdi      # 0x12ab8
jmp 0x693c
leaq 0xc86e(%rip), %rdi      # 0x1318d
jmp 0x693c
leaq 0xc50a(%rip), %rdi      # 0x12e32
callq 0x2190
movslq %r14d, %r15
jmp 0x6758
leaq 0xc6a0(%rip), %rdi      # 0x12fdc
callq 0x2190
jmp 0x68c2