// File: /workspace/github_c_makefile_star2_O0/Ziddykins[P]Dawn/src/map.c
// Function: move_player
void move_player(struct Message *message, int x, int y, int teleport) {
    char out[MAX_MESSAGE_BUFFER];
    int pindex = get_pindex(message->sender_nick);
    float travel_time;

    if (x < 0 || x >= global_map->dim || y < 0 || y >= global_map->dim) {
        sprintf(out, "PRIVMSG %s :Invalid location, this map is %dx%d\r\n", message->receiver, global_map->dim-1, global_map->dim-1);
        add_msg(out, strlen(out));
        return;
    }

    if (is_obstructed(x, y)) {
        snprintf(out, MAX_MESSAGE_BUFFER,"PRIVMSG %s :(%d,%d) is obstructed :(\r\n", message->receiver, x, y);
        add_msg(out, strlen(out));
        return;
    }

    int cx = dawn->players[pindex].pos_x;
    int cy = dawn->players[pindex].pos_y;

    if (is_obstructed(cx, cy)) {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :You're stuck :(\r\n", message->receiver);
        add_msg(out, strlen(out));
        return;
    }

    travel_time = pathlen(cx, cy, x, y)*TRAVEL_TIME_MULT;

    if (travel_time < 0) {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s, (%d,%d) cannot be reached :(\r\n", message->receiver, message->sender_nick, x, y);
        add_msg(out, strlen(out));
        return;
    }

    if ((unsigned int)travel_time >= (unsigned int)((((unsigned int)1<<(sizeof(unsigned int) * 8 - 1))-1)/TRAVEL_TIME_MULT)) {
        snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s, you cannot travel that far! It would take %.2f hours!\r\n", message->receiver, message->sender_nick, travel_time/60/60);
        add_msg(out, strlen(out));
        return;
    }

    if (teleport) {
        int teleport_cost = (int)(travel_time / 2.0f);

        if (dawn->players[pindex].mana > teleport_cost) {
            dawn->players[pindex].mana -= teleport_cost;
            dawn->players[pindex].pos_x = x;
            dawn->players[pindex].pos_y = y;
            snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s, you have teleported to %d,%d, saving you %u travel time!\r\n",
                    message->receiver, message->sender_nick, x, y, (unsigned int)travel_time);
            add_msg(out, strlen(out));

            return;
        } else {
            snprintf(out, MAX_MESSAGE_BUFFER, "PRIVMSG %s :%s, you do not have the required %u mana to teleport to %d, %d!\r\n",
                    dawn->active_room, message->sender_nick, (unsigned int)(travel_time / 2.0f), x, y);
            add_msg(out, strlen(out));

            return;
        }
    }

    add_event(TRAVEL, pindex, (unsigned int)travel_time, UNIQUE);

    dawn->players[pindex].travel_timer.pos.x = x;
    dawn->players[pindex].travel_timer.pos.y = y;
    dawn->players[pindex].travel_timer.active = 1;

    sprintf(out, "PRIVMSG %s :%s, you are traveling from (%d,%d) to (%d,%d). This will take %u seconds.\r\n",
            message->receiver, message->sender_nick, cx, cy, x, y, (unsigned int)travel_time);
    add_msg(out, strlen(out));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x13ba0
movl %eax, -0x1b4(%rbp)
cmpl $0x0, -0xc(%rbp)
jl 0xecf1
movl -0xc(%rbp), %eax
movq 0x175b9(%rip), %rcx     # 0x26290
cmpl 0x20(%rcx), %eax
jge 0xecf1
cmpl $0x0, -0x10(%rbp)
jl 0xecf1
movl -0x10(%rbp), %eax
movq 0x175a4(%rip), %rcx     # 0x26290
cmpl 0x20(%rcx), %eax
jl 0xed5b
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rdx
addq $0xc0, %rdx
movq 0x17586(%rip), %rax     # 0x26290
movl 0x20(%rax), %ecx
subl $0x1, %ecx
movq 0x17579(%rip), %rax     # 0x26290
movl 0x20(%rax), %r8d
subl $0x1, %r8d
leaq 0x10193(%rip), %rsi     # 0x1eeb9
movb $0x0, %al
callq 0x2050
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1d0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0xf253
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
callq 0xe620
cmpl $0x0, %eax
je 0xedc6
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rcx
addq $0xc0, %rcx
movl -0xc(%rbp), %r8d
movl -0x10(%rbp), %r9d
movl $0x190, %esi            # imm = 0x190
leaq 0x1015a(%rip), %rdx     # 0x1eeeb
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 0xf253
leaq 0x19ca3(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1b4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x25ec(%rax), %eax
movl %eax, -0x1bc(%rbp)
leaq 0x19c76(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1b4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x25f0(%rax), %eax
movl %eax, -0x1c0(%rbp)
movl -0x1bc(%rbp), %edi
movl -0x1c0(%rbp), %esi
callq 0xe620
cmpl $0x0, %eax
je 0xee89
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rcx
addq $0xc0, %rcx
movl $0x190, %esi            # imm = 0x190
leaq 0x100be(%rip), %rdx     # 0x1ef12
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 0xf253
movl -0x1bc(%rbp), %edi
movl -0x1c0(%rbp), %esi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
callq 0xe6e0
movss 0xf1b8(%rip), %xmm1     # 0x1e060
mulss %xmm1, %xmm0
movss %xmm0, -0x1b8(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x1b8(%rbp), %xmm0
jbe 0xef21
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rcx
addq $0xc0, %rcx
movq -0x8(%rbp), %r8
movl -0xc(%rbp), %r9d
movl -0x10(%rbp), %eax
movl $0x190, %esi            # imm = 0x190
leaq 0x10047(%rip), %rdx     # 0x1ef30
movl %eax, (%rsp)
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
jmp 0xf253
cvttss2si -0x1b8(%rbp), %rax
cmpl $0x80000000, %eax       # imm = 0x80000000
jb 0xefac
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rcx
addq $0xc0, %rcx
movq -0x8(%rbp), %r8
movss -0x1b8(%rbp), %xmm0
movss 0xf111(%rip), %xmm1     # 0x1e068
divss %xmm1, %xmm0
movss 0xf105(%rip), %xmm1     # 0x1e068
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movl $0x190, %esi            # imm = 0x190
leaq 0xffe8(%rip), %rdx      # 0x1ef5f
movb $0x1, %al
callq 0x2390
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1f0(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0xf253
cmpl $0x0, -0x14(%rbp)
je 0xf162
movss -0x1b8(%rbp), %xmm0
movss 0xf086(%rip), %xmm1     # 0x1e04c
divss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x1c4(%rbp)
leaq 0x19a95(%rip), %rax     # 0x28a70
movq (%rax), %rax
addq $0x1a0, %rax            # imm = 0x1A0
movslq -0x1b4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
addq %rcx, %rax
movl 0x2680(%rax), %eax
cmpl -0x1c4(%rbp), %eax
jle 0xf0da
movl -0x1c4(%rbp), %edi
leaq 0x19a5c(%rip), %rax     # 0x28a70
movq (%rax), %rcx
movslq -0x1b4(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
movl 0x2820(%rcx,%rdx), %esi
subl %edi, %esi
movl %esi, 0x2820(%rcx,%rdx)
movl -0xc(%rbp), %esi
movq (%rax), %rcx
movslq -0x1b4(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
movl %esi, 0x278c(%rcx,%rdx)
movl -0x10(%rbp), %edx
movq (%rax), %rax
movslq -0x1b4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
movl %edx, 0x2790(%rax,%rcx)
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %r8
movq %r8, %rcx
addq $0xc0, %rcx
movl -0xc(%rbp), %r9d
movl -0x10(%rbp), %r10d
cvttss2si -0x1b8(%rbp), %rax
movl $0x190, %esi            # imm = 0x190
leaq 0xff0a(%rip), %rdx      # 0x1efa7
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x2390
leaq -0x1b0(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x1f8(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0xf253
leaq -0x1b0(%rbp), %rdi
leaq 0x19988(%rip), %rax     # 0x28a70
movq (%rax), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x8(%rbp), %r8
movss -0x1b8(%rbp), %xmm0
movss 0xef5e(%rip), %xmm1     # 0x1e064
mulss %xmm1, %xmm0
cvttss2si %xmm0, %rax
movl %eax, %r9d
movl -0xc(%rbp), %r10d
movl -0x10(%rbp), %eax
movl $0x190, %esi            # imm = 0x190
leaq 0xfecd(%rip), %rdx      # 0x1eff2
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x2390
leaq -0x1b0(%rbp), %rax
movq %rax, -0x200(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x200(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
jmp 0xf253
movl -0x1b4(%rbp), %esi
cvttss2si -0x1b8(%rbp), %rax
movl %eax, %edx
movl $0x3, %edi
movl $0x1, %ecx
callq 0x17280
movl -0xc(%rbp), %esi
leaq 0x198e4(%rip), %rax     # 0x28a70
movq (%rax), %rcx
movslq -0x1b4(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
movl %esi, 0x12e4(%rcx,%rdx)
movl -0x10(%rbp), %esi
movq (%rax), %rcx
movslq -0x1b4(%rbp), %rdx
imulq $0x26a8, %rdx, %rdx     # imm = 0x26A8
movl %esi, 0x12e8(%rcx,%rdx)
movq (%rax), %rax
movslq -0x1b4(%rbp), %rcx
imulq $0x26a8, %rcx, %rcx     # imm = 0x26A8
movl $0x1, 0x12ec(%rax,%rcx)
leaq -0x1b0(%rbp), %rdi
movq -0x8(%rbp), %rcx
movq %rcx, %rdx
addq $0xc0, %rdx
movl -0x1bc(%rbp), %r8d
movl -0x1c0(%rbp), %r9d
movl -0xc(%rbp), %r11d
movl -0x10(%rbp), %r10d
cvttss2si -0x1b8(%rbp), %rax
leaq 0xfe2a(%rip), %rsi      # 0x1f040
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x2050
leaq -0x1b0(%rbp), %rax
movq %rax, -0x208(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x20c0
movq -0x208(%rbp), %rdi
movq %rax, %rsi
callq 0x12840
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopl (%rax)