// File: /workspace/github_c_makefile_star2_O3/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 0x1a9e8(%rip), %r13     # 0x21a80
movq (%r13), %rax
cmpl $0x0, 0x148(%rax)
je 0x7739
callq 0x2080
movslq %eax, %r14
imulq $0x66666667, %r14, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x21, %rax
addl %ecx, %eax
leal (%rax,%rax,4), %eax
subl %eax, %r14d
callq 0x2080
movq (%r13), %rcx
cltd
idivl 0x148(%rcx)
movslq %edx, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
cmpl $0x1, 0x2804(%rcx,%rax)
jne 0x70cb
leaq (%rcx,%rax), %rbx
addq $0x1a0, %rbx            # imm = 0x1A0
cmpl $0x4, %r14d
ja 0x774b
movl %r14d, %eax
leaq 0xc9ce(%rip), %rcx      # 0x13adc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0xda6c
movl %eax, %ebp
callq 0x2080
movslq %eax, %r15
imulq $0x55555556, %r15, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
leal (%rax,%rax,2), %eax
subl %eax, %r15d
cmpl $0x2, %r15d
je 0x746f
cmpl $0x1, %r15d
je 0x74ff
testl %r15d, %r15d
jne 0x775d
callq 0x2080
movq (%r13), %rcx
movslq %ebp, %r12
imulq $0x26a8, %r12, %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 0xcb10(%rip), %rsi      # 0x13cb9
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rcx, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
jmp 0x7560
callq 0x7782
jmp 0x76fd
movq %rbx, %rdi
callq 0xda6c
movl %eax, %ebp
callq 0x2080
cltq
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
cmpl $0x2, %eax
je 0x7342
cmpl $0x1, %eax
je 0x73f3
testl %eax, %eax
jne 0x7754
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 0xce01(%rip), %rsi      # 0x1404c
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2050
jmp 0x745f
xorl %edi, %edi
movl $0x1, %esi
callq 0xbb54
jmp 0x76fd
movq %rbx, %rdi
callq 0xda6c
movl %eax, %ebp
callq 0x2080
cltq
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
cmpl $0x2, %eax
je 0x74a9
cmpl $0x1, %eax
je 0x7642
testl %eax, %eax
jne 0x7771
callq 0x2080
cltq
imulq $0x51eb851f, %rax, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x23, %rcx
addl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
leal (%rcx,%rcx,4), %ecx
negl %ecx
leal (%rax,%rcx), %r12d
incl %r12d
leaq 0x17f79(%rip), %rax     # 0x1f264
movl (%rax), %edx
leaq 0x1a0(%rsp), %rdi
movq %rbx, %rsi
callq 0x20e0
leaq 0x260(%rsp), %rdi
movq (%r13), %r14
leaq 0x100(%r14), %r15
leaq 0x17f49(%rip), %rax     # 0x1f260
movl (%rax), %edx
movq %r15, %rsi
callq 0x20e0
movslq %r12d, %r8
movslq %ebp, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
subq %r8, 0x27f0(%r14,%rax)
leaq 0xcbb3(%rip), %rsi      # 0x13ef0
jmp 0x76c8
callq 0x2080
movq (%r13), %r12
movslq %ebp, %rcx
imulq $0x26a8, %rcx, %rbp     # imm = 0x26A8
movl 0x2808(%r12,%rbp), %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
cltd
idivl %ecx
movl %edx, %r14d
leal 0x1(%r14), %eax
movl %eax, 0xc(%rsp)
leaq 0x17eed(%rip), %rax     # 0x1f264
movl (%rax), %edx
leaq 0x1a0(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x20e0
leaq 0x260(%rsp), %rdi
leaq 0x100(%r12), %rsi
leaq 0x17ebd(%rip), %rax     # 0x1f260
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 0xe32c
leaq 0xcd47(%rip), %rsi      # 0x14119
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x260(%rsp), %rdx
movq %rbx, %rcx
movl 0xc(%rsp), %r8d
xorl %eax, %eax
callq 0x2050
jmp 0x745f
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 0x7432
addq %rdx, %rax
addq $0x1a0, %rax            # imm = 0x1A0
movq %rcx, 0x2650(%rax)
addq $0x100, %rdx            # imm = 0x100
movl $0xf, (%rsp)
leaq 0xcc5b(%rip), %rsi      # 0x140a2
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 0x7635
movq (%r13), %rdx
movslq %ebp, %r12
imulq $0x26a8, %r12, %rax     # imm = 0x26A8
incl 0x283c(%rdx,%rax)
addq $0x100, %rdx            # imm = 0x100
leaq 0xc969(%rip), %rsi      # 0x13dfb
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
jmp 0x7560
movq (%r13), %rdx
movslq %ebp, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addw $-0x5, 0x2842(%rdx,%rax)
addq $0x100, %rdx            # imm = 0x100
leaq 0xcab2(%rip), %rsi      # 0x13f80
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 0xcefe
movl %ebp, %edi
callq 0x7893
jmp 0x76fd
callq 0x2080
movq (%r13), %rcx
movslq %ebp, %r12
imulq $0x26a8, %r12, %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 0xc7ff(%rip), %rsi      # 0x13d47
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 0xcefe
movq (%r13), %rsi
imulq $0x26a8, %r12, %rax     # imm = 0x26A8
leaq (%rsi,%rax), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x22d0
cmpl $0x1, %r15d
ja 0x76fd
testl %eax, %eax
jne 0x76fd
callq 0x2080
movq (%r13), %rbx
cltd
idivl 0x148(%rbx)
movslq %edx, %rax
imulq $0x26a8, %rax, %r12     # imm = 0x26A8
cmpl $0x1, 0x2804(%rbx,%r12)
jne 0x75a0
leaq (%rbx,%r12), %r14
addq $0x1a0, %r14            # imm = 0x1A0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x22d0
testl %eax, %eax
je 0x75a0
leaq 0x100(%rbx), %rdx
movq 0x27e8(%rbx), %r9
leaq 0xc8aa(%rip), %rsi      # 0x13e9e
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)
movq $0x0, 0x27e8(%rax)
movq %r15, %rdi
callq 0x20c0
movq %r15, %rdi
movq %rax, %rsi
callq 0xcefe
jmp 0x76fd
callq 0x2080
cltq
imulq $-0x49f49f49, %rax, %rcx # imm = 0xB60B60B7
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x5, %ecx
addl %edx, %ecx
leal (%rcx,%rcx,8), %ecx
leal (%rcx,%rcx,4), %ecx
negl %ecx
leal (%rax,%rcx), %r12d
incl %r12d
leaq 0x17bee(%rip), %rax     # 0x1f264
movl (%rax), %edx
leaq 0x1a0(%rsp), %rdi
movq %rbx, %rsi
callq 0x20e0
leaq 0x260(%rsp), %rdi
movq (%r13), %r14
leaq 0x100(%r14), %r15
leaq 0x17bbe(%rip), %rax     # 0x1f260
movl (%rax), %edx
movq %r15, %rsi
callq 0x20e0
movslq %r12d, %r8
movslq %ebp, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
subq %r8, 0x27f0(%r14,%rax)
leaq 0xc878(%rip), %rsi      # 0x13f40
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
movq %r12, %rdi
callq 0x20c0
movq %r12, %rdi
movq %rax, %rsi
callq 0xcefe
leaq 0x1a0(%rsp), %rdi
callq 0x45bc
movq (%r13), %rax
movslq 0x148(%rax), %rcx
testq %rcx, %rcx
jle 0x772a
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
xorl %edx, %edx
decw 0x2842(%rax,%rdx)
addq $0x26a8, %rdx           # imm = 0x26A8
cmpq %rdx, %rcx
jne 0x7716
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x7893
callq 0xb5b0
addq $0xaa8, %rsp            # imm = 0xAA8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc39e(%rip), %rdi      # 0x13af0
jmp 0x7778
leaq 0xca6a(%rip), %rdi      # 0x141c5
jmp 0x7778
leaq 0xc706(%rip), %rdi      # 0x13e6a
callq 0x2190
movslq %ebp, %r12
jmp 0x7573
leaq 0xc89c(%rip), %rdi      # 0x14014
callq 0x2190
jmp 0x76fd