// File: /workspace/github_c_makefile_star2_O0/S01den[P]Lost_CavernRL/pnj.c
// Function: setPnj
void setPnj(Map map[LONGUEUR][LARGEUR], Pnj pnj[], int *nbrPnjOnFloor)
{
	*nbrPnjOnFloor = rand()%NBR_PNJ_MAX+1;
	char *nameClerc[] = {"Sister Maria", "Brother Mikael","Mother Cynthia", "Father Lyris"};
	char *nameWorker[] = {"Swann","Nicolas","Thomas","Erica"};
	char *nameErmit[] = {"Michel","Wallace","Francis","Jannice"};
	char *nameScientific[] = {"Dr Jane","Dr Cooper","Dr Jones","Dr Marlene"}; 
	
	int i = 0;

	for(i = 0; i < *nbrPnjOnFloor; i++) // let's spawn the NPC
	{
		pnj[i].x = rand()%LONGUEUR;
		pnj[i].y = rand()%LARGEUR;
		pnj[i].questDone = 0;

		if(pnj[i].x == 0)
			pnj[i].x++;
		if(pnj[i].x == LONGUEUR)
			pnj[i].x--;
		if(pnj[i].y == 0)
			pnj[i].y++;
		if(pnj[i].y == LARGEUR)
			pnj[i].y--;

		if(map[pnj[i].x][pnj[i].y].content != FLOOR)
		{
			if(LARGEUR-pnj[i].y > pnj[i].y)
			{
				while(map[pnj[i].x][pnj[i].y].content != FLOOR && pnj[i].y < LARGEUR)
				{
					pnj[i].y++;
				}
			}
			else
			{
				while(map[pnj[i].x][pnj[i].y].content != FLOOR && pnj[i].y > 0)
				{
					pnj[i].y--;
				}
			}
		}

		int rollType = rand()%4;
		pnj[i].type = rollType;

		switch(pnj[i].type)
		{
			case 0: // cleric
				pnj[i].name = nameClerc[rand()%4];
				pnj[i].quest = rand()%3;
				break;
			case 1: // worker
				pnj[i].name = nameWorker[rand()%4];
				pnj[i].quest = rand()%3+3;
				break;
			case 2: // ermit
				pnj[i].name = nameErmit[rand()%4];
				pnj[i].quest = rand()%3+6;
				break;
			case 3: // scientific
				pnj[i].name = nameScientific[rand()%4];
				pnj[i].quest = rand()%2+9;
				break;
		}
			map[pnj[i].x][pnj[i].y].content = PNJ;
			map[pnj[i].x][pnj[i].y].typePnj = pnj[i].type;

	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
callq 0x21e0
movl $0x4, %ecx
cltd
idivl %ecx
addl $0x1, %edx
movq -0x18(%rbp), %rax
movl %edx, (%rax)
movq 0x8b8c(%rip), %rax      # 0x1cd40
movq %rax, -0x40(%rbp)
movq 0x8b89(%rip), %rax      # 0x1cd48
movq %rax, -0x38(%rbp)
movq 0x8b86(%rip), %rax      # 0x1cd50
movq %rax, -0x30(%rbp)
movq 0x8b83(%rip), %rax      # 0x1cd58
movq %rax, -0x28(%rbp)
movq 0x8b80(%rip), %rax      # 0x1cd60
movq %rax, -0x60(%rbp)
movq 0x8b7d(%rip), %rax      # 0x1cd68
movq %rax, -0x58(%rbp)
movq 0x8b7a(%rip), %rax      # 0x1cd70
movq %rax, -0x50(%rbp)
movq 0x8b77(%rip), %rax      # 0x1cd78
movq %rax, -0x48(%rbp)
movq 0x8b74(%rip), %rax      # 0x1cd80
movq %rax, -0x80(%rbp)
movq 0x8b71(%rip), %rax      # 0x1cd88
movq %rax, -0x78(%rbp)
movq 0x8b6e(%rip), %rax      # 0x1cd90
movq %rax, -0x70(%rbp)
movq 0x8b6b(%rip), %rax      # 0x1cd98
movq %rax, -0x68(%rbp)
movq 0x8b68(%rip), %rax      # 0x1cda0
movq %rax, -0xa0(%rbp)
movq 0x8b62(%rip), %rax      # 0x1cda8
movq %rax, -0x98(%rbp)
movq 0x8b5c(%rip), %rax      # 0x1cdb0
movq %rax, -0x90(%rbp)
movq 0x8b56(%rip), %rax      # 0x1cdb8
movq %rax, -0x88(%rbp)
movl $0x0, -0xa4(%rbp)
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x147e8
callq 0x21e0
movl $0x27, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl %edx, 0x14(%rax)
callq 0x21e0
movl $0x82, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl %edx, 0x18(%rax)
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x14(%rax)
jne 0x1431f
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x27, 0x14(%rax)
jne 0x14352
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x14(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x18(%rax)
jne 0x14385
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x82, 0x18(%rax)
jne 0x143bb
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0x14(%rcx), %rcx
imulq $0xe38, %rcx, %rcx      # imm = 0xE38
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0x18(%rcx), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, (%rax)
je 0x1457c
movq -0x10(%rbp), %rcx
movslq -0xa4(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movl $0x82, %eax
subl 0x18(%rcx), %eax
movq -0x10(%rbp), %rcx
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
jle 0x144dd
jmp 0x1443c
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movslq 0x14(%rax), %rax
imulq $0xe38, %rax, %rax      # imm = 0xE38
addq %rax, %rcx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movslq 0x18(%rax), %rax
imulq $0x1c, %rax, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpl $0x1, (%rcx)
movb %al, -0xa9(%rbp)
je 0x144ac
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x82, 0x18(%rax)
setl %al
movb %al, -0xa9(%rbp)
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x144b8
jmp 0x144d8
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
jmp 0x1443c
jmp 0x1457a
jmp 0x144df
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movslq 0x14(%rax), %rax
imulq $0xe38, %rax, %rax      # imm = 0xE38
addq %rax, %rcx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movslq 0x18(%rax), %rax
imulq $0x1c, %rax, %rax
addq %rax, %rcx
xorl %eax, %eax
cmpl $0x1, (%rcx)
movb %al, -0xaa(%rbp)
je 0x1454c
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x18(%rax)
setg %al
movb %al, -0xaa(%rbp)
movb -0xaa(%rbp), %al
testb $0x1, %al
jne 0x14558
jmp 0x14578
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x18(%rax)
jmp 0x144df
jmp 0x1457a
jmp 0x1457c
callq 0x21e0
movl %eax, %edx
addl $0x3, %edx
testl %eax, %eax
movl %eax, %ecx
cmovsl %edx, %ecx
andl $-0x4, %ecx
subl %ecx, %eax
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
movl %edx, 0x8(%rax,%rcx)
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
movl 0x8(%rax,%rcx), %eax
movq %rax, -0xb8(%rbp)
subq $0x3, %rax
ja 0x14734
movq -0xb8(%rbp), %rax
leaq 0x5b35(%rip), %rcx      # 0x1a118
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x21e0
movl $0x4, %ecx
cltd
idivl %ecx
movslq %edx, %rax
movq -0x40(%rbp,%rax,8), %rcx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
callq 0x21e0
movl $0x3, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl %edx, 0xc(%rax)
jmp 0x14734
callq 0x21e0
movl $0x4, %ecx
cltd
idivl %ecx
movslq %edx, %rax
movq -0x60(%rbp,%rax,8), %rcx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
callq 0x21e0
movl $0x3, %ecx
cltd
idivl %ecx
addl $0x3, %edx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl %edx, 0xc(%rax)
jmp 0x14734
callq 0x21e0
movl $0x4, %ecx
cltd
idivl %ecx
movslq %edx, %rax
movq -0x80(%rbp,%rax,8), %rcx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
callq 0x21e0
movl $0x3, %ecx
cltd
idivl %ecx
addl $0x6, %edx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl %edx, 0xc(%rax)
jmp 0x14734
callq 0x21e0
movl $0x4, %ecx
cltd
idivl %ecx
movslq %edx, %rax
movq -0xa0(%rbp,%rax,8), %rcx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
callq 0x21e0
movl $0x2, %ecx
cltd
idivl %ecx
addl $0x9, %edx
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl %edx, 0xc(%rax)
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0x14(%rcx), %rcx
imulq $0xe38, %rcx, %rcx      # imm = 0xE38
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movslq -0xa4(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq 0x18(%rcx), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0xb, (%rax)
movq -0x10(%rbp), %rax
movslq -0xa4(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rdx
movslq -0xa4(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rdx
movslq 0x14(%rdx), %rdx
imulq $0xe38, %rdx, %rdx      # imm = 0xE38
addq %rdx, %rax
movq -0x10(%rbp), %rdx
movslq -0xa4(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rdx
movslq 0x18(%rdx), %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x1427d
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)