// File: /workspace/github_c_makefile_star2_O2/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 0x1f6ce(%rip), %rax     # 0x2dc50
movl 0x50(%rax), %esi
movl 0x54(%rax), %edi
callq 0xea05
testq %rax, %rax
je 0xe6e5
movq %rax, %r14
leaq 0x1f2ea(%rip), %rax     # 0x2d88a
cmpb $0x0, (%rax)
je 0xe6e5
testb $0x2, 0x10(%r14)
jne 0xe6e5
leaq 0x10d20(%rip), %rdi     # 0x1f2db
xorl %esi, %esi
callq 0xfd08
testq %rax, %rax
je 0xe6e5
movq 0x10(%rax), %rbx
leaq 0x1f28a(%rip), %rax     # 0x2d860
andl $0x0, (%rax)
leaq 0x1f260(%rip), %r15     # 0x2d840
movq (%r15), %rdi
cmpq %rdi, %rbx
sete %al
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0xe60b
pushq $0x1
popq %rsi
callq 0x934a
testb %al, %al
je 0xe60b
leaq 0x10cd9(%rip), %rdi     # 0x1f2df
jmp 0xe6d4
leaq 0x1f236(%rip), %rax     # 0x2d848
cmpq (%rax), %rbx
je 0xe6cd
leaq 0x1f71e(%rip), %rax     # 0x2dd40
cmpq (%rax), %rbx
je 0xe6c4
cmpq 0x8(%rax), %rbx
je 0xe6c4
movslq 0x28(%rbx), %r12
orl $0x2, 0x10(%r14)
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0x9359
testb %al, %al
je 0xe9fd
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x936c
movl 0x20(%rbx), %eax
cmpl $0x21, %eax
je 0xe7ec
cmpl $0x5d, %eax
je 0xe7b2
cmpl $0x2f, %eax
je 0xe6f0
cmpl $0x3d, %eax
je 0xe73c
cmpl $0x3f, %eax
je 0xe719
cmpl $0x29, %eax
jne 0xe79f
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x13, %eax
jg 0xe863
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9359
testb %al, %al
je 0xe945
incl 0x2c(%rbx)
movl 0x30(%rbx), %eax
incl %eax
jmp 0xe95d
leaq 0x10c72(%rip), %rdi     # 0x1f33d
jmp 0xe6d4
leaq 0x10c32(%rip), %rdi     # 0x1f306
xorl %eax, %eax
callq 0xb178
leaq 0x1bc1b(%rip), %rax     # 0x2a2fd
movb $0x0, (%rax)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
xorl %eax, %eax
callq 0xc004
movl %eax, %ebp
incl %ebp
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x18, %eax
jg 0xe80f
addl %ebp, 0x34(%rbx)
jmp 0xe830
leaq 0x21cb0(%rip), %rax     # 0x303d0
movb $0x1, (%rax,%r12)
leaq 0x21de4(%rip), %rax     # 0x30510
movq (%rax,%r12,8), %rsi
leaq 0x10c75(%rip), %rdi     # 0x1f3ac
jmp 0xe9f6
leaq 0x21ccd(%rip), %rax     # 0x30410
movb $0x1, (%rax,%r12)
movq %rbx, %rdi
callq 0x11e2a
testb %al, %al
je 0xe92e
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x18, %eax
jg 0xe8f0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9359
movl %eax, %ebp
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0xc004
incl %eax
testb %bpl, %bpl
je 0xe78c
addl 0x34(%rbx), %eax
movl %eax, 0x34(%rbx)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9370
jmp 0xe92e
leaq 0x10c66(%rip), %rdi     # 0x1f40c
xorl %eax, %eax
callq 0xb178
jmp 0xe9fd
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x1d, %eax
jg 0xe8ad
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9359
testb %al, %al
je 0xe96d
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0xc004
notl %eax
addl %eax, 0x34(%rbx)
jmp 0xe98a
leaq 0x21bfd(%rip), %rax     # 0x303f0
movb $0x1, (%rax,%r12)
leaq 0x21de1(%rip), %rax     # 0x305e0
movq (%rax,%r12,8), %rsi
leaq 0x10bbb(%rip), %rdi     # 0x1f3c5
jmp 0xe9f6
xorl %r14d, %r14d
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x9, %eax
jg 0xe830
movl 0x34(%rbx), %eax
subl %ebp, %eax
testl %eax, %eax
cmovgl %eax, %r14d
movl %r14d, 0x34(%rbx)
leaq 0x21bf9(%rip), %rax     # 0x30430
movb $0x1, (%rax,%r12)
imulq $0x18, %r12, %rax
leaq 0x21f19(%rip), %rcx     # 0x30760
movq (%rcx,%rax), %rdx
movq 0x8(%rcx,%rax), %rsi
leaq 0x10b37(%rip), %rdi     # 0x1f38e
xorl %eax, %eax
callq 0xb178
jmp 0xe9fd
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x9, %eax
jg 0xe9b4
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9359
testb %al, %al
je 0xe997
pushq $0x2
popq %rbp
movl %ebp, %edi
xorl %eax, %eax
callq 0xc004
notl %eax
movl %eax, 0x2c(%rbx)
movl %ebp, %edi
xorl %eax, %eax
callq 0xc004
notl %eax
movl %eax, 0x30(%rbx)
jmp 0xe9a9
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0xe, %eax
jg 0xe9e0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9359
testb %al, %al
je 0xe9c1
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0xc004
imulq $0xc, %r12, %rcx
leaq 0x1d618(%rip), %rdx     # 0x2bf00
addl (%rdx,%rcx), %eax
jmp 0xe9d2
pushq $0x64
popq %rdi
xorl %eax, %eax
callq 0xc004
cmpl $0x9, %eax
jg 0xe92e
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9359
movl %eax, %ebp
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0xc004
notl %eax
testb %bpl, %bpl
jne 0xe920
addl 0x34(%rbx), %eax
movl %eax, 0x34(%rbx)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x936c
leaq 0x21d5b(%rip), %rax     # 0x30690
movq (%rax,%r12,8), %rsi
leaq 0x10aa9(%rip), %rdi     # 0x1f3e9
jmp 0xe9f6
pushq $0x2
popq %rbp
movl %ebp, %edi
xorl %eax, %eax
callq 0xc004
movl %eax, 0x2c(%rbx)
movl %ebp, %edi
xorl %eax, %eax
callq 0xc004
movl %eax, 0x30(%rbx)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9370
jmp 0xe9b4
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0xc004
imulq $0xc, %r12, %rcx
leaq 0x1d57e(%rip), %rdx     # 0x2bf00
movl (%rdx,%rcx), %ecx
subl %eax, %ecx
movl %ecx, 0x34(%rbx)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x9370
jmp 0xe9e0
movq 0x2c(%rbx), %xmm0
pcmpeqd %xmm1, %xmm1
paddd %xmm0, %xmm1
movq %xmm1, 0x2c(%rbx)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x936c
shlq $0x4, %r12
leaq 0x1d5c1(%rip), %rax     # 0x2bf80
jmp 0xe9eb
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0xc004
movl 0x34(%rbx), %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x34(%rbx)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x936c
shlq $0x4, %r12
leaq 0x1d465(%rip), %rax     # 0x2be50
movq (%rax,%r12), %rsi
leaq 0x1097d(%rip), %rdi     # 0x1f373
xorl %eax, %eax
callq 0xb178
movq %rbx, (%r15)
jmp 0xe6e5