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

    if (tindex == -1) {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :Invalid target\r\n", dawn->active_room);
        add_msg(out, strlen(out));
        return;
    }

    if (!dawn->players[pindex].spellbook.revive.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;
    }

    if (dawn->players[tindex].alive) {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s, %s is already alive\r\n",
                dawn->active_room, username, target);
        add_msg(out, strlen(out));
        return;
    }

    if (strcmp(username, target) == 0) {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s, you can't revive yourself... You're dead.\r\n",
                dawn->active_room, username);
        add_msg(out, strlen(out));
        return;
    }

    int revive_cost = 1 + dawn->players[pindex].spellbook.revive.level * 6;

    if (dawn->players[pindex].mana >= revive_cost) {
        dawn->players[pindex].mana -= revive_cost;
        dawn->players[tindex].alive = 1;
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s has revived %s from the dead!\r\n",
                dawn->active_room, username, target);
        add_msg(out, strlen(out));
    } else {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s, you do not have the required %d mana to cast this spell\r\n",
                dawn->active_room, username, revive_cost);
        add_msg(out, strlen(out));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13ba0
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0x13ba0
movl %eax, -0x18(%rbp)
cmpl $-0x1, -0x18(%rbp)
jne 0x1577a
leaq -0x1b0(%rbp), %rdi
leaq 0x13341(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movl $0x190, %esi            # imm = 0x190
leaq 0xb62b(%rip), %rdx      # 0x20d70
movb $0x0, %al
callq 0x2390
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1c0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x15a6a
leaq 0x132ef(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpl $0x0, 0x118c(%rax)
jne 0x157fe
leaq -0x1b0(%rbp), %rdi
leaq 0x132c1(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x8(%rbp), %r8
movl $0x190, %esi            # imm = 0x190
leaq 0xb5d2(%rip), %rdx      # 0x20d9b
movb $0x0, %al
callq 0x2390
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1c8(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1c8(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x15a6a
leaq 0x1326b(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x18(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
cmpl $0x0, 0x2660(%rax)
je 0x15886
leaq -0x1b0(%rbp), %rdi
leaq 0x1323d(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x8(%rbp), %r8
movq -0x10(%rbp), %r9
movl $0x190, %esi            # imm = 0x190
leaq 0xb65d(%rip), %rdx      # 0x20eae
movb $0x0, %al
callq 0x2390
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1d0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x15a6a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x22d0
cmpl $0x0, %eax
jne 0x158f5
leaq -0x1b0(%rbp), %rdi
leaq 0x131ca(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x8(%rbp), %r8
movl $0x190, %esi            # imm = 0x190
leaq 0xb614(%rip), %rdx      # 0x20ed4
movb $0x0, %al
callq 0x2390
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1d8(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x15a6a
leaq 0x13174(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
imull $0x6, 0x1184(%rax), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
leaq 0x13146(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x2680(%rax), %eax
cmpl -0x1b4(%rbp), %eax
jl 0x15a0b
movl -0x1b4(%rbp), %edx
leaq 0x13110(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x14(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x2680(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x2680(%rax)
leaq 0x130e4(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x18(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl $0x1, 0x2660(%rax)
leaq -0x1b0(%rbp), %rdi
leaq 0x130b5(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x8(%rbp), %r8
movq -0x10(%rbp), %r9
movl $0x190, %esi            # imm = 0x190
leaq 0xb537(%rip), %rdx      # 0x20f10
movb $0x0, %al
callq 0x2390
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1e0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0x15a6a
leaq -0x1b0(%rbp), %rdi
leaq 0x13057(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x8(%rbp), %r8
movl -0x1b4(%rbp), %r9d
movl $0x190, %esi            # imm = 0x190
leaq 0xb505(%rip), %rdx      # 0x20f3f
movb $0x0, %al
callq 0x2390
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1e8(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
nopw %cs:(%rax,%rax)