// File: /workspace/github_c_makefile_star2_O0/S01den[P]Lost_CavernRL/player.c
// Function: shotLine
int shotLine(Map map[LONGUEUR][LARGEUR],Weapons *weaponHold, Ennemy ennemies[], char dir, Player player, int nbrEnnemies, int *components)
{
	int x, y = 0;
	int posX = player.x;
	int posY = player.y;
	int noGem = 0; // you must pick a gem with contact weapons

	weaponHold->state--;

	switch(dir)
	{
		case 'z':
			x = -1;
			y = 0;
			break;
		case 's':
			x = 1;
			y = 0;
			break;
		case 'q':
			x = 0;
			y = -1;
			break;
		case 'd':
			x = 0;
			y = 1;
			break;
		case 'a':
			x = -1;
			y = -1;
			break;
		case 'e':
			x = -1;
			y = 1;
			break;
		case 'w':
			x = 1;
			y = -1;
			break;
		case 'x':
			x = 1;
			y = 1;
			break;
	}

	int hit = 0;
	int turn = 0;
	int ret = 0;

	while(hit == 0 && turn < weaponHold->range)
	{
		if(map[posX][posY].typeEnnemy > 0 && rand()%101 <= weaponHold->efficiency)
		{
			int ennemySeenIndice = testEnnemyOnPos(ennemies,posX,posY,nbrEnnemies);
			if(ennemySeenIndice >= 0)
			{
				ennemies[ennemySeenIndice].life -= abs(weaponHold->degat+player.agility/4);
				if(weaponHold->indice == 1) // darts random effect
				{
					if(rand()%4 == 0)
					{
						if(rand()%2 == 1)
						{
							ennemies[ennemySeenIndice].effect = 1;
						}
						else
						{
							ennemies[ennemySeenIndice].effect = 2;
						}
					}
				}
				if(ennemies[ennemySeenIndice].life <= 0)
				{
					ret = 1;
					if(ennemies[ennemySeenIndice].type == 1)
					{
						int compWin = rand()%10+5;
						*components += compWin;	
					}
					else if(ennemies[ennemySeenIndice].type == 2)
					{
						int compWin = rand()%15+7;
						*components += compWin;	
					}
				}

				hit = 1;
			}
		}
		else if(map[posX][posY].content == WALL)
		{
			destroyWall(map, posX, posY, weaponHold,&noGem);
			hit = 1;
		}
		else
		{
			turn++;
			posX += x;
			posY += y;
		}

	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb %cl, -0x19(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movl 0x14(%rax), %ecx
movl %ecx, -0x34(%rbp)
movl 0x18(%rax), %eax
movl %eax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
decl %ecx
movl %ecx, 0x1c(%rax)
movsbl -0x19(%rbp), %eax
addl $-0x61, %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x19, %eax
ja 0x13145
movq -0x60(%rbp), %rax
leaq 0x6f22(%rip), %rcx      # 0x19fe0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x30(%rbp)
jmp 0x13145
movl $0x1, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
jmp 0x13145
movl $0x0, -0x2c(%rbp)
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
jmp 0x13145
movl $0x0, -0x2c(%rbp)
movl $0x1, -0x30(%rbp)
jmp 0x13145
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
jmp 0x13145
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x30(%rbp)
jmp 0x13145
movl $0x1, -0x2c(%rbp)
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
jmp 0x13145
movl $0x1, -0x2c(%rbp)
movl $0x1, -0x30(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x40(%rbp)
movb %al, -0x69(%rbp)
jne 0x13175
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x20(%rcx), %eax
setl %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x13181
jmp 0x13372
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xe38, %rcx, %rcx      # imm = 0xE38
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jle 0x1330e
callq 0x21e0
movl $0x65, %ecx
cltd
idivl %ecx
movq -0x10(%rbp), %rax
cmpl 0x14(%rax), %edx
jg 0x1330e
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %edx
movl -0x20(%rbp), %ecx
callq 0x8a10
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jl 0x1330c
movq -0x68(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl %ecx, -0x70(%rbp)
movl 0x24(%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl -0x70(%rbp), %edx
addl %eax, %edx
movl %edx, %eax
negl %eax
cmovnsl %eax, %edx
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpl $0x1, 0x2c(%rax)
jne 0x1327d
callq 0x21e0
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x1327b
callq 0x21e0
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x13263
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x24(%rax)
jmp 0x13279
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl $0x2, 0x24(%rax)
jmp 0x1327b
jmp 0x1327d
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x8(%rax)
jg 0x13305
movl $0x1, -0x48(%rbp)
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, 0x20(%rax)
jne 0x132ce
callq 0x21e0
movl $0xa, %ecx
cltd
idivl %ecx
addl $0x5, %edx
movl %edx, -0x50(%rbp)
movl -0x50(%rbp), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x13303
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, 0x20(%rax)
jne 0x13301
callq 0x21e0
movl $0xf, %ecx
cltd
idivl %ecx
addl $0x7, %edx
movl %edx, -0x54(%rbp)
movl -0x54(%rbp), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x13303
jmp 0x13305
movl $0x1, -0x40(%rbp)
jmp 0x1336d
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xe38, %rcx, %rcx      # imm = 0xE38
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x13350
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %edx
movq -0x10(%rbp), %rcx
leaq -0x3c(%rbp), %r8
callq 0xf750
movl $0x1, -0x40(%rbp)
jmp 0x1336b
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x2c(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x1336d
jmp 0x1315a
movl -0x48(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)