// File: /workspace/github_c_makefile_star2_O3/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 0x1bbce(%rip), %r14     # 0x2dd50
cmpq $0x0, (%r14)
je 0x121ac
cmpq $0x0, 0x8(%r14)
je 0x121ac
leaq 0xfb96(%rip), %rdi      # 0x21d2c
xorl %eax, %eax
callq 0xb620
leaq 0x18169(%rip), %rax     # 0x2a30d
movb $0x0, (%rax)
jmp 0x12279
leaq 0xfb94(%rip), %rdi      # 0x21d47
movl $0x3d, %esi
callq 0x10749
testq %rax, %rax
je 0x12279
movq 0x10(%rax), %rbx
cmpl $0x3d, 0x20(%rbx)
jne 0x1226b
movq %rbx, %rdi
callq 0xd2fe
testb %al, %al
jne 0x12279
movq (%r14), %rax
testq %rax, %rax
jne 0x121f7
cmpq $0x0, 0x8(%r14)
je 0x12287
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 0x12228
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9531
testb %al, %al
jne 0x1240e
movl 0x34(%rbx), %eax
testl %eax, %eax
jns 0x12241
movl $0x20, %esi
movq %rbx, %rdi
callq 0x9531
testb %al, %al
jne 0x1240e
leal -0x1(%r15), %eax
cmpl $0x18, %eax
ja 0x1240e
leaq 0xf94f(%rip), %rcx      # 0x21ba4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x34(%rbx), %esi
movl $0x1, %edi
jmp 0x12366
leaq 0xfadc(%rip), %rdi      # 0x21d4e
xorl %eax, %eax
callq 0xb620
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %r15d, %r15d
xorl %edi, %edi
callq 0x124ee
testb %al, %al
je 0x12201
jmp 0x12279
leaq 0x1e17e(%rip), %rax     # 0x30420
movb $0x1, 0x16(%rax)
leaq 0x1b9b3(%rip), %r14     # 0x2dc60
movq 0x70(%r14), %rax
testq %rax, %rax
je 0x1240e
andb $-0x2, 0x5c(%rax)
leaq 0x50(%r14), %rdi
callq 0xeba8
leaq 0x1e712(%rip), %r12     # 0x309e0
movq (%r12), %rdi
movl 0x50(%r14), %edx
movl 0x54(%r14), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0x1240e
movq (%r12), %rdi
jmp 0x123ad
movl 0x34(%rbx), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x34(%rbx)
testl %eax, %eax
jle 0x123fa
xorl %edi, %edi
callq 0x11ee4
leaq 0xfa5d(%rip), %rdi      # 0x21d6d
xorl %eax, %eax
callq 0xb620
jmp 0x1240e
movl 0x34(%rbx), %esi
movl $0x2, %edi
jmp 0x12366
leaq 0x1e0f3(%rip), %rax     # 0x30420
movb $0x1, 0x11(%rax)
leaq 0x1b928(%rip), %rax     # 0x2dc60
orb $0x1, 0x78(%rax)
xorl %edi, %edi
callq 0xcae0
jmp 0x1240e
movl 0x34(%rbx), %esi
movl $0x4, %edi
jmp 0x12366
xorl %eax, %eax
callq 0xd288
jmp 0x1240e
movl 0x34(%rbx), %esi
movl $0x3, %edi
movl $0x2, %edx
callq 0x11d8e
jmp 0x1240e
leaq 0x1b8e4(%rip), %r12     # 0x2dc60
orb $0x10, 0x79(%r12)
leaq 0x50(%r12), %rdi
callq 0xeba8
leaq 0x1e64d(%rip), %r14     # 0x309e0
movq (%r14), %rdi
movl 0x50(%r12), %edx
movl 0x54(%r12), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0x1240e
movq (%r14), %rdi
movl $0x40, %esi
callq 0x64c0
jmp 0x1240e
leaq 0x1b8a0(%rip), %rax     # 0x2dc60
orb $0x40, 0x79(%rax)
jmp 0x1240e
leaq 0x1b993(%rip), %rax     # 0x2dd60
movq (%rax), %rax
movl $0x18, 0x10(%rax)
jmp 0x1240e
xorl %eax, %eax
callq 0x9560
jmp 0x1240e
leaq -0x92f7(%rip), %rdi     # 0x90f2
movl $0x1, %esi
movl $0x96, %edx
callq 0x8ba7
jmp 0x1240e
movl $0x0, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x9553
leaq 0x1e00b(%rip), %rax     # 0x30420
leaq 0x1de24(%rip), %r12     # 0x30240
movq (%r12,%r15,8), %rdi
cmpb $0x1, (%rax,%r15)
jne 0x1243b
testq %rdi, %rdi
je 0x124a9
callq 0x6050
movq $0x0, (%r12,%r15,8)
jmp 0x124a9
testq %rdi, %rdi
jne 0x124a9
leaq 0x1b429(%rip), %rax     # 0x2d870
movl $0x0, (%rax)
leaq 0x1e24c(%rip), %rax     # 0x306a0
movq (%rax,%r15,8), %rsi
movq %rsp, %r14
movq %r14, %rdi
callq 0x60e0
leaq 0x17f2c(%rip), %rdi     # 0x2a396
xorl %eax, %eax
callq 0xb620
leaq 0x1e568(%rip), %rax     # 0x309e0
movq (%rax), %rsi
movq %r14, %rdi
callq 0xfd31
testl %eax, %eax
jne 0x124a9
movq %rsp, %r14
movq %r14, %rdi
callq 0x6170
leal 0x1(%rax), %edi
callq 0xbe2a
movq %rax, (%r12,%r15,8)
movq %rax, %rdi
movq %r14, %rsi
callq 0x60e0
leaq 0x1b3c0(%rip), %rax     # 0x2d870
movl $0x0, (%rax)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1aa04
leaq 0xf8c9(%rip), %rdi      # 0x21d93
movq %rax, %rsi
xorl %eax, %eax
callq 0xb620
callq 0x128e5
leaq 0x1b3b4(%rip), %rcx     # 0x2d894
movl %eax, (%rcx)
leaq 0x1b3ba(%rip), %rax     # 0x2d8a3
jmp 0x121a4