// File: /workspace/github_c_makefile_star2_O1/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 0x1aa44(%rip), %r13     # 0x21a80
movq (%r13), %rax
cmpl $0x0, 0x148(%rax)
je 0x76d7
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 0x706f
leaq (%rcx,%rax), %rbx
addq $0x1a0, %rbx            # imm = 0x1A0
cmpl $0x4, %r14d
ja 0x76e9
movl %r14d, %eax
leaq 0xc9f2(%rip), %rcx      # 0x13aa4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
callq 0xd89c
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
movslq %ebp, %r12
cmpl $0x2, %r15d
je 0x7413
cmpl $0x1, %r15d
je 0x74a0
testl %r15d, %r15d
jne 0x76fb
callq 0x2080
movq (%r13), %rcx
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 0xcb34(%rip), %rsi      # 0x13c81
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rcx, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
jmp 0x74fe
callq 0x771a
jmp 0x769b
movq %rbx, %rdi
callq 0xd89c
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 0x72e6
cmpl $0x1, %eax
je 0x7397
testl %eax, %eax
jne 0x76f2
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 0xce25(%rip), %rsi      # 0x14014
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x2050
jmp 0x7403
xorl %edi, %edi
movl $0x1, %esi
callq 0xba54
jmp 0x769b
movq %rbx, %rdi
callq 0xd89c
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 0x744a
cmpl $0x1, %eax
je 0x75e0
testl %eax, %eax
jne 0x770c
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 0x17fd5(%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 0x17fa5(%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 0xcbd7(%rip), %rsi      # 0x13eb8
jmp 0x7666
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 0x17f49(%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 0x17f19(%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 0xe0ef
leaq 0xcd6b(%rip), %rsi      # 0x140e1
leaq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x260(%rsp), %rdx
movq %rbx, %rcx
movl 0xc(%rsp), %r8d
xorl %eax, %eax
callq 0x2050
jmp 0x7403
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 0x73d6
addq %rdx, %rax
addq $0x1a0, %rax            # imm = 0x1A0
movq %rcx, 0x2650(%rax)
addq $0x100, %rdx            # imm = 0x100
movl $0xf, (%rsp)
leaq 0xcc7f(%rip), %rsi      # 0x1406a
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 0x75d3
movq (%r13), %rdx
imulq $0x26a8, %r12, %rax     # imm = 0x26A8
incl 0x283c(%rdx,%rax)
addq $0x100, %rdx            # imm = 0x100
leaq 0xc990(%rip), %rsi      # 0x13dc3
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2050
jmp 0x74fe
movq (%r13), %rdx
movslq %ebp, %rax
imulq $0x26a8, %rax, %rax     # imm = 0x26A8
addw $-0x5, 0x2842(%rdx,%rax)
addq $0x100, %rdx            # imm = 0x100
leaq 0xcad9(%rip), %rsi      # 0x13f48
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 0xcd1c
movl %ebp, %edi
callq 0x782b
jmp 0x769b
callq 0x2080
movq (%r13), %rcx
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 0xc829(%rip), %rsi      # 0x13d0f
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 0xcd1c
movq (%r13), %rsi
imulq $0x26a8, %r12, %rax     # imm = 0x26A8
leaq (%rsi,%rax), %rdi
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x22d0
cmpl $0x1, %r15d
ja 0x769b
testl %eax, %eax
jne 0x769b
callq 0x2080
movq (%r13), %rbx
cltd
idivl 0x148(%rbx)
movslq %edx, %rax
imulq $0x26a8, %rax, %r12     # imm = 0x26A8
cmpl $0x1, 0x2804(%rbx,%r12)
jne 0x753e
leaq (%rbx,%r12), %r14
addq $0x1a0, %r14            # imm = 0x1A0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x22d0
testl %eax, %eax
je 0x753e
leaq 0x100(%rbx), %rdx
movq 0x27e8(%rbx), %r9
leaq 0xc8d4(%rip), %rsi      # 0x13e66
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 0xcd1c
jmp 0x769b
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 0x17c50(%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 0x17c20(%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 0xc8a2(%rip), %rsi      # 0x13f08
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 0xcd1c
leaq 0x1a0(%rsp), %rdi
callq 0x4564
movq (%r13), %rax
movslq 0x148(%rax), %rcx
testq %rcx, %rcx
jle 0x76c8
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
xorl %edx, %edx
decw 0x2842(%rax,%rdx)
addq $0x26a8, %rdx           # imm = 0x26A8
cmpq %rdx, %rcx
jne 0x76b4
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x782b
callq 0xb498
addq $0xaa8, %rsp            # imm = 0xAA8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc3c8(%rip), %rdi      # 0x13ab8
jmp 0x7713
leaq 0xca94(%rip), %rdi      # 0x1418d
jmp 0x7713
leaq 0xc730(%rip), %rdi      # 0x13e32
callq 0x2190
jmp 0x7511
leaq 0xc8c9(%rip), %rdi      # 0x13fdc
callq 0x2190
jmp 0x769b