// File: /workspace/github_c_makefile_star2_O1/ajpaulson[P]srogue11/move.c
// Function: be_trapped
char be_trapped(struct coord *tc,struct thing *th)
{
	struct trap *trp;
	int ch, ishero;
	struct linked_list *mon;
	char stuckee[35], seeit, sayso;

	if ((trp = trap_at(tc->y, tc->x)) == NULL)
		return 0;
	ishero = (th == &player);
	if (ishero) {
		strcpy(stuckee, "You");
		count = running = FALSE;
	}
	else {
		sprintf(stuckee, "The %s", monsters[th->t_indx].m_name);
	}
	seeit = cansee(tc->y, tc->x);
	if (seeit)
		mvwaddch(cw, tc->y, tc->x, trp->tr_type);
	trp->tr_flags |= ISFOUND;
	sayso = TRUE;
	switch (ch = trp->tr_type) {
		case POST:
			if (ishero) {
				nlmove = TRUE;
				new_level(POSTLEV);
			}
			else
				goto goner;
		when MAZETRAP:
			if (ishero) {
				nlmove = TRUE;
				level += 1;
				new_level(MAZELEV);
				msg("You are surrounded by twisty passages!");
			}
			else
				goto goner;
		when TELTRAP:
			nlmove = TRUE;
			teleport(trp->tr_goto, th);
		when TRAPDOOR:
			if (ishero) {
				level += 1;
				new_level(NORMLEV);
			}
			else {		/* monsters get lost */
goner:
				ch = GONER;
			}
			nlmove = TRUE;
			if (seeit && sayso)
				msg("%s fell into a trap!", stuckee);
		when BEARTRAP:
			th->t_nomove += BEARTIME;
			if (seeit) {
				strcat(stuckee, (ishero ? " are" : " is"));
				msg("%s caught in a bear trap.", stuckee);
			}
		when SLEEPTRAP:
			if (ishero && pl_on(ISINVINC))
				msg("You feel momentarily dizzy.");
			else {
				if (ishero)
					th->t_nocmd += SLEEPTIME;
				else
					th->t_nomove += SLEEPTIME;
				if (seeit)
					msg("%s fall%s asleep in a strange white mist.",
					  stuckee, (ishero ? "":"s"));
			}
		when ARROWTRAP: {
			int resist, ac;
			struct stats *it;

			stuckee[0] = tolower(stuckee[0]);
			it = &th->t_stats;
			if (ishero && cur_armor != NULL)
				ac = cur_armor->o_ac;
			else
				ac = it->s_arm;
			resist = ac + getpdex(it, FALSE);
			if (ishero && pl_on(ISINVINC))
				resist = -100;		/* invincible is impossible to hit */
			if (swing(3 + (level / 4), resist, 1)) {
				if (seeit)
					msg("%sAn arrow shot %s.", (ishero ? "Oh no! " : ""),
					  stuckee);
				if (ishero)
					chg_hpt(-roll(1,6),FALSE,K_ARROW);
				else {
					it->s_hpt -= roll(1,6);
					if (it->s_hpt < 1) {
						sayso = FALSE;
						goto goner;
					}
				}
			}
			else {
				struct linked_list *item;
				struct object *arrow;

				if (seeit)
					msg("An arrow shoots past %s.", stuckee);
				item = new_thing(FALSE, WEAPON, ARROW);
				arrow = OBJPTR(item);
				arrow->o_hplus = 3;
				arrow->o_dplus = rnd(2);
				arrow->o_count = 1;
		 		arrow->o_pos = th->t_pos;
				fall(item, FALSE);
			}
		}
		when DARTTRAP: {
			int resist, ac;
			struct stats *it;

			stuckee[0] = tolower(stuckee[0]);
			it = &th->t_stats;
			if (ishero && cur_armor != NULL)
				ac = cur_armor->o_ac;
			else
				ac = it->s_arm;
			resist = ac + getpdex(it, FALSE);
			if (ishero && pl_on(ISINVINC))
				resist = -100;		/* invincible is impossible to hit */
			if (swing(3 + (level / 4), resist, 0)) {
				if (seeit)
					msg("A small dart just hit %s.", stuckee);
				if (ishero) {
					if (!save(VS_POISON))
						chg_abil(CON,-1,TRUE);
					if (!iswearing(R_SUSTSTR))
						chg_abil(STR,-1,TRUE);
					chg_hpt(-roll(1, 4),FALSE,K_DART);
				}
				else {
					if (!save_throw(VS_POISON, th))
						it->s_ef.a_str -= 1;
					it->s_hpt -= roll(1, 4);
					if (it->s_hpt < 1) {
						sayso = FALSE;
						goto goner;
					}
				}
			}
			else if (seeit)
				msg("A small dart whizzes by %s.", stuckee);
		}
	    when POOL:
			if (!ishero && rnd(100) < 10) {
				if (seeit)
					msg("The %s drowns !!", stuckee);
				goto goner;
			}
			if ((trp->tr_flags & ISGONE) && rnd(100) < 10) {
				nlmove = TRUE;
				if (rnd(100) < 15)
					teleport(rndspot, &player);	   /* teleport away */
				else if(rnd(100) < 15 && level > 2) {
					level -= rnd(2) + 1;
					new_level(NORMLEV);
					msg("You here a faint groan from below.");
				}
				else if(rnd(100) < 40) {
					level += rnd(4);
					new_level(NORMLEV);
					msg("You find yourself in strange surroundings.");
				}
				else if(rnd(100) < 6 && pl_off(ISINVINC)) {
					msg("Oh no!!! You drown in the pool!!! --More--");
					wait_for(cw, ' ');
					death(K_POOL);
				}
				else
					 nlmove = FALSE;
		}
	}
	flushinp();		/* flush typeahead */
	return ch;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x1f925(%rip), %rax     # 0x2de68
movslq (%rax), %rdx
testq %rdx, %rdx
jle 0xe57e
movl (%r15), %eax
movl 0x4(%r15), %ecx
leaq (%rdx,%rdx,2), %rdx
shlq $0x3, %rdx
addq 0x1ba5f(%rip), %rdx     # 0x29fc0
leaq 0x1f808(%rip), %r12     # 0x2dd70
cmpl %ecx, 0x4(%r12)
jne 0xe575
cmpl %eax, (%r12)
je 0xe581
addq $0x18, %r12
cmpq %rdx, %r12
jb 0xe568
xorl %r12d, %r12d
testq %r12, %r12
je 0xe5b8
cmpq 0x1b9cb(%rip), %r14     # 0x29f58
je 0xe5bf
movslq 0x80(%r14), %rax
imulq $0x70, %rax, %rax
leaq 0x1be1f(%rip), %rcx     # 0x2a3c0
movq (%rcx,%rax), %rdx
leaq 0x12b1c(%rip), %rsi     # 0x210c8
movq %rsp, %rdi
xorl %eax, %eax
callq 0x64f0
jmp 0xe5dd
xorl %ebp, %ebp
jmp 0xeb97
movl $0x756f59, (%rsp)       # imm = 0x756F59
leaq 0x1f2cf(%rip), %rax     # 0x2d89c
movb $0x0, (%rax)
leaq 0x1f2ad(%rip), %rax     # 0x2d884
movl $0x0, (%rax)
movl (%r15), %esi
movl 0x4(%r15), %edi
callq 0x6fcc
movl %eax, %ebx
testb %al, %al
je 0xe61a
leaq 0x223ea(%rip), %r13     # 0x309e0
movq (%r13), %rdi
movl (%r15), %edx
movl 0x4(%r15), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0xe61a
movq (%r13), %rdi
movsbl 0x14(%r12), %esi
callq 0x64c0
orb $0x8, 0x10(%r12)
movzbl 0x14(%r12), %ebp
cmpl $0x5d, %ebp
jle 0xe670
cmpl $0x7a, %ebp
jle 0xe6fb
cmpl $0x7b, %ebp
je 0xe867
cmpl $0x7d, %ebp
je 0xe986
cmpl $0x7e, %ebp
jne 0xeb92
leaq 0x1f243(%rip), %rax     # 0x2d899
movb $0x1, (%rax)
movq 0x8(%r12), %rdi
movq %r14, %rsi
callq 0x1d5fa
movl $0x7e, %ebp
jmp 0xeb92
cmpl $0x3d, %ebp
jg 0xe6a1
cmpl $0x22, %ebp
je 0xe7f1
cmpl $0x24, %ebp
jne 0xeb92
cmpq 0x1b8ca(%rip), %r14     # 0x29f58
je 0xea2e
addl $0x5, 0x84(%r14)
jmp 0xebb6
cmpl $0x3e, %ebp
je 0xe837
cmpl $0x5c, %ebp
jne 0xeb92
movl $0x1, %r15d
cmpq 0x1b898(%rip), %r14     # 0x29f58
jne 0xeb6a
leaq 0x1f1cc(%rip), %rax     # 0x2d899
movb $0x1, (%rax)
leaq 0x1bc19(%rip), %rax     # 0x2a2f0
incl (%rax)
movl $0x2, %edi
callq 0xf658
leaq 0x129e5(%rip), %rdi     # 0x210cf
xorl %eax, %eax
callq 0xb6e0
movl $0x5c, %ebp
jmp 0xeb92
cmpl $0x5e, %ebp
je 0xe955
cmpl $0x60, %ebp
jne 0xeb92
leaq 0x1f54c(%rip), %r15     # 0x2dc60
callq 0x65a0
leaq 0x1f138(%rip), %rcx     # 0x2d858
movq (%rcx), %rcx
leaq 0x34(%rcx), %rdx
leaq 0x2c(%r14), %rsi
testq %rcx, %rcx
cmoveq %rsi, %rdx
cmpq %r15, %r14
movq (%rax), %rax
movsbq (%rsp), %rcx
movb (%rax,%rcx,4), %al
movb %al, (%rsp)
cmovneq %rsi, %rdx
movl (%rdx), %r12d
movq %r14, %rdi
xorl %esi, %esi
callq 0x120fa
movl %eax, %ebp
addl %r12d, %ebp
cmpq %r15, %r14
jne 0xe772
movl $0x8, %edi
callq 0x9595
testb %al, %al
movl $0xffffff9c, %eax       # imm = 0xFFFFFF9C
cmovnel %eax, %ebp
leaq 0x1bb77(%rip), %rax     # 0x2a2f0
movl (%rax), %eax
leal 0x3(%rax), %edi
testl %eax, %eax
cmovnsl %eax, %edi
sarl $0x2, %edi
addl $0x3, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0xaf25
testl %eax, %eax
je 0xea58
testb %bl, %bl
je 0xe7af
leaq 0x12a04(%rip), %rdi     # 0x211a9
movq %rsp, %rsi
xorl %eax, %eax
callq 0xb6e0
cmpq 0x1b7a2(%rip), %r14     # 0x29f58
je 0xeada
xorl %r15d, %r15d
xorl %edi, %edi
movq %r14, %rsi
callq 0xb022
testl %eax, %eax
jne 0xe7d1
decl 0x10(%r14)
movl $0x1, %edi
movl $0x4, %esi
callq 0xc74e
subl %eax, 0x30(%r14)
jg 0xeb3a
xorl %eax, %eax
jmp 0xeb42
cmpq 0x1b760(%rip), %r14     # 0x29f58
je 0xe9ce
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x9, %eax
jg 0xe9ce
movl $0x1, %r15d
testb %bl, %bl
je 0xeb6a
leaq 0x129b7(%rip), %rdi     # 0x211df
movq %rsp, %rsi
xorl %eax, %eax
callq 0xb6e0
jmp 0xeb6a
movl $0x1, %r15d
cmpq 0x1b714(%rip), %r14     # 0x29f58
jne 0xeb6a
leaq 0x1ba9f(%rip), %rax     # 0x2a2f0
incl (%rax)
xorl %edi, %edi
callq 0xf658
movl $0x3e, %ebp
movb $0x1, %r15b
jmp 0xeb6f
leaq 0x1f3f2(%rip), %r15     # 0x2dc60
callq 0x65a0
leaq 0x1efde(%rip), %rcx     # 0x2d858
movq (%rcx), %rcx
leaq 0x34(%rcx), %rdx
leaq 0x2c(%r14), %rsi
testq %rcx, %rcx
cmoveq %rsi, %rdx
cmpq %r15, %r14
movq (%rax), %rax
movsbq (%rsp), %rcx
movb (%rax,%rcx,4), %al
movb %al, (%rsp)
cmovneq %rsi, %rdx
movl (%rdx), %r12d
movq %r14, %rdi
xorl %esi, %esi
callq 0x120fa
movl %eax, %ebp
addl %r12d, %ebp
cmpq %r15, %r14
jne 0xe8cc
movl $0x8, %edi
callq 0x9595
testb %al, %al
movl $0xffffff9c, %eax       # imm = 0xFFFFFF9C
cmovnel %eax, %ebp
leaq 0x1ba1d(%rip), %rax     # 0x2a2f0
movl (%rax), %eax
leal 0x3(%rax), %edi
testl %eax, %eax
cmovnsl %eax, %edi
sarl $0x2, %edi
addl $0x3, %edi
movl %ebp, %esi
movl $0x1, %edx
callq 0xaf25
testl %eax, %eax
je 0xea76
testb %bl, %bl
je 0xe925
cmpq 0x1b656(%rip), %r14     # 0x29f58
leaq 0x1287f(%rip), %rax     # 0x21188
leaq 0x15001(%rip), %rsi     # 0x23911
cmoveq %rax, %rsi
leaq 0x12859(%rip), %rdi     # 0x21174
movq %rsp, %rdx
xorl %eax, %eax
callq 0xb6e0
movl $0x1, %edi
movl $0x6, %esi
callq 0xc74e
cmpq 0x1b61d(%rip), %r14     # 0x29f58
je 0xeb49
subl %eax, 0x30(%r14)
jg 0xeb59
xorl %eax, %eax
xorl %r15d, %r15d
jmp 0xeb61
movl $0x1, %r15d
cmpq 0x1b5f6(%rip), %r14     # 0x29f58
jne 0xeb6a
leaq 0x1ef2a(%rip), %rax     # 0x2d899
movb $0x1, (%rax)
movl $0x1, %edi
callq 0xf658
movl $0x5e, %ebp
jmp 0xeb92
addl $0x3, 0x84(%r14)
movl $0x7d, %ebp
testb %bl, %bl
je 0xeb92
cmpq 0x1b5b6(%rip), %r14     # 0x29f58
leaq 0x12762(%rip), %rax     # 0x2110b
leaq 0x12760(%rip), %rsi     # 0x21110
cmoveq %rax, %rsi
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x64d0
leaq 0x1274e(%rip), %rdi     # 0x21114
movq %rbx, %rsi
jmp 0xeb8b
movl $0x22, %ebp
testb $0x2, 0x10(%r12)
je 0xeb92
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x9, %eax
jg 0xeb92
leaq 0x1ee9e(%rip), %rbx     # 0x2d899
movb $0x1, (%rbx)
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0xe, %eax
jg 0xebeb
leaq 0x1b996(%rip), %rax     # 0x2a3b0
movq (%rax), %rdi
leaq 0x1f23c(%rip), %rsi     # 0x2dc60
callq 0x1d5fa
jmp 0xeb92
movl $0x8, %edi
callq 0x9595
testb %al, %al
je 0xeba8
leaq 0x126e7(%rip), %rdi     # 0x2112e
xorl %eax, %eax
callq 0xb6e0
movl $0x24, %ebp
jmp 0xeb92
testb %bl, %bl
je 0xeb3a
leaq 0x1275c(%rip), %rdi     # 0x211c3
movq %rsp, %rsi
xorl %eax, %eax
callq 0xb6e0
jmp 0xeb3a
testb %bl, %bl
je 0xea8b
leaq 0x1270f(%rip), %rdi     # 0x21190
movq %rsp, %rsi
xorl %eax, %eax
callq 0xb6e0
xorl %edi, %edi
movl $0x29, %esi
movl $0x3, %edx
callq 0x1b715
movq %rax, %r15
movq 0x10(%rax), %r12
movl $0x3, 0x2c(%r12)
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
movl %eax, 0x30(%r12)
movl $0x1, 0x24(%r12)
movq 0x50(%r14), %rax
movq %rax, (%r12)
movq %r15, %rdi
xorl %esi, %esi
callq 0x1cacd
jmp 0xeb59
xorl %edi, %edi
callq 0xae50
testl %eax, %eax
jne 0xeaf9
movl $0x3, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11f24
movl $0x2, %edi
callq 0x12d9c
testb %al, %al
jne 0xeb1b
movl $0x1, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x11f24
movl $0x1, %edi
movl $0x4, %esi
callq 0xc74e
negl %eax
movl %eax, %edi
xorl %esi, %esi
movl $0xfffffff1, %edx       # imm = 0xFFFFFFF1
callq 0x11ec8
movl $0x1, %r15d
movb $0x1, %al
movl $0x60, %ebp
jmp 0xeb66
negl %eax
movl %eax, %edi
xorl %esi, %esi
movl $0xfffffff0, %edx       # imm = 0xFFFFFFF0
callq 0x11ec8
movl $0x1, %r15d
movb $0x1, %al
movl $0x7b, %ebp
testb %al, %al
jne 0xeb92
movl $0x2, %ebp
leaq 0x1ed23(%rip), %rax     # 0x2d899
movb $0x1, (%rax)
andb %r15b, %bl
cmpb $0x1, %bl
jne 0xeb92
leaq 0x1256e(%rip), %rdi     # 0x210f6
movq %rsp, %rsi
xorl %eax, %eax
callq 0xb6e0
callq 0x6070
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f0b1(%rip), %rax     # 0x2dc60
addl $0x5, 0x88(%rax)
movl $0x24, %ebp
testb %bl, %bl
je 0xeb92
cmpq 0x1b392(%rip), %r14     # 0x29f58
leaq 0x14d44(%rip), %rax     # 0x23911
leaq 0x10a15(%rip), %rdx     # 0x1f5e9
cmoveq %rax, %rdx
leaq 0x1256b(%rip), %rdi     # 0x2114a
movq %rsp, %rsi
xorl %eax, %eax
callq 0xb6e0
jmp 0xeb92
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
leaq 0x1b6f2(%rip), %r14     # 0x2a2f0
cmpl $0xe, %eax
jg 0xec2a
cmpl $0x3, (%r14)
jl 0xec2a
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
notl %eax
addl %eax, (%r14)
xorl %edi, %edi
callq 0xf658
leaq 0x125c8(%rip), %rdi     # 0x211f0
jmp 0xec58
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x27, %eax
jg 0xec64
movl $0x4, %edi
xorl %eax, %eax
callq 0xc72d
addl %eax, (%r14)
xorl %edi, %edi
callq 0xf658
leaq 0x125bb(%rip), %rdi     # 0x21213
xorl %eax, %eax
callq 0xb6e0
jmp 0xeb92
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x5, %eax
jg 0xecb4
movl $0x8, %edi
callq 0x95a4
testb %al, %al
je 0xecb4
leaq 0x125b4(%rip), %rdi     # 0x2123e
xorl %eax, %eax
callq 0xb6e0
leaq 0x21d48(%rip), %rax     # 0x309e0
movq (%rax), %rdi
movl $0x20, %esi
callq 0xb95e
movl $0xfffffff3, %edi       # imm = 0xFFFFFFF3
callq 0x12dc8
jmp 0xeb92
movb $0x0, (%rbx)
jmp 0xeb92