// File: /workspace/github_c_makefile_star2_O3/ajpaulson[P]srogue11/move.c
// Function: dip_it
int dip_it()
{
	struct linked_list *what;
	struct object *ob;
	struct trap *tp;
	int wh;

	tp = trap_at(hero.y,hero.x);
	if (tp == NULL || inpool == FALSE || (tp->tr_flags & ISGONE))
		return 0;

	if ((what = get_item("dip",0)) == NULL)
		return 0;
	ob = OBJPTR(what);
	mpos = 0;
	/*
	 * If hero is trying to dip an object OTHER than his
	 * current weapon, make sure that he could drop his
	 * current weapon
	 */
	if (ob != cur_weapon) {
		if (cur_weapon != NULL && o_on(cur_weapon, ISCURSED)) {
			msg("You are unable to release your weapon.");
			after = FALSE;
			return 0;
		}
	}
	if (ob == cur_armor) {
		msg("You have to take off your armor before you can dip it.");
		after = FALSE;
		return 0;
	}
	else if (ob == cur_ring[LEFT] || ob == cur_ring[RIGHT]) {
		msg("You have to take that ring off before you can dip it.");
		after = FALSE;
		return 0;
	}
	wh = ob->o_which;
	tp->tr_flags |= ISGONE;
	if (ob != NULL && o_off(ob,ISPROT)) {
		setoflg(ob,ISKNOW);
		switch(ob->o_type) {
		case WEAPON:
			if(rnd(100) < 20) {		/* enchant weapon here */
				if (o_off(ob,ISCURSED)) {
					ob->o_hplus += 1;
					ob->o_dplus += 1;
				}
				else {		/* weapon was prev cursed here */
					ob->o_hplus = rnd(2);
					ob->o_dplus = rnd(2);
				}
				resoflg(ob,ISCURSED);
			}
			else if(rnd(100) < 10) {	/* curse weapon here */
				if (o_off(ob,ISCURSED)) {
					ob->o_hplus = -(rnd(2)+1);
					ob->o_dplus = -(rnd(2)+1);
				}
				else {			/* if already cursed */
					ob->o_hplus--;
					ob->o_dplus--;
				}
				setoflg(ob,ISCURSED);
			}			
			msg("The %s glows for a moment.",w_magic[wh].mi_name);
		when ARMOR:
			if (rnd(100) < 30) {			/* enchant armor */
				if(o_off(ob,ISCURSED))
					ob->o_ac -= rnd(2) + 1;
				else
					ob->o_ac = -rnd(3)+ armors[wh].a_class;
				resoflg(ob,ISCURSED);
			}
			else if(rnd(100) < 15){			/* curse armor */
				if (o_off(ob,ISCURSED))
					ob->o_ac = rnd(3)+ armors[wh].a_class;
				else
					ob->o_ac += rnd(2) + 1;
				setoflg(ob,ISCURSED);
			}
			msg("The %s glows for a moment.",a_magic[wh].mi_name);
		when STICK: {
			int i;
			struct rod *rd;

			i = rnd(8) + 1;
			if(rnd(100) < 25)		/* add charges */
				ob->o_charges += i;
			else if(rnd(100) < 10) {	/* remove charges */
				if ((ob->o_charges -= i) < 0)
					ob->o_charges = 0;
			}
			ws_know[wh] = TRUE;
			rd = &ws_stuff[wh];
			msg("The %s %s glows for a moment.",rd->ws_made,rd->ws_type);
		}
		when SCROLL:
			s_know[wh] = TRUE;
			msg("The '%s' scroll unfurls.",s_names[wh]);
		when POTION:
			p_know[wh] = TRUE;
			msg("The %s potion bubbles for a moment.",p_colors[wh]);
		when RING:
			r_know[wh] = TRUE;
			if (magring(ob)) {
				if(rnd(100) < 25) {	 		/* enchant ring */
					if (o_off(ob,ISCURSED))
						ob->o_ac += rnd(2) + 1;
					else
						ob->o_ac = rnd(2) + 1;
					resoflg(ob,ISCURSED);
				}
				else if(rnd(100) < 10) {	 /* curse ring */
					if (o_off(ob,ISCURSED))
						ob->o_ac = -(rnd(2) + 1);
					else
						ob->o_ac -= (rnd(2) + 1);
					setoflg(ob,ISCURSED);
				}
			}
			msg("The %s ring vibrates for a moment.",r_stones[wh]);
		otherwise:
			msg("The pool bubbles for a moment.");
		}
	}
	cur_weapon = ob;	/* hero has to weild item to dip it */
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x1ef7e(%rip), %rax     # 0x2de68
movslq (%rax), %rdx
testq %rdx, %rdx
jle 0xef2b
leaq 0x1ed67(%rip), %rcx     # 0x2dc60
movl 0x50(%rcx), %eax
movl 0x54(%rcx), %ecx
leaq (%rdx,%rdx,2), %rdx
shlq $0x3, %rdx
addq 0x1b0b2(%rip), %rdx     # 0x29fc0
leaq 0x1ee5b(%rip), %r12     # 0x2dd70
cmpl %ecx, 0x4(%r12)
jne 0xef22
cmpl %eax, (%r12)
je 0xef36
addq $0x18, %r12
cmpq %rdx, %r12
jb 0xef15
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e95d(%rip), %rax     # 0x2d89a
cmpb $0x0, (%rax)
je 0xef2b
testb $0x2, 0x10(%r12)
jne 0xef2b
leaq 0x1238a(%rip), %rdi     # 0x212db
xorl %esi, %esi
callq 0x10749
testq %rax, %rax
je 0xef2b
movq 0x10(%rax), %rbx
leaq 0x1e908(%rip), %rax     # 0x2d870
movl $0x0, (%rax)
leaq 0x1e8db(%rip), %r14     # 0x2d850
movq (%r14), %rdi
cmpq %rdi, %rbx
sete %al
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0xefa2
movl $0x1, %esi
callq 0x9531
testb %al, %al
je 0xefa2
leaq 0x12342(%rip), %rdi     # 0x212df
jmp 0xf054
leaq 0x1e8af(%rip), %rax     # 0x2d858
cmpq (%rax), %rbx
je 0xf04d
leaq 0x1ed97(%rip), %rax     # 0x2dd50
cmpq (%rax), %rbx
je 0xf044
cmpq 0x8(%rax), %rbx
je 0xf044
movslq 0x28(%rbx), %r15
orl $0x2, 0x10(%r12)
movl $0x10, %esi
movq %rbx, %rdi
callq 0x9540
testb %al, %al
je 0xf3d0
movl $0x2, %esi
movq %rbx, %rdi
callq 0x9553
movl 0x20(%rbx), %eax
cmpl $0x3c, %eax
jg 0xf06a
cmpl $0x21, %eax
je 0xf0c1
cmpl $0x29, %eax
je 0xf162
cmpl $0x2f, %eax
jne 0xf14f
movl $0x8, %edi
xorl %eax, %eax
callq 0xc674
movl %eax, %ebp
incl %ebp
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x18, %eax
jg 0xf1bc
addl %ebp, 0x34(%rbx)
jmp 0xf1df
leaq 0x122f2(%rip), %rdi     # 0x2133d
jmp 0xf054
leaq 0x122b2(%rip), %rdi     # 0x21306
xorl %eax, %eax
callq 0xb620
leaq 0x1b2ab(%rip), %rax     # 0x2a30d
movb $0x0, (%rax)
jmp 0xef2b
cmpl $0x3d, %eax
je 0xf0e4
cmpl $0x3f, %eax
je 0xf199
cmpl $0x5d, %eax
jne 0xf14f
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x1d, %eax
jg 0xf212
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9540
testb %al, %al
je 0xf309
movl $0x2, %edi
xorl %eax, %eax
callq 0xc674
notl %eax
addl %eax, 0x34(%rbx)
jmp 0xf328
leaq 0x21338(%rip), %rax     # 0x30400
movb $0x1, (%rax,%r15)
leaq 0x2151c(%rip), %rax     # 0x305f0
movq (%rax,%r15,8), %rsi
leaq 0x122e6(%rip), %rdi     # 0x213c5
jmp 0xf3c9
leaq 0x21335(%rip), %rax     # 0x30420
movb $0x1, (%rax,%r15)
movq %rbx, %rdi
callq 0x12aa8
testb %al, %al
je 0xf2f2
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x18, %eax
jg 0xf2ac
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9540
movl %eax, %ebp
movl $0x2, %edi
xorl %eax, %eax
callq 0xc674
incl %eax
testb %bpl, %bpl
je 0xf13a
addl 0x34(%rbx), %eax
movl %eax, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9557
jmp 0xf2f2
leaq 0x122b6(%rip), %rdi     # 0x2140c
xorl %eax, %eax
callq 0xb620
jmp 0xf3d0
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x13, %eax
jg 0xf25b
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9540
testb %al, %al
je 0xf337
incl 0x2c(%rbx)
movl 0x30(%rbx), %eax
incl %eax
jmp 0xf352
leaq 0x21240(%rip), %rax     # 0x303e0
movb $0x1, (%rax,%r15)
leaq 0x21374(%rip), %rax     # 0x30520
movq (%rax,%r15,8), %rsi
leaq 0x121f5(%rip), %rdi     # 0x213ac
jmp 0xf3c9
xorl %r12d, %r12d
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x9, %eax
jg 0xf1df
movl 0x34(%rbx), %eax
subl %ebp, %eax
testl %eax, %eax
cmovgl %eax, %r12d
movl %r12d, 0x34(%rbx)
leaq 0x2125a(%rip), %rax     # 0x30440
movb $0x1, (%rax,%r15)
leaq (%r15,%r15,2), %rax
leaq 0x2157a(%rip), %rcx     # 0x30770
movq (%rcx,%rax,8), %rdx
movq 0x8(%rcx,%rax,8), %rsi
leaq 0x12188(%rip), %rdi     # 0x2138e
xorl %eax, %eax
callq 0xb620
jmp 0xf3d0
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0xe, %eax
jg 0xf387
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9540
testb %al, %al
je 0xf364
movl $0x3, %edi
xorl %eax, %eax
callq 0xc674
leaq (%r15,%r15,2), %rcx
leaq 0x1ccbd(%rip), %rdx     # 0x2bf10
addl (%rdx,%rcx,4), %eax
jmp 0xf377
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x9, %eax
jg 0xf3b3
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9540
testb %al, %al
je 0xf394
movl $0x2, %edi
xorl %eax, %eax
callq 0xc674
notl %eax
movl %eax, 0x2c(%rbx)
movl $0x2, %edi
xorl %eax, %eax
callq 0xc674
notl %eax
movl %eax, 0x30(%rbx)
jmp 0xf3a6
movl $0x64, %edi
xorl %eax, %eax
callq 0xc674
cmpl $0x9, %eax
jg 0xf2f2
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9540
movl %eax, %ebp
movl $0x2, %edi
xorl %eax, %eax
callq 0xc674
notl %eax
testb %bpl, %bpl
jne 0xf2e2
addl 0x34(%rbx), %eax
movl %eax, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9553
leaq 0x213a7(%rip), %rax     # 0x306a0
movq (%rax,%r15,8), %rsi
leaq 0x120e5(%rip), %rdi     # 0x213e9
jmp 0xf3c9
movl $0x3, %edi
xorl %eax, %eax
callq 0xc674
leaq (%r15,%r15,2), %rcx
leaq 0x1cbf0(%rip), %rdx     # 0x2bf10
movl (%rdx,%rcx,4), %ecx
subl %eax, %ecx
movl %ecx, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9557
jmp 0xf387
movl $0x2, %edi
xorl %eax, %eax
callq 0xc674
movl %eax, 0x2c(%rbx)
movl $0x2, %edi
xorl %eax, %eax
callq 0xc674
movl %eax, 0x30(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9557
jmp 0xf3b3
movl $0x2, %edi
xorl %eax, %eax
callq 0xc674
movl 0x34(%rbx), %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9553
shlq $0x4, %r15
leaq 0x1cace(%rip), %rax     # 0x2be60
jmp 0xf3be
movq 0x2c(%rbx), %xmm0
pcmpeqd %xmm1, %xmm1
paddd %xmm0, %xmm1
movq %xmm1, 0x2c(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9553
shlq $0x4, %r15
leaq 0x1cbd2(%rip), %rax     # 0x2bf90
movq (%rax,%r15), %rsi
leaq 0x11faa(%rip), %rdi     # 0x21373
xorl %eax, %eax
callq 0xb620
movq %rbx, (%r14)
jmp 0xef2b