// File: /workspace/github_c_makefile_star2_O0/S01den[P]Lost_CavernRL/pnj.c
// Function: sayQuest
int sayQuest(Pnj pnj, Quest listQuests[], Quest actQuests[], int *nbrQuestAct, Weapons listWeapons[], Armor listArmor[], double *disease, int *questDrug, int *drugUsed)
{
	char *classNames[] = {"CLERIC","WORKER","ERMIT","SCIENTIST"};
	char *typeRewards[] = {"VAX","LIFE POINTS","COMPONENTS","EXOTIC BLOOD"};
	int key = 0;
	int i = 0;
	int select = 0;
	int choice = -1;

	if(listQuests[pnj.quest].isSet == 0)
	{
		WINDOW *win;
		win = newwin(13,75,LONGUEUR/2,LARGEUR/2+10);
		box(win,0,0);
		wattron(win, A_UNDERLINE);
		mvwprintw(win,2,22,"%s (%s)",pnj.name, classNames[pnj.type]);
		wattroff(win, A_UNDERLINE);
		mvwprintw(win,4,2,"%s",listQuests[pnj.quest].description);
		keypad(win, TRUE);
		if(listQuests[pnj.quest].typeReward <= 3)
		{
			mvwprintw(win,7,2,"Reward: %d (%s)", listQuests[pnj.quest].reward, typeRewards[listQuests[pnj.quest].typeReward]);
		}
		else if(listQuests[pnj.quest].typeReward == 4)
		{
			mvwprintw(win,7,2,"Reward: %s", listWeapons[listQuests[pnj.quest].reward].name);
		}
		else if(listQuests[pnj.quest].typeReward == 5)
		{
			mvwprintw(win,7,2,"Reward: %s", listArmor[listQuests[pnj.quest].reward].name);
		}
		else if(listQuests[pnj.quest].typeReward == 6)
		{
			mvwprintw(win,7,2,"Reward: a drug");
		}

		char *menus[] = {"ACCEPT","REJECT"};

		while(1)
		{
			for(i = 0; i < 2; i++)
			{
				if(i == select)
				{
					wattron(win, COLOR_PAIR(STAIRS_COLOR));
					mvwprintw(win, i+9, 75/2-10, menus[i]);
					wattroff(win,COLOR_PAIR(STAIRS_COLOR));
				}
				else
				{
					mvwprintw(win, i+9, 75/2-10, menus[i]);
				}
			}

			wrefresh(win);

			key = wgetch(win);
			switch(key)
			{	
				case KEY_DOWN:
					if(select+1<=1)
						select++;
					break;

				case KEY_UP:
					if(select-1 >= 0)
						select--;
					break;

				case '\n':
					choice = select;
					break;
			}
			if(choice != -1)
				break;
		}

		if(choice == 0 && *nbrQuestAct+1 <= NBR_QUESTS_MAX)
		{
			if(listQuests[pnj.quest].indice == 2)
			{
				*disease = 0;
			}
			int indiceQuest = 0;
			for(indiceQuest = 0; indiceQuest < NBR_QUESTS_MAX; indiceQuest++)
			{
				if(actQuests[indiceQuest].isSet == 0)
				{
					actQuests[indiceQuest].name = listQuests[pnj.quest].name;
					actQuests[indiceQuest].description = listQuests[pnj.quest].description;
					actQuests[indiceQuest].indice = listQuests[pnj.quest].indice;
					actQuests[indiceQuest].isSet = 1;
					listQuests[pnj.quest].isSet = 1;
					actQuests[indiceQuest].typeReward = listQuests[pnj.quest].typeReward;
					actQuests[indiceQuest].reward = listQuests[pnj.quest].reward;
					if(actQuests[indiceQuest].indice == 0)
					{
						*drugUsed = 0;
						*questDrug = 1;
					}
				}
			}
			(*nbrQuestAct)++;
		}

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

	return choice;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rcx, %rax
movq 0x38(%rbp), %rcx
movq 0x30(%rbp), %rcx
leaq 0x10(%rbp), %rcx
movq %rcx, -0xb0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rax, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq 0x92e0(%rip), %rax      # 0x1ccf0
movq %rax, -0x50(%rbp)
movq 0x92dd(%rip), %rax      # 0x1ccf8
movq %rax, -0x48(%rbp)
movq 0x92da(%rip), %rax      # 0x1cd00
movq %rax, -0x40(%rbp)
movq 0x92d7(%rip), %rax      # 0x1cd08
movq %rax, -0x38(%rbp)
movq 0x92d4(%rip), %rax      # 0x1cd10
movq %rax, -0x70(%rbp)
movq 0x92d1(%rip), %rax      # 0x1cd18
movq %rax, -0x68(%rbp)
movq 0x92ce(%rip), %rax      # 0x1cd20
movq %rax, -0x60(%rbp)
movq 0x92cb(%rip), %rax      # 0x1cd28
movq %rax, -0x58(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0xffffffff, -0x80(%rbp) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jne 0x140a6
movl $0xd, %edi
movl $0x4b, %ecx
movl $0x13, %edx
movl %ecx, %esi
callq 0x2130
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
xorl %r9d, %r9d
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x2120
movq -0x88(%rbp), %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %eax, %eax
movl %eax, %edx
callq 0x21d0
movq -0xb0(%rbp), %rax
movq -0x88(%rbp), %rdi
movq (%rax), %r8
movslq 0x8(%rax), %rax
movq -0x50(%rbp,%rax,8), %r9
movl $0x2, %esi
movl $0x16, %edx
leaq 0x555d(%rip), %rcx      # 0x19082
movb $0x0, %al
callq 0x2070
movq -0x88(%rbp), %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %eax, %eax
movl %eax, %edx
callq 0x2060
movq -0xb0(%rbp), %rcx
movq -0x88(%rbp), %rdi
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %r8
movl $0x4, %esi
movl $0x2, %edx
leaq 0x55fa(%rip), %rcx      # 0x1916d
movb $0x0, %al
callq 0x2070
movq -0x88(%rbp), %rdi
movl $0x1, %esi
callq 0x2080
movq -0xb0(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x3, 0x10(%rax)
jg 0x13bfd
movq -0xb0(%rbp), %rcx
movq -0x88(%rbp), %rdi
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl 0x14(%rax), %r8d
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x10(%rax), %rax
movq -0x70(%rbp,%rax,8), %r9
movl $0x7, %esi
movl $0x2, %edx
leaq 0x5b98(%rip), %rcx      # 0x19789
movb $0x0, %al
callq 0x2070
jmp 0x13d0b
movq -0xb0(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x4, 0x10(%rax)
jne 0x13c65
movq -0xb0(%rbp), %rdx
movq -0x88(%rbp), %rdi
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movslq 0xc(%rdx), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0x14(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq (%rax), %r8
movl $0x7, %esi
movl $0x2, %edx
leaq 0x5b48(%rip), %rcx      # 0x197a1
movb $0x0, %al
callq 0x2070
jmp 0x13d09
movq -0xb0(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x5, 0x10(%rax)
jne 0x13cca
movq -0xb0(%rbp), %rdx
movq -0x88(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x8(%rbp), %rcx
movslq 0xc(%rdx), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0x14(%rcx), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %r8
movl $0x7, %esi
movl $0x2, %edx
leaq 0x5ae0(%rip), %rcx      # 0x197a1
movb $0x0, %al
callq 0x2070
jmp 0x13d07
movq -0xb0(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x6, 0x10(%rax)
jne 0x13d05
movq -0x88(%rbp), %rdi
movl $0x7, %esi
movl $0x2, %edx
leaq 0x5ab6(%rip), %rcx      # 0x197b4
movb $0x0, %al
callq 0x2070
jmp 0x13d07
jmp 0x13d09
jmp 0x13d0b
movq 0x901e(%rip), %rax      # 0x1cd30
movq %rax, -0xa0(%rbp)
movq 0x9018(%rip), %rax      # 0x1cd38
movq %rax, -0x98(%rbp)
movl $0x0, -0x78(%rbp)
cmpl $0x2, -0x78(%rbp)
jge 0x13dc6
movl -0x78(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jne 0x13d91
movq -0x88(%rbp), %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %eax, %eax
movl %eax, %edx
callq 0x21d0
movq -0x88(%rbp), %rdi
movl -0x78(%rbp), %esi
addl $0x9, %esi
movslq -0x78(%rbp), %rax
movq -0xa0(%rbp,%rax,8), %rcx
movl $0x1b, %edx
movb $0x0, %al
callq 0x2070
movq -0x88(%rbp), %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %eax, %eax
movl %eax, %edx
callq 0x2060
jmp 0x13db6
movq -0x88(%rbp), %rdi
movl -0x78(%rbp), %esi
addl $0x9, %esi
movslq -0x78(%rbp), %rax
movq -0xa0(%rbp,%rax,8), %rcx
movl $0x1b, %edx
movb $0x0, %al
callq 0x2070
jmp 0x13db8
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x13d2e
movq -0x88(%rbp), %rdi
callq 0x2100
movq -0x88(%rbp), %rdi
callq 0x21f0
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0xb4(%rbp)
subl $0xa, %eax
je 0x13e3b
jmp 0x13df1
movl -0xb4(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x13e0f
jmp 0x13e00
movl -0xb4(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x13e25
jmp 0x13e41
movl -0x7c(%rbp), %eax
addl $0x1, %eax
cmpl $0x1, %eax
jg 0x13e23
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x13e41
movl -0x7c(%rbp), %eax
subl $0x1, %eax
cmpl $0x0, %eax
jl 0x13e39
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x13e41
movl -0x7c(%rbp), %eax
movl %eax, -0x80(%rbp)
cmpl $-0x1, -0x80(%rbp)
je 0x13e49
jmp 0x13e4e
jmp 0x13d27
cmpl $0x0, -0x80(%rbp)
jne 0x14018
movq -0x18(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
cmpl $0x3, %eax
jg 0x14018
movq -0xb0(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x2, 0x18(%rax)
jne 0x13e91
movq -0x30(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl $0x0, -0xa4(%rbp)
movl $0x0, -0xa4(%rbp)
cmpl $0x3, -0xa4(%rbp)
jge 0x1400d
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jne 0x13ff7
movq -0xb0(%rbp), %rcx
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq (%rax), %rdx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movq %rdx, (%rax)
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movq %rdx, 0x8(%rax)
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl 0x18(%rax), %edx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movl %edx, 0x18(%rax)
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl $0x1, 0x1c(%rax)
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl $0x1, 0x1c(%rax)
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl 0x10(%rax), %edx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movl %edx, 0x10(%rax)
movq -0x8(%rbp), %rax
movslq 0xc(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x18(%rax)
jne 0x13ff5
movq 0x38(%rbp), %rax
movl $0x0, (%rax)
movq 0x30(%rbp), %rax
movl $0x1, (%rax)
jmp 0x13ff7
jmp 0x13ff9
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x13ea5
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x88(%rbp), %rdi
movl $0x20, %r8d
xorl %r9d, %r9d
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x2120
movq -0x88(%rbp), %rdi
movl $0x20, %r9d
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
movl $0x20, (%rsp)
movl $0x20, 0x8(%rsp)
movl $0x20, 0x10(%rsp)
callq 0x2120
movq -0x88(%rbp), %rdi
callq 0x2030
movq -0x88(%rbp), %rdi
callq 0x2100
movq -0x88(%rbp), %rdi
callq 0x2110
movl -0x80(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)