// File: /workspace/github_c_makefile_star2_O3/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 $0x98, %rsp
movq %r9, %r13
movq %r8, %r14
movl %edx, %ebx
movl %esi, %ebp
movl %edi, %r15d
movq 0xf8(%rsp), %r9
movl 0xf0(%rsp), %r8d
movq 0xe8(%rsp), %rdx
movq 0xe0(%rsp), %r10
movq 0xd8(%rsp), %rdi
cmpl $0x0, 0x24(%r13)
je 0xb934
movslq 0x2c(%r13), %rax
cmpq $0x9, %rax
ja 0xba67
movl $0x236, %esi            # imm = 0x236
btl %eax, %esi
jae 0xba67
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movaps %xmm3, 0x80(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps 0x50(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
movaps 0x70(%rsp), %xmm2
movaps 0x80(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movsbl %r15b, %ecx
movq %r13, %rsi
callq 0xbd5b
movl %eax, %r12d
movq 0x118(%rsp), %rax
movl %r12d, (%rax)
jmp 0xbb94
movq %rdi, %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 %r12d, %r12d
cmpl 0x14(%r13), %eax
jg 0xbb94
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 0xb9be
cmpl $0x3, 0x2c(%r13)
jne 0xb99f
addl $-0x2, 0x10(%r14)
movq %r15, %rdi
movq %r13, %rcx
movq 0xe0(%rsp), %r8
callq 0x929c
movl 0x14(%r14), %esi
addl %ebp, %esi
movl 0x18(%r14), %edx
addl %ebx, %edx
movq 0xe8(%rsp), %r15
movq %r15, %rdi
movl 0xf0(%rsp), %ecx
callq 0x5820
movq 0x110(%rsp), %rsi
movl %eax, (%rsi)
testl %eax, %eax
movq 0xf8(%rsp), %rcx
js 0xbb94
movq %r15, %rdx
movq 0x108(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, (%rax)
movslq (%rsi), %rax
imulq $0x38, %rax, %rax
addq %rax, %rdx
movl 0x20(%r14), %eax
movl %eax, 0x4c(%rsp)
movl 0x28(%r14), %r12d
movl 0x10(%r13), %r15d
movl 0x24(%r13), %eax
movl %eax, 0x48(%rsp)
movq %rdx, %r13
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
movl $0x64, %ecx
subl %r12d, %ecx
cmpl %ecx, %eax
jge 0xbaf6
cmpl $0x0, 0x48(%rsp)
je 0xbbd3
movl 0x8(%r13), %eax
jmp 0xbbf4
movq 0xd0(%rsp), %rsi
shlq $0x6, %rax
movl 0x24(%rsi,%rax), %eax
xorl %r12d, %r12d
cmpl $0x3, %eax
je 0xbb1d
cmpl $0x2, %eax
jne 0xbb94
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movaps %xmm3, 0x80(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps 0x50(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
movaps 0x70(%rsp), %xmm2
movaps 0x80(%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 %r13, %rsi
callq 0xbfc3
jmp 0xb921
movl %r12d, %eax
shrl $0x1f, %eax
addl %r12d, %eax
sarl %eax
negl %eax
imull %eax, %r15d
addl 0x8(%r13), %r15d
movl %r15d, 0x8(%r13)
movl $0x2, %r12d
movl %r15d, %eax
jmp 0xbbf7
movl (%r10), %eax
testl %eax, %eax
jle 0xbb94
decl %eax
movl %eax, (%r10)
movq %rdi, %r13
movq %rcx, %rdi
callq 0xd9cd
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movaps %xmm3, 0x80(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps 0x50(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
movaps 0x70(%rsp), %xmm2
movaps 0x80(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movsbl %r15b, %esi
movq %r13, %rdi
callq 0xc2bd
addl 0x14(%r14), %ebp
addl 0x18(%r14), %ebx
movq 0x120(%rsp), %rdi
movl %ebp, %esi
movl %ebx, %edx
movl 0x128(%rsp), %ecx
callq 0xc3dc
movq 0x130(%rsp), %rcx
movl %eax, (%rcx)
movl %r12d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4c(%rsp), %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
addl %eax, %r15d
movl %r15d, %eax
negl %eax
cmovnsl %r15d, %eax
addl 0x8(%r13), %eax
movl %eax, 0x8(%r13)
xorl %r12d, %r12d
testl %eax, %eax
jg 0xb924
movl 0x20(%r13), %eax
movl $0xa, %r13d
movl $0x1, %r12d
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jb 0xbc35
cmpl $0x1, %eax
je 0xbc47
cmpl $0x2, %eax
jne 0xb924
movl $0x7, 0x48(%rsp)
movl $0xf, %r13d
jmp 0xbc4f
movl $0x5, 0x48(%rsp)
movq 0x100(%rsp), %r15
jmp 0xbc57
movl $0x5, 0x48(%rsp)
movq 0xf8(%rsp), %r15
callq 0x11d0
cltd
idivl %r13d
addl 0x48(%rsp), %edx
addl %edx, (%r15)
jmp 0xb924