// File: /workspace/github_c_makefile_star2_O2/ajpaulson[P]srogue11/rings.c
// Function: ring_on
int ring_on()
{
	struct object *obj;
	struct linked_list *item;
	int ring, wh;
	char buf[LINLEN];
	bool okring;

	if (cur_ring[LEFT] != NULL && cur_ring[RIGHT] != NULL) {
		msg("Already wearing two rings.");
		after = FALSE;
		return 0;
	}
	/*
	 * Make certain that it is somethings that we want to wear
	 */
	if ((item = get_item("put on", RING)) == NULL)
		return 0;
	obj = OBJPTR(item);
	if (obj->o_type != RING) {
		msg("That won't fit on your finger.");
		return 0;
	}
	/*
	 * find out which hand to put it on
	 */
	if (is_current(obj))
		return 0;
	if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) {
		if ((ring = gethand(FALSE)))
			return 0;
	}
	else if (cur_ring[LEFT] == NULL)
		ring = LEFT;
	else
		ring = RIGHT;
	cur_ring[ring] = obj;
	wh = obj->o_which;
	/*
	 * okring = FALSE when:
	 * 1) ring is cursed and benefit = plus
	 * 2) ring is blessed and benefit = minus
	 */
	okring = !((obj->o_ac > 0 && o_on(obj, ISCURSED)) ||
	          (obj->o_ac < 0 && o_on(obj, ISBLESS)));
	/*
	 * Calculate the effect it has on the poor guy (if possible).
	 */
	if (okring) {
		switch (wh) {
			case R_SPEED:
				if (--obj->o_ac < 0) {
					obj->o_ac = 0;
					setoflg(obj,ISCURSED);
				}
				else {
					add_haste(FALSE);
					msg("You find yourself moving must faster.");
				}
			when R_GIANT:				/* to 24 */
				him->s_ef.a_str = MAXSTR;
			when R_ADDSTR:
				chg_abil(STR,obj->o_ac,FROMRING);
			when R_KNOW:
				chg_abil(WIS,obj->o_ac,FROMRING);
			when R_DEX:
				chg_abil(DEX,obj->o_ac,FROMRING);
			when R_CONST:
				chg_abil(CON,obj->o_ac,FROMRING);
			when R_SEEINVIS:
				player.t_flags |= CANSEE;
				light(&hero);
				mvwaddch(cw, hero.y, hero.x, PLAYER);
			when R_AGGR:
				aggravate();
			when R_HEAVY:
				updpack();			/* new pack weight */
			when R_BLIND:
				r_know[R_BLIND] = TRUE;
				player.t_flags |= ISBLIND;
				look(FALSE);
			when R_SLOW:
				player.t_flags |= ISSLOW;
			when R_SAPEM:
				fuse(sapem,TRUE,150);
			when R_LIGHT: {
				struct room *rop;

				r_know[R_LIGHT] = TRUE;
				if ((rop = player.t_room) != NULL) {
					rop->r_flags &= ~ISDARK;
					light(&hero);
					mvwaddch(cw, hero.y, hero.x, PLAYER);
				}
			}
		}
	}
	if (r_know[wh] && r_guess[wh]) {
		free(r_guess[wh]);
		r_guess[wh] = NULL;
	}
	else if(!r_know[wh] && r_guess[wh] == NULL) {
		mpos = 0;
		strcpy(buf, r_stones[wh]);
		msg(callit);
		if (get_str(buf, cw) == NORM) {
			r_guess[wh] = new(strlen(buf) + 1);
			strcpy(r_guess[wh], buf);
		}
	}
	mpos = 0;
	msg("Now wearing %s",inv_name(obj,TRUE));
	ringfood = ring_eat();
	nochange = FALSE;
  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x58, %rsp
leaq 0x1c7de(%rip), %r14     # 0x2dd40
cmpq $0x0, (%r14)
je 0x1158c
cmpq $0x0, 0x8(%r14)
je 0x1158c
leaq 0xe7b6(%rip), %rdi      # 0x1fd2c
xorl %eax, %eax
callq 0xb178
leaq 0x18d79(%rip), %rax     # 0x2a2fd
movb $0x0, (%rax)
jmp 0x11650
leaq 0xe7b4(%rip), %rdi      # 0x1fd47
pushq $0x3d
popq %rsi
callq 0xfd08
testq %rax, %rax
je 0x11650
movq 0x10(%rax), %rbx
cmpl $0x3d, 0x20(%rbx)
jne 0x11642
movq %rbx, %rdi
callq 0xcb75
testb %al, %al
jne 0x11650
movq (%r14), %rax
testq %rax, %rax
jne 0x115d5
cmpq $0x0, 0x8(%r14)
je 0x1165e
xorl %r15d, %r15d
testq %rax, %rax
setne %r15b
movq %rbx, (%r14,%r15,8)
movslq 0x28(%rbx), %r15
movl 0x34(%rbx), %eax
testl %eax, %eax
jle 0x11604
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x934a
testb %al, %al
jne 0x117d5
movl 0x34(%rbx), %eax
testl %eax, %eax
jns 0x1161b
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0x934a
testb %al, %al
jne 0x117d5
leal -0x1(%r15), %eax
cmpl $0x18, %eax
ja 0x117d5
leaq 0xe575(%rip), %rcx      # 0x1fba4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x34(%rbx), %esi
pushq $0x1
jmp 0x11737
leaq 0xe705(%rip), %rdi      # 0x1fd4e
xorl %eax, %eax
callq 0xb178
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %r15d, %r15d
xorl %edi, %edi
callq 0x118aa
testb %al, %al
je 0x115df
jmp 0x11650
leaq 0x1ed97(%rip), %rax     # 0x30410
movb $0x1, 0x16(%rax)
leaq 0x1c5cc(%rip), %r14     # 0x2dc50
movq 0x70(%r14), %rax
testq %rax, %rax
je 0x117d5
andb $-0x2, 0x5c(%rax)
leaq 0x50(%r14), %rdi
callq 0xe29f
leaq 0x1f32b(%rip), %r12     # 0x309d0
movq (%r12), %rdi
movl 0x50(%r14), %edx
movl 0x54(%r14), %esi
callq 0x6470
cmpl $-0x1, %eax
je 0x117d5
movq (%r12), %rdi
jmp 0x1177d
movl 0x34(%rbx), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x34(%rbx)
testl %eax, %eax
jle 0x117c6
xorl %edi, %edi
callq 0x112ea
leaq 0xe686(%rip), %rdi      # 0x1fd6d
xorl %eax, %eax
callq 0xb178
jmp 0x117d5
movl 0x34(%rbx), %esi
pushq $0x2
popq %rdi
movl %edi, %edx
jmp 0x1173b
leaq 0x1ed0c(%rip), %rax     # 0x30410
movb $0x1, 0x11(%rax)
leaq 0x1c541(%rip), %rax     # 0x2dc50
orb $0x1, 0x78(%rax)
xorl %edi, %edi
callq 0xc377
jmp 0x117d5
movl 0x34(%rbx), %esi
pushq $0x4
jmp 0x11737
xorl %eax, %eax
callq 0xcb05
jmp 0x117d5
movl 0x34(%rbx), %esi
pushq $0x3
popq %rdi
pushq $0x2
popq %rdx
callq 0x111a5
jmp 0x117d5
leaq 0x1c504(%rip), %r12     # 0x2dc50
orb $0x10, 0x79(%r12)
leaq 0x50(%r12), %rdi
callq 0xe29f
leaq 0x1f26d(%rip), %r14     # 0x309d0
movq (%r14), %rdi
movl 0x50(%r12), %edx
movl 0x54(%r12), %esi
callq 0x6470
cmpl $-0x1, %eax
je 0x117d5
movq (%r14), %rdi
pushq $0x40
popq %rsi
callq 0x64a0
jmp 0x117d5
leaq 0x1c4c2(%rip), %rax     # 0x2dc50
orb $0x40, 0x79(%rax)
jmp 0x117d5
leaq 0x1c5b5(%rip), %rax     # 0x2dd50
movq (%rax), %rax
movl $0x18, 0x10(%rax)
jmp 0x117d5
xorl %eax, %eax
callq 0x9378
jmp 0x117d5
leaq -0x8865(%rip), %rdi     # 0x8f52
pushq $0x1
popq %rsi
movl $0x96, %edx
callq 0x8a46
jmp 0x117d5
andl $0x0, 0x34(%rbx)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x936c
leaq 0x1ec34(%rip), %rax     # 0x30410
leaq 0x1ea4d(%rip), %r12     # 0x30230
movq (%r12,%r15,8), %rdi
cmpb $0x1, (%rax,%r15)
jne 0x117ff
testq %rdi, %rdi
je 0x1186a
callq 0x6050
andq $0x0, (%r12,%r15,8)
jmp 0x1186a
testq %rdi, %rdi
jne 0x1186a
leaq 0x1c055(%rip), %rax     # 0x2d860
andl $0x0, (%rax)
leaq 0x1ee7b(%rip), %rax     # 0x30690
movq (%rax,%r15,8), %rsi
movq %rsp, %r14
movq %r14, %rdi
callq 0x60e0
leaq 0x18b5b(%rip), %rdi     # 0x2a386
xorl %eax, %eax
callq 0xb178
leaq 0x1f197(%rip), %rax     # 0x309d0
movq (%rax), %rsi
movq %r14, %rdi
callq 0xf37e
testl %eax, %eax
jne 0x1186a
movq %rsp, %r14
movq %r14, %rdi
callq 0x6170
leal 0x1(%rax), %edi
callq 0xb8a5
movq %rax, (%r12,%r15,8)
movq %rax, %rdi
movq %r14, %rsi
callq 0x60e0
leaq 0x1bfef(%rip), %rax     # 0x2d860
andl $0x0, (%rax)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x1908c
leaq 0xe50d(%rip), %rdi      # 0x1fd93
movq %rax, %rsi
xorl %eax, %eax
callq 0xb178
callq 0x11c70
leaq 0x1bfe8(%rip), %rcx     # 0x2d884
movl %eax, (%rcx)
leaq 0x1bfee(%rip), %rax     # 0x2d893
jmp 0x11584