// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/spells.c
// Function: cast_rain
void cast_rain(const char *username) {
    int pindex = get_pindex(username);
    char out[MAX_MESSAGE_BUFFER];

    if (!dawn->players[pindex].spellbook.rain.learned) {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s, you do not know this spell\r\n",
                 dawn->active_room, username);
        add_msg(out, strlen(out));
        return;
    }

    int rain_cost = 1 + dawn->players[pindex].spellbook.rain.level * 6;
    int rain_amount = 1 + rand() % (dawn->players[pindex].spellbook.rain.level * 6);

    if (dawn->players[pindex].mana >= rain_cost) {
        dawn->players[pindex].mana -= rain_cost;

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

        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s has conjured up a storm. Rain pours down "
                "upon the town, allowing the crops to flourish! Everyone's fullness +%d!\r\n",
                 dawn->active_room, username, rain_amount);
    } else {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s, you do not have enough mana to cast this spell\r\n",
                 dawn->active_room, username);
    }
    add_msg(out, strlen(out));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13ba0
movl %eax, -0xc(%rbp)
leaq 0x1298e(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0xc(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpl $0x0, 0x1164(%rax)
jne 0x1615f
leaq -0x1a0(%rbp), %rdi
leaq 0x12960(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x8(%rbp), %r8
movl $0x190, %esi            # imm = 0x190
leaq 0xac71(%rip), %rdx      # 0x20d9b
movb $0x0, %al
callq 0x2390
leaq -0x1a0(%rbp), %rax
movq %rax, -0x1b8(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x20c0
movq -0x1b8(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x16380
leaq 0x1290a(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0xc(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
imull $0x6, 0x115c(%rax), %eax
addl $0x1, %eax
movl %eax, -0x1a4(%rbp)
callq 0x2080
leaq 0x128d7(%rip), %rcx     # 0x28a70
movq (%rcx), %rcx
addq $0x1a0, %rcx            # imm = 0x1A0
movslq -0xc(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
addq %rdx, %rcx
imull $0x6, 0x115c(%rcx), %ecx
cltd
idivl %ecx
addl $0x1, %edx
movl %edx, -0x1a8(%rbp)
leaq 0x128a5(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0xc(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x2680(%rax), %eax
cmpl -0x1a4(%rbp), %eax
jl 0x16328
movl -0x1a4(%rbp), %edx
leaq 0x1286f(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0xc(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x2680(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x2680(%rax)
movl $0x0, -0x1ac(%rbp)
movl -0x1ac(%rbp), %eax
leaq 0x12833(%rip), %rcx     # 0x28a70
movq (%rcx), %rcx
cmpl 0x148(%rcx), %eax
jge 0x162f0
movl -0x1a8(%rbp), %edx
leaq 0x12817(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1ac(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movswl 0x26a2(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x26a2(%rax)
leaq 0x127e6(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1ac(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movswl 0x26a2(%rax), %eax
cmpl $0x64, %eax
jl 0x162da
leaq 0x127b9(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1ac(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movw $0x64, 0x26a2(%rax)
jmp 0x162dc
movl -0x1ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ac(%rbp)
jmp 0x16230
leaq -0x1a0(%rbp), %rdi
leaq 0x12772(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x8(%rbp), %r8
movl -0x1a8(%rbp), %r9d
movl $0x190, %esi            # imm = 0x190
leaq 0xade6(%rip), %rdx      # 0x21105
movb $0x0, %al
callq 0x2390
jmp 0x16357
leaq -0x1a0(%rbp), %rdi
leaq 0x1273a(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x8(%rbp), %r8
movl $0x190, %esi            # imm = 0x190
leaq 0xae37(%rip), %rdx      # 0x21187
movb $0x0, %al
callq 0x2390
leaq -0x1a0(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x20c0
movq -0x1c0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
nopl (%rax)