// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x10(%rbp), %rax
movl (%rax), %esi
callq 0x12e80
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x11b38
movb $0x0, -0x1(%rbp)
jmp 0x123a1
leaq 0x25591(%rip), %rax     # 0x370d0
cmpq %rax, -0x18(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x11b7d
leaq -0x60(%rbp), %rdi
leaq 0x19b69(%rip), %rsi     # 0x2b6c8
callq 0x60d0
leaq 0x251a1(%rip), %rax     # 0x36d0c
movb $0x0, (%rax)
leaq 0x2517f(%rip), %rax     # 0x36cf4
movl $0x0, (%rax)
jmp 0x11bab
leaq -0x60(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq 0x80(%rax), %rcx
leaq 0x2182d(%rip), %rax     # 0x333c0
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdx
leaq 0x19b28(%rip), %rsi     # 0x2b6cc
movb $0x0, %al
callq 0x64f0
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x10(%rbp), %rax
movl (%rax), %esi
callq 0x7480
andb $0x1, %al
movb %al, -0x61(%rbp)
cmpb $0x0, -0x61(%rbp)
je 0x11c02
leaq 0x28281(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x10(%rbp), %rax
movl (%rax), %edx
callq 0x6490
cmpl $-0x1, %eax
jne 0x11beb
jmp 0x11c02
leaq 0x2825e(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movsbl 0x14(%rax), %esi
callq 0x64c0
movq -0x20(%rbp), %rax
movl 0x10(%rax), %ecx
orl $0x8, %ecx
movl %ecx, 0x10(%rax)
movb $0x1, -0x62(%rbp)
movq -0x20(%rbp), %rax
movsbl 0x14(%rax), %eax
movl %eax, -0x9c(%rbp)
movl %eax, -0x24(%rbp)
subl $0x22, %eax
je 0x121ff
jmp 0x11c2f
movl -0x9c(%rbp), %eax
subl $0x24, %eax
je 0x11deb
jmp 0x11c40
movl -0x9c(%rbp), %eax
subl $0x3e, %eax
je 0x11d3a
jmp 0x11c51
movl -0x9c(%rbp), %eax
subl $0x5c, %eax
je 0x11cd4
jmp 0x11c5e
movl -0x9c(%rbp), %eax
subl $0x5e, %eax
je 0x11cae
jmp 0x11c6b
movl -0x9c(%rbp), %eax
subl $0x60, %eax
je 0x12043
jmp 0x11c7c
movl -0x9c(%rbp), %eax
subl $0x7b, %eax
je 0x11e76
jmp 0x11c8d
movl -0x9c(%rbp), %eax
subl $0x7d, %eax
je 0x11d9a
jmp 0x11c9e
movl -0x9c(%rbp), %eax
subl $0x7e, %eax
je 0x11d1a
jmp 0x12396
cmpl $0x0, -0x28(%rbp)
je 0x11cca
leaq 0x2504e(%rip), %rax     # 0x36d09
movb $0x1, (%rax)
movl $0x1, %edi
callq 0x13060
jmp 0x11ccf
jmp 0x11d60
jmp 0x12396
cmpl $0x0, -0x28(%rbp)
je 0x11d13
leaq 0x25028(%rip), %rax     # 0x36d09
movb $0x1, (%rax)
leaq 0x21605(%rip), %rax     # 0x332f0
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x215f9(%rip), %rax     # 0x332f0
movl %ecx, (%rax)
movl $0x2, %edi
callq 0x13060
leaq 0x199c9(%rip), %rdi     # 0x2b6d3
movb $0x0, %al
callq 0xd8f0
jmp 0x11d15
jmp 0x11d60
jmp 0x12396
leaq 0x24fe8(%rip), %rax     # 0x36d09
movb $0x1, (%rax)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rsi
movq 0x8(%rax), %rdi
callq 0x26c70
jmp 0x12396
cmpl $0x0, -0x28(%rbp)
je 0x11d5e
leaq 0x215a9(%rip), %rax     # 0x332f0
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x2159d(%rip), %rax     # 0x332f0
movl %ecx, (%rax)
xorl %edi, %edi
callq 0x13060
jmp 0x11d67
jmp 0x11d60
movl $0x2, -0x24(%rbp)
leaq 0x24f9b(%rip), %rax     # 0x36d09
movb $0x1, (%rax)
movsbl -0x61(%rbp), %eax
cmpl $0x0, %eax
je 0x11d95
movsbl -0x62(%rbp), %eax
cmpl $0x0, %eax
je 0x11d95
leaq -0x60(%rbp), %rsi
leaq 0x1996c(%rip), %rdi     # 0x2b6fa
movb $0x0, %al
callq 0xd8f0
jmp 0x12396
movq -0x18(%rbp), %rax
movl 0x84(%rax), %ecx
addl $0x3, %ecx
movl %ecx, 0x84(%rax)
cmpb $0x0, -0x61(%rbp)
je 0x11de6
leaq -0x60(%rbp), %rdi
movl -0x28(%rbp), %ecx
leaq 0x19953(%rip), %rsi     # 0x2b714
leaq 0x19947(%rip), %rax     # 0x2b70f
cmpl $0x0, %ecx
cmovneq %rax, %rsi
callq 0x64d0
leaq -0x60(%rbp), %rsi
leaq 0x19939(%rip), %rdi     # 0x2b718
movb $0x0, %al
callq 0xd8f0
jmp 0x12396
cmpl $0x0, -0x28(%rbp)
je 0x11e11
movl $0x8, %edi
callq 0xaa60
testb $0x1, %al
jne 0x11e01
jmp 0x11e11
leaq 0x1992a(%rip), %rdi     # 0x2b732
movb $0x0, %al
callq 0xd8f0
jmp 0x11e71
cmpl $0x0, -0x28(%rbp)
je 0x11e2c
movq -0x18(%rbp), %rax
movl 0x88(%rax), %ecx
addl $0x5, %ecx
movl %ecx, 0x88(%rax)
jmp 0x11e3f
movq -0x18(%rbp), %rax
movl 0x84(%rax), %ecx
addl $0x5, %ecx
movl %ecx, 0x84(%rax)
cmpb $0x0, -0x61(%rbp)
je 0x11e6f
leaq -0x60(%rbp), %rsi
movl -0x28(%rbp), %ecx
leaq 0x17aee(%rip), %rdx     # 0x29941
leaq 0x1c455(%rip), %rax     # 0x2e2af
cmpl $0x0, %ecx
cmovneq %rax, %rdx
leaq 0x198e6(%rip), %rdi     # 0x2b74e
movb $0x0, %al
callq 0xd8f0
jmp 0x11e71
jmp 0x12396
movsbl -0x60(%rbp), %edi
callq 0x6320
movb %al, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x11eaf
leaq 0x24e31(%rip), %rax     # 0x36cc8
cmpq $0x0, (%rax)
je 0x11eaf
leaq 0x24e24(%rip), %rax     # 0x36cc8
movq (%rax), %rax
movl 0x34(%rax), %eax
movl %eax, -0x6c(%rbp)
jmp 0x11eb9
movq -0x78(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0xa0(%rbp)
movq -0x78(%rbp), %rdi
xorl %esi, %esi
callq 0x16c60
movl %eax, %ecx
movl -0xa0(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x11ef7
movl $0x8, %edi
callq 0xaa60
testb $0x1, %al
jne 0x11ef0
jmp 0x11ef7
movl $0xffffff9c, -0x68(%rbp) # imm = 0xFFFFFF9C
leaq 0x213f2(%rip), %rax     # 0x332f0
movl (%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %edi
addl $0x3, %edi
movl -0x68(%rbp), %esi
movl $0x1, %edx
callq 0xcb90
cmpl $0x0, %eax
je 0x11fb1
cmpb $0x0, -0x61(%rbp)
je 0x11f53
movl -0x28(%rbp), %ecx
leaq 0x1c37c(%rip), %rsi     # 0x2e2af
leaq 0x19852(%rip), %rax     # 0x2b78c
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq -0x60(%rbp), %rdx
leaq 0x1982c(%rip), %rdi     # 0x2b778
movb $0x0, %al
callq 0xd8f0
cmpl $0x0, -0x28(%rbp)
je 0x11f7a
movl $0x1, %edi
movl $0x6, %esi
callq 0xef70
xorl %edi, %edi
subl %eax, %edi
xorl %esi, %esi
movl $0xfffffff0, %edx       # imm = 0xFFFFFFF0
callq 0x16860
jmp 0x11fac
movl $0x1, %edi
movl $0x6, %esi
callq 0xef70
movl %eax, %edx
movq -0x78(%rbp), %rax
movl 0x30(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x30(%rax)
movq -0x78(%rbp), %rax
cmpl $0x1, 0x30(%rax)
jge 0x11faa
movb $0x0, -0x62(%rbp)
jmp 0x11d60
jmp 0x11fac
jmp 0x1203e
cmpb $0x0, -0x61(%rbp)
je 0x11fc9
leaq -0x60(%rbp), %rsi
leaq 0x197d2(%rip), %rdi     # 0x2b794
movb $0x0, %al
callq 0xd8f0
xorl %edi, %edi
movl $0x29, %esi
movl $0x3, %edx
callq 0x24020
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movl $0x3, 0x2c(%rax)
movl $0x2, %edi
movb $0x0, %al
callq 0xef20
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x88(%rbp), %rax
movl $0x1, 0x24(%rax)
movq -0x88(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x50(%rcx), %rcx
movq %rcx, (%rax)
movq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0x25c30
jmp 0x12396
movsbl -0x60(%rbp), %edi
callq 0x6320
movb %al, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x12082
leaq 0x24c61(%rip), %rax     # 0x36cc8
cmpq $0x0, (%rax)
je 0x12082
leaq 0x24c54(%rip), %rax     # 0x36cc8
movq (%rax), %rax
movl 0x34(%rax), %eax
movl %eax, -0x90(%rbp)
jmp 0x12092
movq -0x98(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0xa4(%rbp)
movq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x16c60
movl %eax, %ecx
movl -0xa4(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x120dc
movl $0x8, %edi
callq 0xaa60
testb $0x1, %al
jne 0x120d2
jmp 0x120dc
movl $0xffffff9c, -0x8c(%rbp) # imm = 0xFFFFFF9C
leaq 0x2120d(%rip), %rax     # 0x332f0
movl (%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %edi
addl $0x3, %edi
movl -0x8c(%rbp), %esi
xorl %edx, %edx
callq 0xcb90
cmpl $0x0, %eax
je 0x121e0
cmpb $0x0, -0x61(%rbp)
je 0x12120
leaq -0x60(%rbp), %rsi
leaq 0x19694(%rip), %rdi     # 0x2b7ad
movb $0x0, %al
callq 0xd8f0
cmpl $0x0, -0x28(%rbp)
je 0x12186
xorl %edi, %edi
callq 0xcaa0
cmpl $0x0, %eax
jne 0x12146
movl $0x3, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x16910
movl $0x2, %edi
callq 0x18220
testb $0x1, %al
jne 0x12165
movl $0x1, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %edx, %edi
callq 0x16910
movl $0x1, %edi
movl $0x4, %esi
callq 0xef70
xorl %edi, %edi
subl %eax, %edi
xorl %esi, %esi
movl $0xfffffff1, %edx       # imm = 0xFFFFFFF1
callq 0x16860
jmp 0x121de
movq -0x18(%rbp), %rsi
xorl %edi, %edi
callq 0xcd80
cmpl $0x0, %eax
jne 0x121a6
movq -0x98(%rbp), %rax
movl 0x10(%rax), %ecx
subl $0x1, %ecx
movl %ecx, 0x10(%rax)
movl $0x1, %edi
movl $0x4, %esi
callq 0xef70
movl %eax, %edx
movq -0x98(%rbp), %rax
movl 0x30(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x30(%rax)
movq -0x98(%rbp), %rax
cmpl $0x1, 0x30(%rax)
jge 0x121dc
movb $0x0, -0x62(%rbp)
jmp 0x11d60
jmp 0x121de
jmp 0x121fa
cmpb $0x0, -0x61(%rbp)
je 0x121f8
leaq -0x60(%rbp), %rsi
leaq 0x195d6(%rip), %rdi     # 0x2b7c7
movb $0x0, %al
callq 0xd8f0
jmp 0x121fa
jmp 0x12396
cmpl $0x0, -0x28(%rbp)
jne 0x12233
movl $0x64, %edi
movb $0x0, %al
callq 0xef20
cmpl $0xa, %eax
jge 0x12233
cmpb $0x0, -0x61(%rbp)
je 0x1222e
leaq -0x60(%rbp), %rsi
leaq 0x195bc(%rip), %rdi     # 0x2b7e3
movb $0x0, %al
callq 0xd8f0
jmp 0x11d60
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x12394
movl $0x64, %edi
movb $0x0, %al
callq 0xef20
cmpl $0xa, %eax
jge 0x12394
leaq 0x24aa7(%rip), %rax     # 0x36d09
movb $0x1, (%rax)
movl $0x64, %edi
movb $0x0, %al
callq 0xef20
cmpl $0xf, %eax
jge 0x12291
leaq 0x21133(%rip), %rax     # 0x333b0
movq (%rax), %rdi
leaq 0x24e49(%rip), %rsi     # 0x370d0
callq 0x26c70
jmp 0x12392
movl $0x64, %edi
movb $0x0, %al
callq 0xef20
cmpl $0xf, %eax
jge 0x122eb
leaq 0x21047(%rip), %rax     # 0x332f0
cmpl $0x2, (%rax)
jle 0x122eb
movl $0x2, %edi
movb $0x0, %al
callq 0xef20
addl $0x1, %eax
leaq 0x2102c(%rip), %rcx     # 0x332f0
movl (%rcx), %ecx
subl %eax, %ecx
leaq 0x21021(%rip), %rax     # 0x332f0
movl %ecx, (%rax)
xorl %edi, %edi
callq 0x13060
leaq 0x19515(%rip), %rdi     # 0x2b7f4
movb $0x0, %al
callq 0xd8f0
jmp 0x12390
movl $0x64, %edi
movb $0x0, %al
callq 0xef20
cmpl $0x28, %eax
jge 0x12333
movl $0x4, %edi
movb $0x0, %al
callq 0xef20
movl %eax, %ecx
leaq 0x20fdf(%rip), %rax     # 0x332f0
addl (%rax), %ecx
leaq 0x20fd6(%rip), %rax     # 0x332f0
movl %ecx, (%rax)
xorl %edi, %edi
callq 0x13060
leaq 0x194ed(%rip), %rdi     # 0x2b817
movb $0x0, %al
callq 0xd8f0
jmp 0x1238e
movl $0x64, %edi
movb $0x0, %al
callq 0xef20
cmpl $0x6, %eax
jge 0x12382
movl $0x8, %edi
callq 0xaa90
testb $0x1, %al
jne 0x12354
jmp 0x12382
leaq 0x194e7(%rip), %rdi     # 0x2b842
movb $0x0, %al
callq 0xd8f0
leaq 0x27ae7(%rip), %rax     # 0x39e50
movq (%rax), %rdi
movl $0x20, %esi
callq 0xdbc0
movl $0xfffffff3, %edi       # imm = 0xFFFFFFF3
callq 0x18260
jmp 0x1238c
leaq 0x24980(%rip), %rax     # 0x36d09
movb $0x0, (%rax)
jmp 0x1238e
jmp 0x12390
jmp 0x12392
jmp 0x12394
jmp 0x12396
callq 0x6060
movl -0x24(%rbp), %eax
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)