// File: /workspace/github_c_makefile_star2_O0/ajpaulson[P]srogue11/wizard.c
// Function: teleport
int teleport(struct coord spot,struct thing *th)
{
	int rm, y, x;
	struct coord oldspot;
	struct room *rp;
	bool ishero;

	ishero = (th == &player);
	oldspot = th->t_pos;
	y = th->t_pos.y;
	x = th->t_pos.x;
	mvwaddch(cw, y, x, th->t_oldch); 
	if (!ishero)
		mvwaddch(mw, y, x, ' ');
	rp = roomin(&spot);
	if (spot.y < 0 || !step_ok(winat(spot.y, spot.x))) {
		rp = &rooms[rnd_room()];
		th->t_pos = *rnd_pos(rp);
	}
	else
		th->t_pos = spot;
	rm = rp - &rooms[0];
	th->t_room = rp;
	th->t_oldch = mvwinch(cw, th->t_pos.y, th->t_pos.x);
	light(&oldspot);
	th->t_nomove = 0;
	if (ishero) {
		light(&hero);
		mvwaddch(cw, hero.y, hero.x, PLAYER);
		/*
		 * turn off ISHELD in case teleportation was done
		 * while fighting a Fungi or Bone Devil.
		 */
		if (pl_on(ISHELD))
			unhold('F');
		count = 0;
		running = FALSE;
		flushinp();			/* flush typeahead */
		nochange = FALSE;
	}
	else
		mvwaddch(mw, th->t_pos.y, th->t_pos.x, th->t_type);
	return rm;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x10449(%rip), %rax     # 0x370d0
cmpq %rax, -0x10(%rbp)
sete %al
andb $0x1, %al
movb %al, -0x31(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x54(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x1c(%rbp)
leaq 0x13196(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x26ccf
jmp 0x26ce9
leaq 0x1317a(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movsbl 0x8f(%rax), %esi
callq 0x64c0
testb $0x1, -0x31(%rbp)
jne 0x26d1f
leaq 0x1316a(%rip), %rax     # 0x39e60
movq (%rax), %rdi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x26d0b
jmp 0x26d1f
leaq 0x1314e(%rip), %rax     # 0x39e60
movq (%rax), %rdi
movl $0x20, %esi
callq 0x64c0
leaq -0x8(%rbp), %rdi
callq 0x7560
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x4(%rbp)
jl 0x26d4a
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
callq 0xa960
movsbq %al, %rdi
callq 0xdc30
testb $0x1, %al
jne 0x26d87
movb $0x0, %al
callq 0x135d0
movslq %eax, %rcx
leaq 0xffc5(%rip), %rax      # 0x36d20
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
callq 0x19c00
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, 0x50(%rax)
jmp 0x26d93
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq %rcx, 0x50(%rax)
movq -0x30(%rbp), %rax
leaq 0xff82(%rip), %rcx      # 0x36d20
subq %rcx, %rax
movl $0x68, %ecx
cqto
idivq %rcx
movl %eax, -0x14(%rbp)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x70(%rax)
leaq 0x1308f(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x54(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x50(%rax), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x26de6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x44(%rbp)
jmp 0x26df8
leaq 0x13063(%rip), %rax     # 0x39e50
movq (%rax), %rdi
callq 0x6340
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x8f(%rax)
leaq -0x24(%rbp), %rdi
callq 0x123b0
movq -0x10(%rbp), %rax
movl $0x0, 0x84(%rax)
testb $0x1, -0x31(%rbp)
je 0x26eb8
leaq 0x102a1(%rip), %rdi     # 0x370d0
addq $0x50, %rdi
callq 0x123b0
leaq 0x13011(%rip), %rax     # 0x39e50
movq (%rax), %rdi
leaq 0x10287(%rip), %rax     # 0x370d0
movl 0x54(%rax), %esi
leaq 0x1027d(%rip), %rax     # 0x370d0
movl 0x50(%rax), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x26e62
jmp 0x26e76
leaq 0x12fe7(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movl $0x40, %esi
callq 0x64c0
movl $0x100, %edi            # imm = 0x100
callq 0xaa60
testb $0x1, %al
jne 0x26e86
jmp 0x26e90
movl $0x46, %edi
callq 0x10f00
leaq 0xfe5d(%rip), %rax      # 0x36cf4
movl $0x0, (%rax)
leaq 0xfe68(%rip), %rax      # 0x36d0c
movb $0x0, (%rax)
callq 0x6060
leaq 0xfe60(%rip), %rax      # 0x36d13
movb $0x0, (%rax)
jmp 0x26ef6
leaq 0x12fa1(%rip), %rax     # 0x39e60
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x54(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x50(%rax), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x26edc
jmp 0x26ef6
leaq 0x12f7d(%rip), %rax     # 0x39e60
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movsbl 0x8d(%rax), %esi
callq 0x64c0
movl -0x14(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop