// File: /workspace/github_c_makefile_star2_O1/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 0x1ba42(%rip), %r14     # 0x2dd50
cmpq $0x0, (%r14)
je 0x12338
cmpq $0x0, 0x8(%r14)
je 0x12338
leaq 0xf992(%rip), %rdi      # 0x21cb4
xorl %eax, %eax
callq 0xb6e0
leaq 0x17fdd(%rip), %rax     # 0x2a30d
movb $0x0, (%rax)
jmp 0x12404
leaq 0xf990(%rip), %rdi      # 0x21ccf
movl $0x3d, %esi
callq 0x10881
testq %rax, %rax
je 0x12404
movq 0x10(%rax), %rbx
cmpl $0x3d, 0x20(%rbx)
jne 0x123f6
movq %rbx, %rdi
callq 0xd358
testb %al, %al
jne 0x12404
cmpq $0x0, (%r14)
setne %al
jne 0x1238b
cmpq $0x0, 0x8(%r14)
jne 0x1238b
xorl %edi, %edi
callq 0x12673
testb %al, %al
jne 0x12404
movzbl %al, %eax
movq %rbx, (%r14,%rax,8)
movslq 0x28(%rbx), %r15
cmpl $0x0, 0x34(%rbx)
jle 0x123b1
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95b3
testb %al, %al
jne 0x12585
cmpl $0x0, 0x34(%rbx)
jns 0x123cc
movl $0x20, %esi
movq %rbx, %rdi
callq 0x95b3
testb %al, %al
jne 0x12585
leal -0x1(%r15), %eax
cmpl $0x18, %eax
ja 0x12585
leaq 0xf74c(%rip), %rcx      # 0x21b2c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x34(%rbx), %esi
movl $0x1, %edi
jmp 0x124dd
leaq 0xf8d9(%rip), %rdi      # 0x21cd6
xorl %eax, %eax
callq 0xb6e0
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1e007(%rip), %rax     # 0x30420
movb $0x1, 0x16(%rax)
leaq 0x1b83c(%rip), %r14     # 0x2dc60
movq 0x70(%r14), %rax
testq %rax, %rax
je 0x12585
andb $-0x2, 0x5c(%rax)
leaq 0x50(%r14), %rdi
callq 0xecbc
leaq 0x1e59b(%rip), %r12     # 0x309e0
movq (%r12), %rdi
movl 0x50(%r14), %edx
movl 0x54(%r14), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0x12585
movq (%r12), %rdi
jmp 0x12524
movl 0x34(%rbx), %eax
leal -0x1(%rax), %ecx
movl %ecx, 0x34(%rbx)
testl %eax, %eax
jle 0x12571
xorl %edi, %edi
callq 0x12073
leaq 0xf86e(%rip), %rdi      # 0x21cf5
xorl %eax, %eax
callq 0xb6e0
jmp 0x12585
movl 0x34(%rbx), %esi
movl $0x2, %edi
jmp 0x124dd
leaq 0x1df7c(%rip), %rax     # 0x30420
movb $0x1, 0x11(%rax)
leaq 0x1b7b1(%rip), %rax     # 0x2dc60
orb $0x1, 0x78(%rax)
xorl %edi, %edi
callq 0xcb98
jmp 0x12585
movl 0x34(%rbx), %esi
movl $0x4, %edi
jmp 0x124dd
xorl %eax, %eax
callq 0xd2e2
jmp 0x12585
movl 0x34(%rbx), %esi
movl $0x3, %edi
movl $0x2, %edx
callq 0x11f24
jmp 0x12585
leaq 0x1b76d(%rip), %r12     # 0x2dc60
orb $0x10, 0x79(%r12)
leaq 0x50(%r12), %rdi
callq 0xecbc
leaq 0x1e4d6(%rip), %r14     # 0x309e0
movq (%r14), %rdi
movl 0x50(%r12), %edx
movl 0x54(%r12), %esi
callq 0x6490
cmpl $-0x1, %eax
je 0x12585
movq (%r14), %rdi
movl $0x40, %esi
callq 0x64c0
jmp 0x12585
leaq 0x1b729(%rip), %rax     # 0x2dc60
orb $0x40, 0x79(%rax)
jmp 0x12585
leaq 0x1b81c(%rip), %rax     # 0x2dd60
movq (%rax), %rax
movl $0x18, 0x10(%rax)
jmp 0x12585
xorl %eax, %eax
callq 0x95e0
jmp 0x12585
leaq -0x93b8(%rip), %rdi     # 0x91a8
movl $0x1, %esi
movl $0x96, %edx
callq 0x8c6f
jmp 0x12585
movl $0x0, 0x34(%rbx)
movl $0x1, %esi
movq %rbx, %rdi
callq 0x95d5
leaq 0x1de94(%rip), %rax     # 0x30420
movb (%rax,%r15), %al
cmpb $0x1, %al
jne 0x125b7
leaq 0x1dca5(%rip), %r14     # 0x30240
movq (%r14,%r15,8), %rdi
testq %rdi, %rdi
je 0x125b3
callq 0x6050
movq $0x0, (%r14,%r15,8)
jmp 0x1262e
testb %al, %al
jne 0x1262e
leaq 0x1dc82(%rip), %r12     # 0x30240
cmpq $0x0, (%r12,%r15,8)
jne 0x1262e
leaq 0x1b2a4(%rip), %rax     # 0x2d870
movl $0x0, (%rax)
leaq 0x1e0c7(%rip), %rax     # 0x306a0
movq (%rax,%r15,8), %rsi
movq %rsp, %r14
movq %r14, %rdi
callq 0x60e0
leaq 0x17da7(%rip), %rdi     # 0x2a396
xorl %eax, %eax
callq 0xb6e0
leaq 0x1e3e3(%rip), %rax     # 0x309e0
movq (%rax), %rsi
movq %r14, %rdi
callq 0xfe5d
testl %eax, %eax
jne 0x1262e
movq %rsp, %r14
movq %r14, %rdi
callq 0x6170
leal 0x1(%rax), %edi
callq 0xbee3
movq %rax, (%r12,%r15,8)
movq %rax, %rdi
movq %r14, %rsi
callq 0x60e0
leaq 0x1b23b(%rip), %rax     # 0x2d870
movl $0x0, (%rax)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1aaa4
leaq 0xf6cc(%rip), %rdi      # 0x21d1b
movq %rax, %rsi
xorl %eax, %eax
callq 0xb6e0
callq 0x12a63
leaq 0x1b22f(%rip), %rcx     # 0x2d894
movl %eax, (%rcx)
leaq 0x1b235(%rip), %rax     # 0x2d8a3
jmp 0x12330