// File: /workspace/github_c_makefile_star2_O2/ajpaulson[P]srogue11/wizard.c
// Function: create_obj
int create_obj(bool fscr)
{
	struct linked_list *item;
	struct object *obj;
	int wh, ch, otype;
	char newitem, newtype, msz, *oname;
	struct magic_info *mf;
	bool nogood = TRUE, inhw = FALSE;

	if (fscr)
		msg(" ");
	else if (wizard) {
		msg("Create what?%s: ", starlist);
		ch = readchar();
		mpos = 0;
		if (ch == ESCAPE)
			return 0;
		else if (ch != '*')
			nogood = FALSE;
	}
	if (nogood) {
		inhw = TRUE;
		wclear(hw);
		wprintw(hw,"Item\tKey\n\n");
		for (otype = 0; otype < NUMTHINGS; otype++) {
			if (otype != TYP_AMULET || wizard) {
				mf = &thnginfo[otype];
				wprintw(hw,"%s\t %c\n",things[otype].mi_name,mf->mf_show);
			}
		}
		if (wizard)
			waddstr(hw,"monster\t (A-z)");
		wprintw(hw,"\n\nWhat do you want to create? ");
		draw(hw);
		do {
			ch = readchar();
			if (ch == ESCAPE) {
				after = FALSE;
				restscr(cw);
				return 0;
			}
			switch (ch) {
				case RING:		case STICK:	case POTION:
				case SCROLL:	case ARMOR:	case WEAPON:
				case FOOD:		case AMULET:
					nogood = FALSE;
					break;
				default:
					if (isalpha(ch))
						nogood = FALSE;
			}
		} while (nogood);
	}
	if (isalpha(ch)) {
		if (inhw)
			restscr(cw);
		makemons(ch);		/* make monster & be done with it */
		return 0;
	}
	otype = getindex(ch);
	if (otype == -1 || (otype == AMULET && !wizard)) {
		if (inhw)
			restscr(cw);
		mpos = 0;
		msg("You can't create that !!");
		return 0;
	}
	newitem = ch;
	mf = &thnginfo[otype];
	oname = things[otype].mi_name;
	msz = mf->mf_max;
	nogood = TRUE;
	if (msz == 1) {		/* if only one type of item */
		ch = 'a';
		nogood = FALSE;
	}
	else if (!fscr && wizard) {
		if (!inhw) {
			msg("Which %s?%s: ", oname, starlist);
			ch = readchar();
			if (ch == ESCAPE)
				return 0;
			if (ch != '*')
				nogood = FALSE;
		}
	}
	if (nogood) {
		struct magic_item *wmi;
		int ii;

		mpos = 0;
		inhw = TRUE;
		switch(newitem) {
			case POTION:	wmi = &p_magic[0];
			when SCROLL:	wmi = &s_magic[0];
			when RING:		wmi = &r_magic[0];
			when STICK:		wmi = &ws_magic[0];
			when WEAPON:	wmi = &w_magic[0];
			otherwise:		wmi = &a_magic[0];
		}
		wclear(hw);
		for (ii = 0 ; ii < msz ; ii++) {
			mvwaddch(hw,ii % 13,ii > 12 ? COLS/2 : 0, ii + 'a');
			waddstr(hw,") ");
			waddstr(hw,wmi->mi_name);
			wmi++;
		}
		sprintf(prbuf,"Which %s? ", oname);
		mvwaddstr(hw,LINES - 1, 0, prbuf);
		draw(hw);
		do {
			ch = readchar();
			if (ch == ESCAPE) {
				restscr(cw);
				msg("");
				return 0;
			}
		} while (!isalpha(ch));
	}
	if (inhw)			/* restore screen if need be */
		restscr(cw);

	newtype = tolower(ch) - 'a';
	if (newtype < 0 || newtype >= msz) {	/* if an illegal value */
		mpos = 0;
		after = FALSE;
		if (inhw)
			restscr(cw);
		msg("There is no such %s", oname);
		return 0;
	}
	mpos = 0;
	item = new_thing(FALSE, newitem, newtype);
	obj = OBJPTR(item);
	wh = obj->o_type;
	if (wh == WEAPON || wh == ARMOR || wh == RING) {
		if (fscr)					/* users get +3 to -3 */
			ch = rnd(7) - 3;
		else {						/* wizard gets to choose */
			if (wh == RING)
				init_ring(obj, TRUE);
			else
				ch = getbless();
		}
		if (wh == WEAPON)
			obj->o_hplus = obj->o_dplus = ch;
		else if (wh == ARMOR)
			obj->o_ac = armors[obj->o_which].a_class - ch;
		if (ch < 0)
			setoflg(obj, ISCURSED);
		else
			resoflg(obj, ISCURSED);
	}
	mpos = 0;
	if (fscr)
		whatis(item);			/* identify for aquirement scroll */
	wh = add_pack(item, FALSE);
	if (wh == FALSE)			/* won't fit in pack */
		discard(item);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edi, 0xc(%rsp)
testl %edi, %edi
je 0x1b291
leaq 0x3f78(%rip), %rdi      # 0x1f200
xorl %eax, %eax
callq 0xb178
jmp 0x1b2dd
leaq 0x125f5(%rip), %rax     # 0x2d88d
cmpb $0x1, (%rax)
jne 0x1b2dd
leaq 0x66ca(%rip), %rdi      # 0x2196e
leaq 0xf0e5(%rip), %rsi      # 0x2a390
xorl %eax, %eax
callq 0xb178
xorl %eax, %eax
callq 0xb447
movl %eax, %r12d
leaq 0x1259d(%rip), %rax     # 0x2d860
andl $0x0, (%rax)
cmpb $0x1b, %r12b
je 0x1b69e
movzbl %r12b, %eax
cmpl $0x2a, %eax
jne 0x1b3eb
leaq 0x156f4(%rip), %rbx     # 0x309d8
movq (%rbx), %rdi
callq 0x6120
movq (%rbx), %rdi
leaq 0x6689(%rip), %rsi      # 0x2197f
xorl %eax, %eax
callq 0x64f0
leaq 0x1165c(%rip), %r15     # 0x2c960
addq $0x8, %r15
leaq 0x10ab1(%rip), %r12     # 0x2bdc0
leaq 0x12577(%rip), %r13     # 0x2d88d
leaq 0x666d(%rip), %r14      # 0x2198a
xorl %ebp, %ebp
cmpq $0x7, %rbp
je 0x1b32d
cmpq $0x8, %rbp
jne 0x1b334
jmp 0x1b356
cmpb $0x1, (%r13)
jne 0x1b349
movq (%rbx), %rdi
movq (%r12), %rdx
movsbl (%r15), %ecx
movq %r14, %rsi
xorl %eax, %eax
callq 0x64f0
incq %rbp
addq $0x10, %r12
addq $0x18, %r15
jmp 0x1b31f
cmpb $0x1, (%r13)
jne 0x1b36f
movq (%rbx), %rdi
leaq 0x662b(%rip), %rsi      # 0x21992
pushq $-0x1
popq %rdx
callq 0x6530
movq (%rbx), %rdi
leaq 0x6628(%rip), %rsi      # 0x219a1
xorl %eax, %eax
callq 0x64f0
movq (%rbx), %rdi
callq 0x6200
movabsq $0x1000000052004901, %rbx # imm = 0x1000000052004901
xorl %r14d, %r14d
xorl %eax, %eax
callq 0xb447
movl %eax, %r12d
movzbl %al, %eax
leal -0x21(%rax), %ecx
cmpl $0x3c, %ecx
ja 0x1b3b0
btq %rcx, %rbx
jb 0x1b3ee
cmpl $0x1b, %eax
je 0x1b3cd
callq 0x6590
movq (%rax), %rax
movsbq %r12b, %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0x1b395
xorl %r14d, %r14d
jmp 0x1b3ee
leaq 0xef29(%rip), %rax      # 0x2a2fd
movb $0x0, (%rax)
leaq 0x155f2(%rip), %rax     # 0x309d0
movq (%rax), %rdi
callq 0xb7b6
jmp 0x1b69e
movb $0x1, %r14b
movsbl %r12b, %r13d
callq 0x6590
movq %rax, %rbx
movq (%rax), %rax
movsbq %r13b, %rcx
testb $0x4, 0x1(%rax,%rcx,2)
jne 0x1b47c
movl %r13d, %edi
callq 0xc2af
cmpl $-0x1, %eax
je 0x1b49d
cmpl $0x2c, %eax
jne 0x1b42a
leaq 0x12468(%rip), %rcx     # 0x2d88d
cmpb $0x0, (%rcx)
je 0x1b49d
cltq
imulq $0x18, %rax, %rcx
leaq 0x11529(%rip), %rdx     # 0x2c960
shlq $0x4, %rax
leaq 0x1097e(%rip), %rsi     # 0x2bdc0
movq (%rsi,%rax), %rsi
movl (%rdx,%rcx), %eax
movsbl %al, %r15d
shll $0x18, %eax
cmpl $0x1000000, %eax        # imm = 0x1000000
sete %cl
orb 0xc(%rsp), %cl
movq %rsi, 0x18(%rsp)
movl %r15d, 0x14(%rsp)
je 0x1b4c7
cmpl $0x1000000, %eax        # imm = 0x1000000
jne 0x1b507
pushq $0x61
popq %r15
jmp 0x1b6b3
testb %r14b, %r14b
jne 0x1b490
leaq 0x15548(%rip), %rax     # 0x309d0
movq (%rax), %rdi
callq 0xb7b6
movl %r13d, %edi
callq 0x1b80c
jmp 0x1b69e
testb %r14b, %r14b
jne 0x1b4b1
leaq 0x15527(%rip), %rax     # 0x309d0
movq (%rax), %rdi
callq 0xb7b6
leaq 0x123a8(%rip), %rax     # 0x2d860
andl $0x0, (%rax)
leaq 0x64fe(%rip), %rdi      # 0x219c0
jmp 0x1b697
leaq 0x123bf(%rip), %rax     # 0x2d88d
movb (%rax), %al
andb %r14b, %al
cmpb $0x1, %al
jne 0x1b507
leaq 0x64fb(%rip), %rdi      # 0x219d9
leaq 0xeeab(%rip), %rdx      # 0x2a390
xorl %eax, %eax
callq 0xb178
xorl %eax, %eax
callq 0xb447
cmpb $0x1b, %al
je 0x1b69e
movzbl %al, %ecx
cmpl $0x2a, %ecx
jne 0x1b6af
leaq 0x12352(%rip), %rax     # 0x2d860
andl $0x0, (%rax)
cmpb $0x21, %r12b
movl %r13d, 0x10(%rsp)
movq %rbx, 0x20(%rsp)
je 0x1b566
movzbl %r12b, %eax
cmpl $0x29, %eax
je 0x1b542
cmpl $0x2f, %eax
je 0x1b554
cmpl $0x3d, %eax
je 0x1b54b
cmpl $0x3f, %eax
jne 0x1b55d
leaq 0x10db0(%rip), %rbp     # 0x2c2f0
jmp 0x1b56d
leaq 0x10a37(%rip), %rbp     # 0x2bf80
jmp 0x1b56d
leaq 0x110ae(%rip), %rbp     # 0x2c600
jmp 0x1b56d
leaq 0x11255(%rip), %rbp     # 0x2c7b0
jmp 0x1b56d
leaq 0x108ec(%rip), %rbp     # 0x2be50
jmp 0x1b56d
leaq 0x10f33(%rip), %rbp     # 0x2c4a0
leaq 0x15464(%rip), %rbx     # 0x309d8
movq (%rbx), %rdi
callq 0x6120
xorl %r12d, %r12d
testl %r15d, %r15d
movl %r15d, %eax
movl $0x0, %r15d
cmovgl %eax, %r15d
leaq 0x6451(%rip), %r13      # 0x219e7
pushq $-0x1
popq %r14
movl %r12d, %eax
xorl %edx, %edx
pushq $0xd
popq %rcx
divl %ecx
cmpl %r12d, %r15d
je 0x1b60a
movl %eax, %ecx
movq (%rbx), %rdi
xorl %edx, %edx
cmpl $0xd, %r12d
jb 0x1b5c7
movq 0xe9e3(%rip), %rax      # 0x29fa0
movl (%rax), %eax
cltd
pushq $0x2
popq %rsi
idivl %esi
movl %eax, %edx
imull $-0xd, %ecx, %esi
addl %r12d, %esi
callq 0x6470
cmpl $-0x1, %eax
je 0x1b5e4
movq (%rbx), %rdi
leal 0x61(%r12), %esi
callq 0x64a0
movq (%rbx), %rdi
movq %r13, %rsi
movl %r14d, %edx
callq 0x6530
movq (%rbx), %rdi
movq (%rbp), %rsi
movl %r14d, %edx
callq 0x6530
addq $0x10, %rbp
incl %r12d
jmp 0x1b59a
leaq 0x1286f(%rip), %rdi     # 0x2de80
leaq 0x63d2(%rip), %rsi      # 0x219ea
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x64d0
movq (%rbx), %rdi
movq 0xe992(%rip), %rax      # 0x29fc0
movl (%rax), %esi
decl %esi
xorl %edx, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0x1b650
movq (%rbx), %rdi
leaq 0x12838(%rip), %rsi     # 0x2de80
pushq $-0x1
popq %rdx
callq 0x6530
movq (%rbx), %rdi
callq 0x6200
movl 0x10(%rsp), %r13d
movq 0x20(%rsp), %rbx
xorl %eax, %eax
callq 0xb447
cmpb $0x1b, %al
je 0x1b681
movq (%rbx), %rcx
movsbq %al, %rdx
testb $0x4, 0x1(%rcx,%rdx,2)
je 0x1b662
movsbl %al, %r15d
jmp 0x1b6bc
leaq 0x15348(%rip), %rax     # 0x309d0
movq (%rax), %rdi
callq 0xb7b6
leaq 0x62f2(%rip), %rdi      # 0x21989
xorl %eax, %eax
callq 0xb178
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsbl %al, %r15d
testb %r14b, %r14b
je 0x1b6bc
xorl %ebp, %ebp
jmp 0x1b6ce
leaq 0x1530d(%rip), %rax     # 0x309d0
movq (%rax), %rdi
callq 0xb7b6
movb $0x1, %bpl
movl %r15d, %edi
callq 0x6300
addb $-0x61, %al
movsbl %al, %edx
leaq 0x1217e(%rip), %rbx     # 0x2d860
andl $0x0, (%rbx)
testl %edx, %edx
js 0x1b740
cmpl 0x14(%rsp), %edx
jge 0x1b740
xorl %edi, %edi
movl %r13d, %esi
callq 0x19c8f
movq %rax, %r14
movq 0x10(%rax), %r12
movl 0x20(%r12), %r13d
leal -0x29(%r13), %eax
cmpl $0x34, %eax
ja 0x1b7db
movabsq $0x10000000100001, %rcx # imm = 0x10000000100001
btq %rax, %rcx
jae 0x1b7db
cmpb $0x0, 0xc(%rsp)
je 0x1b776
pushq $0x7
popq %rdi
xorl %eax, %eax
callq 0xc004
movl %eax, %r15d
addl $-0x3, %r15d
jmp 0x1b791
leaq 0xebb6(%rip), %rax      # 0x2a2fd
movb $0x0, (%rax)
testb %bpl, %bpl
je 0x1b75e
leaq 0x1527a(%rip), %rax     # 0x309d0
movq (%rax), %rdi
callq 0xb7b6
leaq 0x6290(%rip), %rdi      # 0x219f5
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0xb178
jmp 0x1b69e
cmpl $0x3d, %r13d
jne 0x1b789
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x11ea2
jmp 0x1b7c4
callq 0x1b8e2
movl %eax, %r15d
cmpl $0x5d, %r13d
je 0x1b7a9
cmpl $0x29, %r13d
jne 0x1b7c4
movl %r15d, 0x30(%r12)
movl %r15d, 0x2c(%r12)
jmp 0x1b7c4
movslq 0x28(%r12), %rax
imulq $0xc, %rax, %rax
leaq 0x10747(%rip), %rcx     # 0x2bf00
movl (%rcx,%rax), %eax
subl %r15d, %eax
movl %eax, 0x34(%r12)
pushq $0x1
popq %rsi
movq %r12, %rdi
testl %r15d, %r15d
js 0x1b7d6
callq 0x9370
jmp 0x1b7db
callq 0x936c
andl $0x0, (%rbx)
cmpb $0x0, 0xc(%rsp)
je 0x1b7ed
movq %r14, %rdi
callq 0x1b194
movq %r14, %rdi
xorl %esi, %esi
callq 0xf7ac
testb %al, %al
jne 0x1b69e
movq %r14, %rdi
callq 0xb857
jmp 0x1b69e