// File: /workspace/github_c_makefile_star2_O1/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 0xb856
movl %edi, %r15d
movslq 0x2c(%r12), %rax
cmpq $0x9, %rax
ja 0xb9d0
movl $0x236, %edi            # imm = 0x236
btl %eax, %edi
jae 0xb9d0
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 0xbc2f
movl %eax, %r13d
movl %eax, (%r15)
jmp 0xba7d
movq %r10, %r15
callq 0x11d0
cltq
imulq $0x51eb851f, %rax, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rcx
addl %edx, %ecx
imull $0x64, %ecx, %ecx
subl %ecx, %eax
xorl %r13d, %r13d
cmpl 0x14(%r12), %eax
jg 0xba7d
movslq 0x14(%r14), %rax
movslq %ebp, %rsi
addq %rax, %rsi
movslq 0x18(%r14), %rax
movslq %ebx, %rdx
addq %rax, %rdx
leaq (%rdx,%rdx,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdx, %rax
imulq $0xe38, %rsi, %rcx      # imm = 0xE38
addq %r15, %rcx
cmpl $0x2, (%rcx,%rax)
jne 0xb8d6
cmpl $0x3, 0x2c(%r12)
jne 0xb8c3
addl $-0x2, 0x10(%r14)
movq %r15, %rdi
movq %r12, %rcx
movq 0x110(%rsp), %r8
callq 0x91e2
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 0x57a3
movq 0x140(%rsp), %r8
movl %eax, (%r8)
testl %eax, %eax
movq 0x128(%rsp), %rsi
js 0xba7d
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 0xbb4a
jmp 0xba6f
movq 0x100(%rsp), %rsi
shlq $0x6, %rax
movl 0x24(%rsi,%rax), %eax
xorl %r13d, %r13d
cmpl $0x3, %eax
je 0xbabc
cmpl $0x2, %eax
jne 0xba7d
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 0xbea8
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 0xc2b8
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 0xba7d
decl %eax
movl %eax, (%r11)
movq %rcx, %rdi
movq %r10, %r12
callq 0xd8c8
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 0xc19b
jmp 0xba7d