// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, (%rsp)
movq 0x50(%rsi), %r14
movq %r14, 0x8(%rsp)
movq %r14, %r15
shrq $0x20, %r15
leaq 0x15086(%rip), %r12     # 0x309d0
movq (%r12), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0x1b96e
movq (%r12), %rdi
movsbl 0x8f(%rbx), %esi
callq 0x64a0
cmpq 0xe5eb(%rip), %rbx      # 0x29f60
je 0x1b99e
leaq 0x15062(%rip), %r13     # 0x309e0
movq (%r13), %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0x1b99e
movq (%r13), %rdi
pushq $0x20
popq %rsi
callq 0x64a0
movq %rsp, %r15
movq %r15, %rdi
callq 0x6f44
movl 0x4(%r15), %edi
testl %edi, %edi
js 0x1b9c9
movq %rax, %r14
movl (%rsp), %esi
callq 0x92ab
movsbq %al, %rdi
callq 0xb3d0
testb %al, %al
jne 0x1b9e8
xorl %eax, %eax
callq 0xef36
cltq
imulq $0x68, %rax, %r14
addq 0xe533(%rip), %r14      # 0x29f10
movq %r14, %rdi
callq 0x1310e
movq %rax, %r15
movq (%r15), %rdx
movq %rdx, 0x50(%rbx)
movq %r14, 0x70(%rbx)
movq (%r12), %rdi
movq %rdx, %rsi
shrq $0x20, %rsi
callq 0x6470
cmpl $-0x1, %eax
je 0x1ba13
movq (%r12), %rdi
callq 0x6320
jmp 0x1ba15
movb $-0x1, %al
movb %al, 0x8f(%rbx)
leaq 0x8(%rsp), %rdi
callq 0xe29f
andl $0x0, 0x84(%rbx)
cmpq 0xe52d(%rip), %rbx      # 0x29f60
je 0x1ba60
leaq 0x14fa4(%rip), %r15     # 0x309e0
movq (%r15), %rdi
movl 0x50(%rbx), %edx
movl 0x54(%rbx), %esi
callq 0x6470
cmpl $-0x1, %eax
je 0x1bac9
movq (%r15), %rdi
movsbl 0x8d(%rbx), %esi
callq 0x64a0
jmp 0x1bac9
leaq 0x121e9(%rip), %rbx     # 0x2dc50
leaq 0x50(%rbx), %rdi
callq 0xe29f
movq (%r12), %rdi
movl 0x50(%rbx), %edx
movl 0x54(%rbx), %esi
callq 0x6470
cmpl $-0x1, %eax
je 0x1ba90
movq (%r12), %rdi
pushq $0x40
popq %rsi
callq 0x64a0
movl $0x100, %edi            # imm = 0x100
callq 0x932c
testb %al, %al
je 0x1baa6
pushq $0x46
popq %rdi
callq 0xd4b0
leaq 0x11dc7(%rip), %rax     # 0x2d874
andl $0x0, (%rax)
leaq 0x11dd5(%rip), %rax     # 0x2d88c
xorl %ebx, %ebx
movb %bl, (%rax)
callq 0x6070
leaq 0x11dcc(%rip), %rax     # 0x2d893
movb %bl, (%rax)
subq 0xe440(%rip), %r14      # 0x29f10
pushq $0x68
popq %rcx
movq %r14, %rax
cqto
idivq %rcx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq