// File: /workspace/github_c_makefile_star2_O0/ajpaulson[P]srogue11/pack.c
// Function: get_item
struct linked_list *get_item(char *purpose,int type)
{
	struct linked_list *obj, *pit, *savepit;
	struct object *pob;
	int ch, och, anr, cnt;

	if (pack == NULL) {
		msg("You aren't carrying anything.");
		return NULL;
	}
	if (type != WEAPON && (type != 0 || next(pack) == NULL)) {
		/*
		 * see if we have any of the type requested
		 */
		pit = pack;
		anr = 0;
		for (ch = 'a'; pit != NULL; pit = next(pit), ch = npch(ch)) {
			pob = OBJPTR(pit);
			if (type == pob->o_type || type == 0) {
				++anr;
				savepit = pit;	/* save in case of only 1 */
			}
		}
		if (anr == 0) {
			msg("Nothing to %s",purpose);
			after = FALSE;
			return NULL;
		}
		else if (anr == 1) {	/* only found one of 'em */
			do {
				struct object *opb;

				opb = OBJPTR(savepit);
				msg("%s what (* for the item)?",purpose);
				och = readchar();
				if (och == '*') {
					mpos = 0;
					msg("%c) %s",pack_char(opb),inv_name(opb,FALSE));
					continue;
				}
				if (och == ESCAPE) {
					msg("");
					after = FALSE;
					return NULL;
				}
				if (isalpha(och) && och != pack_char(opb)) {
					mpos = 0;
					msg("You can't %s that !!", purpose);
					after = FALSE;
					return NULL;
				}
			} while(!isalpha(och));
			mpos = 0;
			return savepit;		/* return this item */
		}
	}
	for (;;) {
		msg("%s what? (* for list): ",purpose);
		ch = readchar();
		mpos = 0;
		if (ch == ESCAPE) {		/* abort if escape hit */
			after = FALSE;
			msg("");			/* clear display */
			return NULL;
		}
		if (ch == '*') {
			wclear(hw);
			pit = pack;		/* point to pack */
			cnt = 0;
			for (ch='a'; pit != NULL; pit=next(pit), ch=npch(ch)) {
				pob = OBJPTR(pit);
				if (type == 0 || type == pob->o_type) {
					wprintw(hw,"%c) %s\n\r",ch,inv_name(pob,FALSE));
					if (++cnt > LINES - 2 && next(pit) != NULL) {
						cnt = 0;
						dbotline(hw, morestr);
						wclear(hw);
					}
				}
			}
			wmove(hw, LINES - 1,0);
			wprintw(hw,"%s what? ",purpose);
			draw(hw);		/* write screen */
			anr = FALSE;
			do {
				ch = readchar();
				if (isalpha(ch) || ch == ESCAPE)
					anr = TRUE; 
			} while(!anr);		/* do till we got it right */
			restscr(cw);		/* redraw orig screen */
			if (ch == ESCAPE) {
				after = FALSE;
				msg("");		/* clear top line */
				return NULL;	/* all done if abort */
			}
			/* ch has item to get from pack */
		}
		for (obj=pack,och='a';obj!=NULL;obj=next(obj),och=npch(och))
			if (ch == och)
				break;
		if (obj == NULL) {
			if (och == 'A')
				och = 'z';
			else
				och -= 1;
			msg("Please specify a letter between 'a' and '%c'",och);
			continue;
		}
		else 
			return obj;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
leaq 0x2252a(%rip), %rax     # 0x370d0
cmpq $0x0, 0x68(%rax)
jne 0x14bc8
leaq 0x16f61(%rip), %rdi     # 0x2bb15
movb $0x0, %al
callq 0xd8f0
movq $0x0, -0x8(%rbp)
jmp 0x150a0
cmpl $0x29, -0x14(%rbp)
je 0x14de7
cmpl $0x0, -0x14(%rbp)
jne 0x14bed
leaq 0x224f1(%rip), %rax     # 0x370d0
movq 0x68(%rax), %rax
cmpq $0x0, (%rax)
jne 0x14de7
leaq 0x224dc(%rip), %rax     # 0x370d0
movq 0x68(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x61, -0x3c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x14c60
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x20(%rcx), %eax
je 0x14c2f
cmpl $0x0, -0x14(%rbp)
jne 0x14c40
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x14c42
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x3c(%rbp), %eax
movsbl %al, %edi
callq 0xe330
movsbl %al, %eax
movl %eax, -0x3c(%rbp)
jmp 0x14c0a
cmpl $0x0, -0x44(%rbp)
jne 0x14c8f
movq -0x10(%rbp), %rsi
leaq 0x16ede(%rip), %rdi     # 0x2bb4f
movb $0x0, %al
callq 0xd8f0
leaq 0x1e68e(%rip), %rax     # 0x3330d
movb $0x0, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x150a0
cmpl $0x1, -0x44(%rbp)
jne 0x14de3
jmp 0x14c9b
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x16eab(%rip), %rdi     # 0x2bb5d
movb $0x0, %al
callq 0xd8f0
movb $0x0, %al
callq 0xdce0
movsbl %al, %eax
movl %eax, -0x40(%rbp)
cmpl $0x2a, -0x40(%rbp)
jne 0x14d0c
leaq 0x2200d(%rip), %rax     # 0x36ce0
movl $0x0, (%rax)
movq -0x50(%rbp), %rdi
callq 0x14790
movsbl %al, %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x23060
movl -0x54(%rbp), %esi
movq %rax, %rdx
leaq 0x1436b(%rip), %rdi     # 0x2906b
movb $0x0, %al
callq 0xd8f0
jmp 0x14da4
cmpl $0x1b, -0x40(%rbp)
jne 0x14d37
leaq 0x19596(%rip), %rdi     # 0x2e2af
movb $0x0, %al
callq 0xd8f0
leaq 0x1e5e6(%rip), %rax     # 0x3330d
movb $0x0, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x150a0
callq 0x65b0
movq (%rax), %rax
movslq -0x40(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x14da2
movl -0x40(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0x14790
movb %al, %cl
movl -0x58(%rbp), %eax
movsbl %cl, %ecx
cmpl %ecx, %eax
je 0x14da2
leaq 0x21f6d(%rip), %rax     # 0x36ce0
movl $0x0, (%rax)
movq -0x10(%rbp), %rsi
leaq 0x16df3(%rip), %rdi     # 0x2bb77
movb $0x0, %al
callq 0xd8f0
leaq 0x1e57b(%rip), %rax     # 0x3330d
movb $0x0, (%rax)
movq $0x0, -0x8(%rbp)
jmp 0x150a0
jmp 0x14da4
callq 0x65b0
movq (%rax), %rax
movslq -0x40(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x14c9b
leaq 0x21f10(%rip), %rax     # 0x36ce0
movl $0x0, (%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x150a0
jmp 0x14de5
jmp 0x14de7
jmp 0x14de9
movq -0x10(%rbp), %rsi
leaq 0x16d98(%rip), %rdi     # 0x2bb8c
movb $0x0, %al
callq 0xd8f0
movb $0x0, %al
callq 0xdce0
movsbl %al, %eax
movl %eax, -0x3c(%rbp)
leaq 0x21ed1(%rip), %rax     # 0x36ce0
movl $0x0, (%rax)
cmpl $0x1b, -0x3c(%rbp)
jne 0x14e40
leaq 0x1e4eb(%rip), %rax     # 0x3330d
movb $0x0, (%rax)
leaq 0x19483(%rip), %rdi     # 0x2e2af
movb $0x0, %al
callq 0xd8f0
movq $0x0, -0x8(%rbp)
jmp 0x150a0
cmpl $0x2a, -0x3c(%rbp)
jne 0x1501c
leaq 0x25007(%rip), %rax     # 0x39e58
movq (%rax), %rdi
callq 0x6110
leaq 0x22270(%rip), %rax     # 0x370d0
movq 0x68(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x61, -0x3c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x14f4e
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x14ea3
movl -0x14(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jne 0x14f2b
leaq 0x24fae(%rip), %rax     # 0x39e58
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x23060
movq -0x68(%rbp), %rdi
movl -0x5c(%rbp), %edx
movq %rax, %rcx
leaq 0x16c1f(%rip), %rsi     # 0x2baf2
movb $0x0, %al
callq 0x6510
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movq 0x1e0f6(%rip), %rcx     # 0x32fe0
movl (%rcx), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jle 0x14f29
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x14f29
movl $0x0, -0x48(%rbp)
leaq 0x24f4d(%rip), %rax     # 0x39e58
movq (%rax), %rdi
leaq 0x1e419(%rip), %rsi     # 0x3332e
callq 0xe270
leaq 0x24f37(%rip), %rax     # 0x39e58
movq (%rax), %rdi
callq 0x6110
jmp 0x14f2b
jmp 0x14f2d
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl -0x3c(%rbp), %eax
movsbl %al, %edi
callq 0xe330
movsbl %al, %eax
movl %eax, -0x3c(%rbp)
jmp 0x14e76
leaq 0x24f03(%rip), %rax     # 0x39e58
movq (%rax), %rdi
movq 0x1e081(%rip), %rax     # 0x32fe0
movl (%rax), %esi
subl $0x1, %esi
xorl %edx, %edx
callq 0x6490
leaq 0x24ee6(%rip), %rax     # 0x39e58
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x16c24(%rip), %rsi     # 0x2bba4
movb $0x0, %al
callq 0x6510
leaq 0x24eca(%rip), %rax     # 0x39e58
movq (%rax), %rdi
callq 0x61f0
movl $0x0, -0x44(%rbp)
movb $0x0, %al
callq 0xdce0
movsbl %al, %eax
movl %eax, -0x3c(%rbp)
callq 0x65b0
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0x14fca
cmpl $0x1b, -0x3c(%rbp)
jne 0x14fd1
movl $0x1, -0x44(%rbp)
jmp 0x14fd3
cmpl $0x0, -0x44(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x14f9d
leaq 0x24e69(%rip), %rax     # 0x39e50
movq (%rax), %rdi
callq 0xe2d0
cmpl $0x1b, -0x3c(%rbp)
jne 0x1501a
leaq 0x1e311(%rip), %rax     # 0x3330d
movb $0x0, (%rax)
leaq 0x192a9(%rip), %rdi     # 0x2e2af
movb $0x0, %al
callq 0xd8f0
movq $0x0, -0x8(%rbp)
jmp 0x150a0
jmp 0x1501c
leaq 0x220ad(%rip), %rax     # 0x370d0
movq 0x68(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x61, -0x40(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x15063
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jne 0x15043
jmp 0x15063
jmp 0x15045
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x40(%rbp), %eax
movsbl %al, %edi
callq 0xe330
movsbl %al, %eax
movl %eax, -0x40(%rbp)
jmp 0x15032
cmpq $0x0, -0x20(%rbp)
jne 0x15098
cmpl $0x41, -0x40(%rbp)
jne 0x15079
movl $0x7a, -0x40(%rbp)
jmp 0x15082
movl -0x40(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %esi
leaq 0x16b22(%rip), %rdi     # 0x2bbae
movb $0x0, %al
callq 0xd8f0
jmp 0x14de9
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)