// File: /workspace/github_c_makefile_star2_O0/S01den[P]Lost_CavernRL/menu.c
// Function: craftMenu
int craftMenu(Inventory inventory[], Drug listDrug[], Player player, int *component, int *exoticBlood, int *gem, int minimal)
{
	int ret = 0;
	int s = 0;

	WINDOW* win;
	if(!minimal)
		win = newwin(16,42,LONGUEUR/2-5,LARGEUR-20);
	else
		win = newwin(16,42,LONGUEUR/2,LARGEUR/4);
	box(win, 0 , 0);
	wattron(win,A_UNDERLINE);
	mvwprintw(win,1,1,"COMPONENTS: %d",*component);
	mvwprintw(win,1,16,"EXOTIC BLOOD: %d",*exoticBlood);
	mvwprintw(win,1,33,"GEMS: %d",*gem);
	wattroff(win,A_UNDERLINE);

	wattron(win,COLOR_PAIR(47));
	mvwprintw(win,2,1,"1) * : NUCLEAR CHARGE (30c + 1g)");
	wattroff(win,COLOR_PAIR(47));
	mvwprintw(win,3,1,"2) ! : VACCIN (30eb)");
	wattron(win,COLOR_PAIR(124));
	mvwprintw(win,4,1,"3) ~ : SHIELD (15c)");
	wattroff(win,COLOR_PAIR(124));
	wattron(win,COLOR_PAIR(22));
	mvwprintw(win,5,1,"4) = : ELECTRIC TRAP (20c)");
	wattroff(win,COLOR_PAIR(22));
	wattron(win,COLOR_PAIR(23));
	mvwprintw(win,6,1,"5) = : PARALYSING TRAP (20c)");
	wattroff(win,COLOR_PAIR(23));
	wattron(win,COLOR_PAIR(COLOR_LAVA));
	mvwprintw(win,7,1,"6) * : LAVA BUCKET (40eb + 1g)");
	wattroff(win,COLOR_PAIR(COLOR_LAVA));
	mvwprintw(win,8,1,"7) ! : ANTIDOTE (35eb)");

	wrefresh(win);

	int key = wgetch(win);

	box(win, ' ', ' ');
	wborder(win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
	wclear(win);
	wrefresh(win);
	delwin(win);	

	switch(key)
	{	
		case '1':
			if(*component >= 20 && *gem >= 1)
			{
				(*gem)--;
				*component -= 20;
				for(s = 0; s < player.inventorySize; s++)
				{
					if(inventory[s].type == -1)
					{
						inventory[s].type = 3;
						inventory[s].object = 1; // nuclear charge
						break;
					}
				}
			}
			break;
		case '2':
			if(*exoticBlood >= 30)
			{
				*exoticBlood -= 30;
				for(s = 0; s < player.inventorySize; s++)
				{
					if(inventory[s].type == -1)
					{
						inventory[s].type = 2;
						int indiceVax = 0;
						for(indiceVax = 0; indiceVax < NBR_DRUGS; indiceVax++)
						{
							if(listDrug[indiceVax].type == 0)
								inventory[s].object = indiceVax; // vaccin
						}
						break;
					}
				}
			}
			break;
		case '3':
			if(*component >= 15)
			{
				*component -= 15;
				for(s = 0; s < player.inventorySize; s++)
				{
					if(inventory[s].type == -1)
					{
						inventory[s].type = 3;
						inventory[s].object = 2; // shield 
						break;
					}
				}
			}
			break;
		case '4':
			if(*component >= 20)
			{
				*component -= 20;
				for(s = 0; s < player.inventorySize; s++)
				{
					if(inventory[s].type == -1)
					{
						inventory[s].type = 3;
						inventory[s].object = 3; 
						break;
					}
				}
			}
			break;
		case '5':
			if(*component >= 20)
			{
				*component -= 20;
				for(s = 0; s < player.inventorySize; s++)
				{
					if(inventory[s].type == -1)
					{
						inventory[s].type = 3;
						inventory[s].object = 4;
						break;
					}
				}
			}
			break;
		case '6':
			if(*exoticBlood >= 40 && *gem >= 1)
			{
				*exoticBlood -= 40;
				(*gem)--;
				for(s = 0; s < player.inventorySize; s++)
				{
					if(inventory[s].type == -1)
					{
						inventory[s].type = 3;
						inventory[s].object = 5;
						break;
					}
				}
			}
			break;
		case '7':
			if(*exoticBlood >= 35)
			{
				*exoticBlood -= 35;
				for(s = 0; s < player.inventorySize; s++)
				{
					if(inventory[s].type == -1)
					{
						inventory[s].type = 2;
						int indiceAntidote = 0;
						for(indiceAntidote = 0; indiceAntidote < NBR_DRUGS; indiceAntidote++)
						{
							if(listDrug[indiceAntidote].type == 2)
								inventory[s].object = indiceAntidote; // vaccin
						}
						break;
					}
				}
			}
			break;
	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x1107e
movl $0x10, %edi
movl $0x2a, %esi
movl $0xe, %edx
movl $0x6e, %ecx
callq 0x2130
movq %rax, -0x40(%rbp)
jmp 0x1109b
movl $0x10, %edi
movl $0x2a, %esi
movl $0x13, %edx
movl $0x20, %ecx
callq 0x2130
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq %rsp, %rax
movl $0x0, 0x10(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, (%rax)
xorl %r9d, %r9d
movl %r9d, -0x68(%rbp)
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x2120
movl -0x68(%rbp), %eax
movq -0x40(%rbp), %rdi
movl %eax, %edx
movq %rdx, -0x78(%rbp)
movl $0x20000, %esi          # imm = 0x20000
movl %esi, -0x90(%rbp)
callq 0x21d0
movl -0x68(%rbp), %eax
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl (%rcx), %r8d
leaq 0x89c7(%rip), %rcx      # 0x19ac7
movb %al, -0x69(%rbp)
movl $0x1, %edx
movl %edx, -0x70(%rbp)
movl %edx, %esi
callq 0x2070
movl -0x70(%rbp), %esi
movb -0x69(%rbp), %al
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl (%rcx), %r8d
leaq 0x89ac(%rip), %rcx      # 0x19ad6
movl $0x10, %edx
callq 0x2070
movl -0x70(%rbp), %esi
movb -0x69(%rbp), %al
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rcx
movl (%rcx), %r8d
leaq 0x899b(%rip), %rcx      # 0x19ae7
movl $0x21, %edx
callq 0x2070
movl -0x90(%rbp), %esi
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
callq 0x2060
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
movl $0x2f00, %esi           # imm = 0x2F00
movl %esi, -0x8c(%rbp)
callq 0x21d0
movl -0x70(%rbp), %edx
movb -0x69(%rbp), %al
movq -0x40(%rbp), %rdi
leaq 0x895e(%rip), %rcx      # 0x19af0
movl $0x2, %esi
callq 0x2070
movl -0x8c(%rbp), %esi
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
callq 0x2060
movl -0x70(%rbp), %edx
movb -0x69(%rbp), %al
movq -0x40(%rbp), %rdi
leaq 0x8951(%rip), %rcx      # 0x19b11
movl $0x3, %esi
callq 0x2070
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
movl $0x7c00, %esi           # imm = 0x7C00
movl %esi, -0x88(%rbp)
callq 0x21d0
movl -0x70(%rbp), %edx
movb -0x69(%rbp), %al
movq -0x40(%rbp), %rdi
leaq 0x8933(%rip), %rcx      # 0x19b26
movl $0x4, %esi
callq 0x2070
movl -0x88(%rbp), %esi
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
callq 0x2060
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
movl $0x1600, %esi           # imm = 0x1600
movl %esi, -0x84(%rbp)
callq 0x21d0
movl -0x70(%rbp), %edx
movb -0x69(%rbp), %al
movq -0x40(%rbp), %rdi
leaq 0x8901(%rip), %rcx      # 0x19b3a
movl $0x5, %esi
callq 0x2070
movl -0x84(%rbp), %esi
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
callq 0x2060
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
movl $0x1700, %esi           # imm = 0x1700
movl %esi, -0x80(%rbp)
callq 0x21d0
movl -0x70(%rbp), %edx
movb -0x69(%rbp), %al
movq -0x40(%rbp), %rdi
leaq 0x88d9(%rip), %rcx      # 0x19b55
movl $0x6, %esi
callq 0x2070
movl -0x80(%rbp), %esi
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
callq 0x2060
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
movl $0xf500, %esi           # imm = 0xF500
movl %esi, -0x7c(%rbp)
callq 0x21d0
movl -0x70(%rbp), %edx
movb -0x69(%rbp), %al
movq -0x40(%rbp), %rdi
leaq 0x88b6(%rip), %rcx      # 0x19b72
movl $0x7, %esi
callq 0x2070
movl -0x7c(%rbp), %esi
movq -0x78(%rbp), %rdx
movq -0x40(%rbp), %rdi
callq 0x2060
movl -0x70(%rbp), %edx
movb -0x69(%rbp), %al
movq -0x40(%rbp), %rdi
leaq 0x88aa(%rip), %rcx      # 0x19b91
movl $0x8, %esi
callq 0x2070
movq -0x40(%rbp), %rdi
callq 0x2100
movq -0x40(%rbp), %rdi
callq 0x21f0
movl -0x68(%rbp), %r9d
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rdi
movq %rsp, %rax
movl $0x0, 0x10(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, (%rax)
movl $0x20, %r8d
movl %r8d, -0x64(%rbp)
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
callq 0x2120
movl -0x64(%rbp), %r9d
movq -0x40(%rbp), %rdi
movq %rsp, %rax
movl $0x20, 0x10(%rax)
movl $0x20, 0x8(%rax)
movl $0x20, (%rax)
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x2120
movq -0x40(%rbp), %rdi
callq 0x2030
movq -0x40(%rbp), %rdi
callq 0x2100
movq -0x40(%rbp), %rdi
callq 0x2110
movl -0x44(%rbp), %eax
addl $-0x31, %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x6, %eax
ja 0x1172c
movq -0x60(%rbp), %rax
leaq 0x835c(%rip), %rcx      # 0x19704
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
cmpl $0x14, (%rax)
jl 0x1142a
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
jl 0x1142a
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
subl $0x14, %ecx
movl %ecx, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jge 0x11428
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,8)
jne 0x1141b
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x3, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x1, 0x4(%rax,%rcx,8)
jmp 0x11428
jmp 0x1141d
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x113e0
jmp 0x1142a
jmp 0x1172c
movq -0x20(%rbp), %rax
cmpl $0x1e, (%rax)
jl 0x114cc
movq -0x20(%rbp), %rax
movl (%rax), %ecx
subl $0x1e, %ecx
movl %ecx, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jge 0x114ca
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,8)
jne 0x114bd
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x2, (%rax,%rcx,8)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x48(%rbp)
cmpl $0x7, -0x48(%rbp)
jge 0x114bb
movq -0x10(%rbp), %rax
movslq -0x48(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0x114ae
movl -0x48(%rbp), %edx
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, 0x4(%rax,%rcx,8)
jmp 0x114b0
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x11485
jmp 0x114ca
jmp 0x114bf
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1144e
jmp 0x114cc
jmp 0x1172c
movq -0x18(%rbp), %rax
cmpl $0xf, (%rax)
jl 0x11536
movq -0x18(%rbp), %rax
movl (%rax), %ecx
subl $0xf, %ecx
movl %ecx, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jge 0x11534
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,8)
jne 0x11527
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x3, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x2, 0x4(%rax,%rcx,8)
jmp 0x11534
jmp 0x11529
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x114ec
jmp 0x11536
jmp 0x1172c
movq -0x18(%rbp), %rax
cmpl $0x14, (%rax)
jl 0x115a0
movq -0x18(%rbp), %rax
movl (%rax), %ecx
subl $0x14, %ecx
movl %ecx, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jge 0x1159e
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,8)
jne 0x11591
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x3, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x3, 0x4(%rax,%rcx,8)
jmp 0x1159e
jmp 0x11593
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x11556
jmp 0x115a0
jmp 0x1172c
movq -0x18(%rbp), %rax
cmpl $0x14, (%rax)
jl 0x1160a
movq -0x18(%rbp), %rax
movl (%rax), %ecx
subl $0x14, %ecx
movl %ecx, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jge 0x11608
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,8)
jne 0x115fb
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x3, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x4, 0x4(%rax,%rcx,8)
jmp 0x11608
jmp 0x115fd
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x115c0
jmp 0x1160a
jmp 0x1172c
movq -0x20(%rbp), %rax
cmpl $0x28, (%rax)
jl 0x11688
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
jl 0x11688
movq -0x20(%rbp), %rax
movl (%rax), %ecx
subl $0x28, %ecx
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jge 0x11686
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,8)
jne 0x11679
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x3, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x5, 0x4(%rax,%rcx,8)
jmp 0x11686
jmp 0x1167b
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1163e
jmp 0x11688
jmp 0x1172c
movq -0x20(%rbp), %rax
cmpl $0x23, (%rax)
jl 0x1172a
movq -0x20(%rbp), %rax
movl (%rax), %ecx
subl $0x23, %ecx
movl %ecx, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x58(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jge 0x11728
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,8)
jne 0x1171b
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl $0x2, (%rax,%rcx,8)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x4c(%rbp)
cmpl $0x7, -0x4c(%rbp)
jge 0x11719
movq -0x10(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x1170c
movl -0x4c(%rbp), %edx
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, 0x4(%rax,%rcx,8)
jmp 0x1170e
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x116e3
jmp 0x11728
jmp 0x1171d
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x116ac
jmp 0x1172a
jmp 0x1172c
movl -0x30(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)