// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movl %edi, 0x8(%rsp)
testl %edi, %edi
je 0x1cf1a
leaq 0x4280(%rip), %rdi      # 0x2118e
xorl %eax, %eax
callq 0xb6e0
movb $0x1, %r15b
jmp 0x1cf6d
leaq 0x1097c(%rip), %rax     # 0x2d89d
movb $0x1, %r15b
cmpb $0x1, (%rax)
jne 0x1cf6d
leaq 0x69c6(%rip), %rdi      # 0x238f6
leaq 0xd469(%rip), %rsi      # 0x2a3a0
xorl %eax, %eax
callq 0xb6e0
xorl %eax, %eax
callq 0xb9fd
leaq 0x10924(%rip), %rcx     # 0x2d870
movl $0x0, (%rcx)
cmpb $0x1b, %al
je 0x1d4ed
movzbl %al, %r14d
cmpl $0x2a, %r14d
je 0x1cf6d
movsbl %al, %r14d
xorl %r15d, %r15d
jmp 0x1cf6d
testb %r15b, %r15b
je 0x1d081
leaq 0x13a6b(%rip), %rbx     # 0x309e8
movq (%rbx), %rdi
callq 0x6120
movq %rbx, %r13
movq (%rbx), %rdi
leaq 0x6975(%rip), %rsi      # 0x23907
xorl %eax, %eax
callq 0x6510
movq $-0xc0, %r12
leaq 0xee29(%rip), %rbp      # 0x2bdd0
leaq 0xf9c2(%rip), %rbx      # 0x2c970
leaq 0x695d(%rip), %r14      # 0x23912
cmpq $-0x18, %r12
jne 0x1cfc7
leaq 0x108db(%rip), %rax     # 0x2d89d
cmpb $0x1, (%rax)
jne 0x1cfe2
movq (%r13), %rdi
movq (%rbp), %rdx
movsbl 0xc8(%rbx,%r12), %ecx
movq %r14, %rsi
xorl %eax, %eax
callq 0x6510
addq $0x10, %rbp
addq $0x18, %r12
jne 0x1cfb5
leaq 0x108aa(%rip), %rax     # 0x2d89d
cmpb $0x1, (%rax)
jne 0x1d00d
movq (%r13), %rdi
leaq 0x6917(%rip), %rsi      # 0x2391a
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
movq (%r13), %rdi
leaq 0x6911(%rip), %rsi      # 0x23929
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x6510
movq (%r13), %rdi
callq 0x6200
movabsq $0x1000000052004901, %rbx # imm = 0x1000000052004901
xorl %r12d, %r12d
xorl %eax, %eax
callq 0xb9fd
movl %eax, %ebp
movzbl %al, %eax
leal -0x21(%rax), %ecx
cmpl $0x3c, %ecx
ja 0x1d05d
btq %rcx, %rbx
jae 0x1d05d
movl %r12d, %r15d
testb $0x1, %r12b
jne 0x1d035
jmp 0x1d085
cmpl $0x1b, %eax
je 0x1d1d1
callq 0x65b0
movq (%rax), %rax
movsbq %bpl, %rcx
testb $0x4, 0x1(%rax,%rcx,2)
movzbl %r15b, %r12d
cmovnel %r14d, %r12d
jmp 0x1d052
xorl %ebx, %ebx
jmp 0x1d08b
movsbl %bpl, %r14d
movb $0x1, %bl
callq 0x65b0
movq %rax, %r15
movq (%rax), %rax
movslq %r14d, %rcx
testb $0x4, 0x1(%rax,%rcx,2)
jne 0x1d17e
movsbl %r14b, %edi
callq 0xcaa3
cmpl $-0x1, %eax
je 0x1d19e
cmpl $0x2c, %eax
jne 0x1d0cb
leaq 0x107db(%rip), %rcx     # 0x2d89d
cmpb $0x0, (%rcx)
je 0x1d19e
cltq
leaq (%rax,%rax,2), %rcx
leaq 0xf898(%rip), %rdx      # 0x2c970
shlq $0x4, %rax
leaq 0xeced(%rip), %rsi      # 0x2bdd0
movq (%rsi,%rax), %rax
movq %rax, 0x10(%rsp)
movl (%rdx,%rcx,8), %ebp
movl %ebp, %eax
shll $0x18, %eax
cmpl $0x1000000, %eax        # imm = 0x1000000
setne %r13b
sete %al
movl $0x61, %r12d
cmovnel %r14d, %r12d
orb 0x8(%rsp), %al
jne 0x1d12a
leaq 0x10786(%rip), %rax     # 0x2d89d
movb $0x1, %r13b
cmpb $0x1, (%rax)
jne 0x1d127
testb %bl, %bl
je 0x1d202
movl %r14d, %r12d
movl %r14d, 0xc(%rsp)
movsbl %bpl, %r14d
testb %r13b, %r13b
je 0x1d395
leaq 0x1072d(%rip), %rax     # 0x2d870
movl $0x0, (%rax)
movsbl 0xc(%rsp), %eax
cmpl $0x2e, %eax
jle 0x1d1ef
cmpl $0x2f, %eax
je 0x1d245
cmpl $0x3d, %eax
je 0x1d24e
cmpl $0x3f, %eax
jne 0x1d260
leaq 0xf187(%rip), %r13      # 0x2c300
jmp 0x1d267
testb %bl, %bl
je 0x1d191
leaq 0x13857(%rip), %rax     # 0x309e0
movq (%rax), %rdi
callq 0xbdbb
movl %r14d, %edi
callq 0x1d4fe
jmp 0x1d4ed
testb %bl, %bl
je 0x1d1b1
leaq 0x13837(%rip), %rax     # 0x309e0
movq (%rax), %rdi
callq 0xbdbb
leaq 0x106b8(%rip), %rax     # 0x2d870
movl $0x0, (%rax)
leaq 0x6783(%rip), %rdi      # 0x23948
xorl %eax, %eax
callq 0xb6e0
jmp 0x1d4ed
leaq 0xd135(%rip), %rax      # 0x2a30d
movb $0x0, (%rax)
leaq 0x137fe(%rip), %rax     # 0x309e0
movq (%rax), %rdi
callq 0xbdbb
jmp 0x1d4ed
cmpl $0x21, %eax
je 0x1d257
cmpl $0x29, %eax
jne 0x1d260
leaq 0xed90(%rip), %r13      # 0x2bf90
jmp 0x1d267
leaq 0x6758(%rip), %rdi      # 0x23961
leaq 0xd190(%rip), %rdx      # 0x2a3a0
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0xb6e0
xorl %eax, %eax
callq 0xb9fd
cmpb $0x1b, %al
je 0x1d4ed
movzbl %al, %r12d
cmpl $0x2a, %r12d
je 0x1d12a
movsbl %al, %r12d
xorl %r13d, %r13d
jmp 0x1d12a
leaq 0xf574(%rip), %r13      # 0x2c7c0
jmp 0x1d267
leaq 0xf3bb(%rip), %r13      # 0x2c610
jmp 0x1d267
leaq 0xf252(%rip), %r13      # 0x2c4b0
jmp 0x1d267
leaq 0xebf9(%rip), %r13      # 0x2be60
leaq 0x1377a(%rip), %rbx     # 0x309e8
movq (%rbx), %rdi
callq 0x6120
testl %r14d, %r14d
jle 0x1d2f6
xorl %ebp, %ebp
leaq 0x66eb(%rip), %r12      # 0x2396f
movl $0x0, %edx
cmpl $0xd, %ebp
jb 0x1d2a0
movq 0xcd03(%rip), %rax      # 0x29f98
movl (%rax), %eax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movl %ebp, %eax
imulq $0x4ec4ec4f, %rax, %rax # imm = 0x4EC4EC4F
shrq $0x22, %rax
imull $-0xd, %eax, %esi
movq (%rbx), %rdi
addl %ebp, %esi
callq 0x6490
cmpl $-0x1, %eax
je 0x1d2ca
movq (%rbx), %rdi
leal 0x61(%rbp), %esi
callq 0x64c0
movq (%rbx), %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
movq (%rbx), %rdi
movq (%r13), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
addq $0x10, %r13
incl %ebp
cmpl %ebp, %r14d
jne 0x1d284
leaq 0x10b93(%rip), %rdi     # 0x2de90
leaq 0x666e(%rip), %rsi      # 0x23972
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x64f0
movq (%rbx), %rdi
movq 0xcc96(%rip), %rax      # 0x29fb0
movl (%rax), %esi
decl %esi
xorl %edx, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0x1d33e
movq (%rbx), %rdi
leaq 0x10b5c(%rip), %rsi     # 0x2de90
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
movq (%rbx), %rdi
callq 0x6200
xorl %eax, %eax
callq 0xb9fd
movl %eax, %r13d
cmpb $0x1b, %al
je 0x1d368
movq (%r15), %rax
movsbq %r13b, %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0x1d346
movsbl %r13b, %r12d
jmp 0x1d389
movzbl %r13b, %r12d
leaq 0x1366d(%rip), %rax     # 0x309e0
movq (%rax), %rdi
callq 0xbdbb
leaq 0x658f(%rip), %rdi      # 0x23911
xorl %eax, %eax
callq 0xb6e0
movb $0x1, %bl
cmpb $0x1b, %r13b
je 0x1d4ed
testb %bl, %bl
je 0x1d3a8
leaq 0x13640(%rip), %rax     # 0x309e0
movq (%rax), %rdi
callq 0xbdbb
movl %r12d, %edi
callq 0x6310
addb $-0x61, %al
movsbl %al, %edx
leaq 0x104b4(%rip), %r13     # 0x2d870
movl $0x0, (%r13)
testl %edx, %edx
js 0x1d420
cmpl %r14d, %edx
jge 0x1d420
movsbl 0xc(%rsp), %esi
xorl %edi, %edi
callq 0x1b715
movq %rax, %r14
movq 0x10(%rax), %r15
movl 0x20(%r15), %ebx
leal -0x29(%rbx), %eax
cmpl $0x34, %eax
ja 0x1d4c0
movabsq $0x10000000100001, %rcx # imm = 0x10000000100001
btq %rax, %rcx
jae 0x1d4c0
cmpb $0x0, 0x8(%rsp)
je 0x1d455
movl $0x7, %edi
xorl %eax, %eax
callq 0xc72d
movl %eax, %r12d
addl $-0x3, %r12d
jmp 0x1d471
leaq 0xcee6(%rip), %rax      # 0x2a30d
movb $0x0, (%rax)
testb %bl, %bl
je 0x1d43d
leaq 0x135ab(%rip), %rax     # 0x309e0
movq (%rax), %rdi
callq 0xbdbb
leaq 0x6539(%rip), %rdi      # 0x2397d
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0xb6e0
jmp 0x1d4ed
cmpl $0x3d, %ebx
jne 0x1d469
movq %r15, %rdi
movl $0x1, %esi
callq 0x12c8e
jmp 0x1d471
callq 0x1d5bd
movl %eax, %r12d
cmpl $0x5d, %ebx
je 0x1d489
cmpl $0x29, %ebx
jne 0x1d4a7
movl %r12d, 0x30(%r15)
movl $0x2c, %ecx
movl %r12d, %eax
jmp 0x1d4a3
movslq 0x28(%r15), %rax
leaq (%rax,%rax,2), %rax
leaq 0xea78(%rip), %rcx      # 0x2bf10
movl (%rcx,%rax,4), %eax
subl %r12d, %eax
movl $0x34, %ecx
movl %eax, (%r15,%rcx)
movl $0x1, %esi
movq %r15, %rdi
testl %r12d, %r12d
js 0x1d4bb
callq 0x95d9
jmp 0x1d4c0
callq 0x95d5
movl $0x0, (%r13)
cmpb $0x0, 0x8(%rsp)
je 0x1d4d7
movq %r14, %rdi
callq 0x1ce10
movq %r14, %rdi
xorl %esi, %esi
callq 0x10288
testb %al, %al
jne 0x1d4ed
movq %r14, %rdi
callq 0xbe93
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq