// File: /workspace/github_c_makefile_star2_O2/S01den[P]Lost_CavernRL/player.c
// Function: hit
int hit(char dirChar, int dirX, int dirY, WINDOW *win_map, Player *player, Weapons *weaponHold, Weapons listWeapons[], Map map[LONGUEUR][LARGEUR], int *gem, Ennemy ennemies[], int nbrEnnemyInFloor, int *component, int *exoticBlood, int *compBefore, int *indiceEnnemy, int *retHit, Pnj pnj[], int nbrPnjInFloor, int *indicePnj)
{
	int ret = 0;

	if(weaponHold->type == 0)
	{
		if(rand()%100 <= weaponHold->efficiency)
		{
			if(map[player->x+dirX][player->y+dirY].content == WALL)
			{
				if(weaponHold->indice == 3) // if we use our fists
				{
					player->life-=2;
				}
				destroyWall(map,player->x+dirX,player->y+dirY,weaponHold, gem);
			}

			*indiceEnnemy = testEnnemyOnPos(ennemies,player->x+dirX,player->y+dirY,nbrEnnemyInFloor);
			if(*indiceEnnemy >= 0)
			{
				*compBefore = *component;
				*retHit = hitEnnemy(*player, &ennemies[*indiceEnnemy], *weaponHold, component, exoticBlood);
				ret = *retHit;
			}
		}
	}
	else if(weaponHold->indice == 1 || weaponHold->indice == 2 || weaponHold->indice == 4 || weaponHold->indice == 5 || weaponHold->indice == 9)
	{
		*retHit = shotLine(map,weaponHold,ennemies,dirChar,*player,nbrEnnemyInFloor,component);
		ret = *retHit;
	}
	else if(listWeapons[weaponHold->indice].type == 2)
	{
		*retHit = burn(map,weaponHold,ennemies,dirChar,*player,nbrEnnemyInFloor,component,win_map);
		ret = *retHit;
	}
	else if(listWeapons[weaponHold->indice].type == 3 && (*gem)-1 >= 0) // crystal canon
	{
		(*gem)--;
		flashBomb(win_map);
		crystalCanon(map,*player,dirChar);
	}

	*indicePnj = testPnjOnPos(pnj,player->x+dirX,player->y+dirY,nbrPnjInFloor);	

	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r9, %r12
movq %r8, %r14
movl %edx, %ebx
movl %esi, %ebp
movq 0x148(%rsp), %rsi
movq 0x128(%rsp), %r9
movl 0x120(%rsp), %r8d
movq 0x118(%rsp), %rdx
movq 0x110(%rsp), %r11
movq 0x108(%rsp), %r10
cmpl $0x0, 0x24(%r12)
je 0xa30e
movl %edi, %r15d
movslq 0x2c(%r12), %rax
cmpq $0x9, %rax
ja 0xa46c
movl $0x236, %edi            # imm = 0x236
btl %eax, %edi
jae 0xa46c
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movaps %xmm3, 0xb0(%rsp)
movaps %xmm2, 0xa0(%rsp)
movaps %xmm1, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps 0x80(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
movaps 0xa0(%rsp), %xmm2
movaps 0xb0(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movsbl %r15b, %ecx
movq %r10, %rdi
movq %rsi, %r15
movq %r12, %rsi
callq 0xa6a9
movl %eax, %r13d
movl %eax, (%r15)
jmp 0xa519
movq %r10, %r15
callq 0x11d0
pushq $0x64
popq %rcx
cltd
idivl %ecx
xorl %r13d, %r13d
cmpl 0x14(%r12), %edx
jg 0xa519
movslq 0x14(%r14), %rax
movslq %ebp, %rsi
addq %rax, %rsi
movslq 0x18(%r14), %rax
movslq %ebx, %rdx
addq %rax, %rdx
imulq $0xe38, %rsi, %rax      # imm = 0xE38
addq %r15, %rax
imulq $0x1c, %rdx, %rcx
cmpl $0x2, (%rcx,%rax)
jne 0xa37e
cmpl $0x3, 0x2c(%r12)
jne 0xa35f
addl $-0x2, 0x10(%r14)
movq %r15, %rdi
movq %r12, %rcx
movq 0x110(%rsp), %r8
callq 0x8091
movl 0x14(%r14), %esi
addl %ebp, %esi
movl 0x18(%r14), %edx
addl %ebx, %edx
movq 0x118(%rsp), %r15
movq %r15, %rdi
movl 0x120(%rsp), %ecx
callq 0x4f9a
movq 0x140(%rsp), %r8
movl %eax, (%r8)
testl %eax, %eax
movq 0x128(%rsp), %rsi
js 0xa519
movq 0x138(%rsp), %rax
movq 0x130(%rsp), %rdx
movl (%rsi), %ecx
movl %ecx, (%rax)
movslq (%r8), %rax
imulq $0x38, %rax, %rax
addq %rax, %r15
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movaps %xmm3, 0xb0(%rsp)
movaps %xmm2, 0xa0(%rsp)
movaps %xmm1, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movups 0x30(%r12), %xmm3
movups %xmm3, 0x70(%rsp)
movups %xmm2, 0x60(%rsp)
movups %xmm1, 0x50(%rsp)
movups %xmm0, 0x40(%rsp)
movaps 0x80(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
movaps 0xa0(%rsp), %xmm2
movaps 0xb0(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
callq 0xa5e6
jmp 0xa50b
movq 0x100(%rsp), %rsi
shlq $0x6, %rax
movl 0x24(%rsi,%rax), %eax
xorl %r13d, %r13d
cmpl $0x3, %eax
je 0xa558
cmpl $0x2, %eax
jne 0xa519
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movaps %xmm3, 0xb0(%rsp)
movaps %xmm2, 0xa0(%rsp)
movaps %xmm1, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps 0x80(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
movaps 0xa0(%rsp), %xmm2
movaps 0xb0(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rcx, 0x40(%rsp)
movsbl %r15b, %ecx
movq %r10, %rdi
movq %r12, %rsi
callq 0xa8e1
movl %eax, %r13d
movq 0x148(%rsp), %rax
movl %r13d, (%rax)
addl 0x14(%r14), %ebp
addl 0x18(%r14), %ebx
movq 0x150(%rsp), %rdi
movl %ebp, %esi
movl %ebx, %edx
movl 0x158(%rsp), %ecx
callq 0xacc8
movq 0x160(%rsp), %rcx
movl %eax, (%rcx)
movl %r13d, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%r11), %eax
testl %eax, %eax
jle 0xa519
decl %eax
movl %eax, (%r11)
movq %rcx, %rdi
movq %r10, %r12
callq 0xbfdd
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movaps %xmm3, 0xb0(%rsp)
movaps %xmm2, 0xa0(%rsp)
movaps %xmm1, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps 0x80(%rsp), %xmm0
movaps 0x90(%rsp), %xmm1
movaps 0xa0(%rsp), %xmm2
movaps 0xb0(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movsbl %r15b, %esi
movq %r12, %rdi
callq 0xabff
jmp 0xa519