// File: /workspace/github_c_makefile_star2_O1/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 0x1ee80(%rip), %rax     # 0x2de68
movslq (%rax), %rdx
testq %rdx, %rdx
jle 0xf029
leaq 0x1ec69(%rip), %rcx     # 0x2dc60
movl 0x50(%rcx), %eax
movl 0x54(%rcx), %ecx
leaq (%rdx,%rdx,2), %rdx
shlq $0x3, %rdx
addq 0x1afb4(%rip), %rdx     # 0x29fc0
leaq 0x1ed5d(%rip), %r12     # 0x2dd70
cmpl %ecx, 0x4(%r12)
jne 0xf020
cmpl %eax, (%r12)
je 0xf02c
addq $0x18, %r12
cmpq %rdx, %r12
jb 0xf013
xorl %r12d, %r12d
testq %r12, %r12
je 0xf17d
leaq 0x1e85e(%rip), %rax     # 0x2d89a
cmpb $0x0, (%rax)
je 0xf17d
testb $0x2, 0x10(%r12)
jne 0xf17d
leaq 0x12211(%rip), %rdi     # 0x21269
xorl %esi, %esi
callq 0x10881
testq %rax, %rax
je 0xf17d
movq 0x10(%rax), %rbx
leaq 0x1e7fd(%rip), %rax     # 0x2d870
movl $0x0, (%rax)
leaq 0x1e7d0(%rip), %r14     # 0x2d850
movq (%r14), %rdi
cmpq %rdi, %rbx
sete %al
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0xf0ad
movl $0x1, %esi
callq 0x95b3
testb %al, %al
je 0xf0ad
leaq 0x121c5(%rip), %rdi     # 0x2126d
jmp 0xf16c
leaq 0x1e7a4(%rip), %rax     # 0x2d858
cmpq (%rax), %rbx
je 0xf165
leaq 0x1ec8c(%rip), %rax     # 0x2dd50
cmpq (%rax), %rbx
je 0xf15c
cmpq 0x8(%rax), %rbx
je 0xf15c
movslq 0x28(%rbx), %r15
orl $0x2, 0x10(%r12)
testq %rbx, %rbx
je 0xf4e2
movl $0x10, %esi
movq %rbx, %rdi
callq 0x95c2
testb %al, %al
je 0xf4e2
movl $0x2, %esi
movq %rbx, %rdi
callq 0x95d5
movl 0x20(%rbx), %eax
cmpl $0x3c, %eax
jg 0xf188
cmpl $0x21, %eax
je 0xf1df
cmpl $0x29, %eax
je 0xf280
cmpl $0x2f, %eax
jne 0xf26d
movl $0x8, %edi
xorl %eax, %eax
callq 0xc72d
movl %eax, %ebp
incl %ebp
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x18, %eax
jg 0xf2da
addl %ebp, 0x34(%rbx)
jmp 0xf2fd
leaq 0x12168(%rip), %rdi     # 0x212cb
jmp 0xf16c
leaq 0x12128(%rip), %rdi     # 0x21294
xorl %eax, %eax
callq 0xb6e0
leaq 0x1b193(%rip), %rax     # 0x2a30d
movb $0x0, (%rax)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3d, %eax
je 0xf202
cmpl $0x3f, %eax
je 0xf2b7
cmpl $0x5d, %eax
jne 0xf26d
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x1d, %eax
jg 0xf330
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95c2
testb %al, %al
je 0xf427
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
notl %eax
addl %eax, 0x34(%rbx)
jmp 0xf446
leaq 0x2121a(%rip), %rax     # 0x30400
movb $0x1, (%rax,%r15)
leaq 0x213fe(%rip), %rax     # 0x305f0
movq (%rax,%r15,8), %rsi
leaq 0x12156(%rip), %rdi     # 0x21353
jmp 0xf4db
leaq 0x21217(%rip), %rax     # 0x30420
movb $0x1, (%rax,%r15)
movq %rbx, %rdi
callq 0x12c18
testb %al, %al
je 0xf410
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x18, %eax
jg 0xf3ca
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95c2
movl %eax, %ebp
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
incl %eax
testb %bpl, %bpl
je 0xf258
addl 0x34(%rbx), %eax
movl %eax, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95d9
jmp 0xf410
leaq 0x12126(%rip), %rdi     # 0x2139a
xorl %eax, %eax
callq 0xb6e0
jmp 0xf4e2
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x13, %eax
jg 0xf379
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95c2
testb %al, %al
je 0xf455
incl 0x2c(%rbx)
movl 0x30(%rbx), %eax
incl %eax
jmp 0xf470
leaq 0x21122(%rip), %rax     # 0x303e0
movb $0x1, (%rax,%r15)
leaq 0x21256(%rip), %rax     # 0x30520
movq (%rax,%r15,8), %rsi
leaq 0x12065(%rip), %rdi     # 0x2133a
jmp 0xf4db
xorl %r12d, %r12d
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x9, %eax
jg 0xf2fd
movl 0x34(%rbx), %eax
subl %ebp, %eax
testl %eax, %eax
cmovgl %eax, %r12d
movl %r12d, 0x34(%rbx)
leaq 0x2113c(%rip), %rax     # 0x30440
movb $0x1, (%rax,%r15)
leaq (%r15,%r15,2), %rax
leaq 0x2145c(%rip), %rcx     # 0x30770
movq (%rcx,%rax,8), %rdx
movq 0x8(%rcx,%rax,8), %rsi
leaq 0x11ff8(%rip), %rdi     # 0x2131c
xorl %eax, %eax
callq 0xb6e0
jmp 0xf4e2
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0xe, %eax
jg 0xf4a5
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95c2
testb %al, %al
je 0xf482
movl $0x3, %edi
xorl %eax, %eax
callq 0xc72d
leaq (%r15,%r15,2), %rcx
leaq 0x1cb9f(%rip), %rdx     # 0x2bf10
addl (%rdx,%rcx,4), %eax
jmp 0xf495
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x9, %eax
jg 0xf4c5
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95c2
testb %al, %al
je 0xf4b2
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
notl %eax
movl %eax, 0x2c(%rbx)
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
notl %eax
movl %eax, 0x30(%rbx)
jmp 0xf4b8
movl $0x64, %edi
xorl %eax, %eax
callq 0xc72d
cmpl $0x9, %eax
jg 0xf410
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95c2
movl %eax, %ebp
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
notl %eax
testb %bpl, %bpl
jne 0xf400
addl 0x34(%rbx), %eax
movl %eax, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95d5
leaq 0x21289(%rip), %rax     # 0x306a0
movq (%rax,%r15,8), %rsi
leaq 0x11f55(%rip), %rdi     # 0x21377
jmp 0xf4db
movl $0x3, %edi
xorl %eax, %eax
callq 0xc72d
leaq (%r15,%r15,2), %rcx
leaq 0x1cad2(%rip), %rdx     # 0x2bf10
movl (%rdx,%rcx,4), %ecx
subl %eax, %ecx
movl %ecx, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95d9
jmp 0xf4a5
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
movl %eax, 0x2c(%rbx)
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
movl %eax, 0x30(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95d9
jmp 0xf4c5
movl $0x2, %edi
xorl %eax, %eax
callq 0xc72d
movl 0x34(%rbx), %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95d5
shlq $0x4, %r15
leaq 0x1c9b0(%rip), %rax     # 0x2be60
jmp 0xf4d0
decl 0x2c(%rbx)
decl 0x30(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95d5
shlq $0x4, %r15
leaq 0x1cac0(%rip), %rax     # 0x2bf90
movq (%rax,%r15), %rsi
leaq 0x11e26(%rip), %rdi     # 0x21301
xorl %eax, %eax
callq 0xb6e0
movq %rbx, (%r14)
jmp 0xf17d