// File: /workspace/github_c_makefile_star2_O0/S01den[P]Lost_CavernRL/ennemy.c
// Function: setEnnemies
void setEnnemies(Map map[LONGUEUR][LARGEUR], Ennemy ennemies[], int nbrEnnemies, int *nbrEnnemyInFloor, int floor)
{
	int nbrEnnemiesRand = rand()%nbrEnnemies+15;
	if(nbrEnnemiesRand > nbrEnnemies)
		nbrEnnemiesRand -= (nbrEnnemies-nbrEnnemiesRand);
	
	int i = 0;
	char name[9];


	for(i = 0; i < nbrEnnemiesRand; i++) // let's spawn the monsters
	{
		ennemies[i].x = rand()%LONGUEUR;
		ennemies[i].y = rand()%LARGEUR;

		if(ennemies[i].x == 0)
			ennemies[i].x++;
		if(ennemies[i].x == LONGUEUR)
			ennemies[i].x--;
		if(ennemies[i].y == 0)
			ennemies[i].y++;
		if(ennemies[i].y == LARGEUR)
			ennemies[i].y--;
		
		moveRand(ennemies,map,i);

		int rollType = rand()%100;

		ennemies[i].effect = 0;

		if(rollType < 40) // droid
		{
			ennemies[i].boss = 0;
			ennemies[i].type = 1;
			ennemies[i].efficiency = 90;
			ennemies[i].life = 20+2*floor;
			ennemies[i].strength = rand()%5+3;
			ennemies[i].seen = 0;
			ennemies[i].agility = rand()%5+3;
			ennemies[i].haveBlaster = rand()%2;
		}
		else if(rollType >= 40 && rollType < 60)
		{
			ennemies[i].boss = 0;
			ennemies[i].type = 2;
			ennemies[i].efficiency = 85;
			ennemies[i].life = 40+2*floor;
			ennemies[i].strength = 3;
			ennemies[i].seen = 0;
			ennemies[i].agility = rand()%7+(3+floor);
			ennemies[i].haveBlaster = 1;			
		}
		else if(rollType >= 60 && rollType < 90)
		{
			ennemies[i].boss = 0;
			ennemies[i].type = 3; 
			ennemies[i].efficiency = 80;
			ennemies[i].life = 30+2*floor;
			ennemies[i].strength = rand()%6+(2+floor);
			ennemies[i].seen = 0;
			ennemies[i].agility = 3;
			ennemies[i].haveBlaster = 0;
			ennemies[i].name = "GUARDIAN";	
		}
		else if(rollType >= 90 && rollType < 100)
		{
			ennemies[i].boss = 0;
			ennemies[i].type = 4;
			ennemies[i].efficiency = 100;
			ennemies[i].life = 15+2*floor;
			ennemies[i].strength = 3;
			ennemies[i].seen = 0;
			ennemies[i].agility = 3;
			ennemies[i].haveBlaster = 0;
			ennemies[i].name = "INFECTED GUARDIAN";	
		}

		if(ennemies[i].type == 1)
		{
			ennemies[i].name = (char*)malloc(11*sizeof(char));
			name[0] = rand()%25+65;
			name[1] = rand()%9+48;
			name[2] = '-';
			name[3] = rand()%25+65;
			name[4] = rand()%9+48;
			name[5] = rand()%9+48;
			name[6] = '@';
			strcpy(ennemies[i].name,name);

			if(strcmp(name,"R2-D26@") == 0)
			{
				strcpy(ennemies[i].name,"D43D-B33F!");
				ennemies[i].life = 300;
				ennemies[i].strength = rand()%50+4;
				ennemies[i].seen = 0;
				ennemies[i].agility = rand()%50+4;
				ennemies[i].haveBlaster = rand()%2;				
			}
		}
		else if(ennemies[i].type == 2)
		{
			ennemies[i].name = (char*)malloc(11*sizeof(char));
			name[0] = 'T';
			name[1] = 'T';
			name[2] = '_';
			name[3] = rand()%9+48;
			name[4] = rand()%9+48;
			name[5] = rand()%9+48;
			name[6] = '&';
			strcpy(ennemies[i].name,name);
		}
	}

	*nbrEnnemyInFloor = nbrEnnemiesRand;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
callq 0x21e0
cltd
idivl -0x14(%rbp)
addl $0xf, %edx
movl %edx, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0xb740
movl -0x14(%rbp), %ecx
subl -0x28(%rbp), %ecx
movl -0x28(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0xbe68
callq 0x21e0
movl $0x27, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, (%rax)
callq 0x21e0
movl $0x82, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, 0x4(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0xb7c1
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x27, (%rax)
jne 0xb7eb
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x4(%rax)
jne 0xb818
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x82, 0x4(%rax)
jne 0xb848
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x83b0
callq 0x21e0
movl $0x64, %ecx
cltd
idivl %ecx
movl %edx, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x24(%rax)
cmpl $0x28, -0x3c(%rbp)
jge 0xb962
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x20(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x5a, 0x1c(%rax)
movl -0x24(%rbp), %ecx
shll %ecx
addl $0x14, %ecx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
callq 0x21e0
movl $0x5, %ecx
cltd
idivl %ecx
addl $0x3, %edx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
callq 0x21e0
movl $0x5, %ecx
cltd
idivl %ecx
addl $0x3, %edx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, 0x14(%rax)
callq 0x21e0
movl $0x2, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, 0x18(%rax)
jmp 0xbc20
cmpl $0x28, -0x3c(%rbp)
jl 0xba40
cmpl $0x3c, -0x3c(%rbp)
jge 0xba40
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x2, 0x20(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x55, 0x1c(%rax)
movl -0x24(%rbp), %ecx
shll %ecx
addl $0x28, %ecx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x3, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
callq 0x21e0
movl $0x7, %ecx
cltd
idivl %ecx
movl -0x24(%rbp), %eax
addl $0x3, %eax
addl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, 0x14(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x18(%rax)
jmp 0xbc1e
cmpl $0x3c, -0x3c(%rbp)
jl 0xbb38
cmpl $0x5a, -0x3c(%rbp)
jge 0xbb38
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x3, 0x20(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x50, 0x1c(%rax)
movl -0x24(%rbp), %ecx
shll %ecx
addl $0x1e, %ecx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
callq 0x21e0
movl $0x6, %ecx
cltd
idivl %ecx
movl -0x24(%rbp), %eax
addl $0x2, %eax
addl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x3, 0x14(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
leaq 0xde94(%rip), %rcx      # 0x199c3
movq %rcx, 0x30(%rax)
jmp 0xbc1c
cmpl $0x5a, -0x3c(%rbp)
jl 0xbc1a
cmpl $0x64, -0x3c(%rbp)
jge 0xbc1a
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x4, 0x20(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x64, 0x1c(%rax)
movl -0x24(%rbp), %ecx
shll %ecx
addl $0xf, %ecx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x3, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x3, 0x14(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
leaq 0xdd97(%rip), %rcx      # 0x199ad
movq %rcx, 0x30(%rax)
jmp 0xbc1c
jmp 0xbc1e
jmp 0xbc20
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, 0x20(%rax)
jne 0xbdb2
movl $0xb, %edi
callq 0x20a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x30(%rax)
callq 0x21e0
movl $0x19, %ecx
cltd
idivl %ecx
addl $0x41, %edx
movb %dl, %al
movb %al, -0x35(%rbp)
callq 0x21e0
movl $0x9, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %al
movb %al, -0x34(%rbp)
movb $0x2d, -0x33(%rbp)
callq 0x21e0
movl $0x19, %ecx
cltd
idivl %ecx
addl $0x41, %edx
movb %dl, %al
movb %al, -0x32(%rbp)
callq 0x21e0
movl $0x9, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %al
movb %al, -0x31(%rbp)
callq 0x21e0
movl $0x9, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %al
movb %al, -0x30(%rbp)
movb $0x40, -0x2f(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x30(%rax), %rdi
leaq -0x35(%rbp), %rsi
callq 0x2170
leaq -0x35(%rbp), %rdi
leaq 0xd271(%rip), %rsi      # 0x18f62
callq 0x2160
cmpl $0x0, %eax
jne 0xbdad
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x30(%rax), %rdi
leaq 0xd251(%rip), %rsi      # 0x18f6a
callq 0x2170
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x12c, 0x8(%rax)       # imm = 0x12C
callq 0x21e0
movl $0x32, %ecx
cltd
idivl %ecx
addl $0x4, %edx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
callq 0x21e0
movl $0x32, %ecx
cltd
idivl %ecx
addl $0x4, %edx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, 0x14(%rax)
callq 0x21e0
movl $0x2, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl %edx, 0x18(%rax)
jmp 0xbe58
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, 0x20(%rax)
jne 0xbe56
movl $0xb, %edi
callq 0x20a0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x30(%rax)
movb $0x54, -0x35(%rbp)
movb $0x54, -0x34(%rbp)
movb $0x5f, -0x33(%rbp)
callq 0x21e0
movl $0x9, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %al
movb %al, -0x32(%rbp)
callq 0x21e0
movl $0x9, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %al
movb %al, -0x31(%rbp)
callq 0x21e0
movl $0x9, %ecx
cltd
idivl %ecx
addl $0x30, %edx
movb %dl, %al
movb %al, -0x30(%rbp)
movb $0x26, -0x2f(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq 0x30(%rax), %rdi
leaq -0x35(%rbp), %rsi
callq 0x2170
jmp 0xbe58
jmp 0xbe5a
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xb74e
movl -0x28(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)