// File: /workspace/github_c_makefile_star2_O0/S01den[P]Lost_CavernRL/player.c
// Function: burn
int burn(Map map[LONGUEUR][LARGEUR],Weapons *weaponHold,Ennemy ennemies[], char dir, Player player, int nbrEnnemies, int *components,WINDOW *screen)
{
	int ret = 0;
	int x, y = 0;
	int posX = player.x;
	int posY = player.y;

	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 animationDelay = 0;
	int noGem = 0; // you must pick a gem with contact weapons

	posX += x;
	posY += y;

	while(hit == 0 && turn < weaponHold->range)
	{
		animationDelay = 0;

		wattron(screen,COLOR_PAIR(203));
		mvwprintw(screen,posX+1,posY+1,"o");
		wattroff(screen,COLOR_PAIR(203));
		mvwprintw(screen,posX+1-x,posY+1-y,".");
		wrefresh(screen);
		while(animationDelay < 30000000)
		{
			animationDelay++;
		}

		if(map[posX][posY].typeEnnemy > 0)
		{
			int ennemySeenIndice = testEnnemyOnPos(ennemies,posX,posY,nbrEnnemies);
			if(ennemySeenIndice >= 0)
			{
				ennemies[ennemySeenIndice].life -= weaponHold->degat;

				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;
		}
	}

	int i, j = 0;
	for(i = posX-4; i < posX+4; i++)
	{
		for(j = posY-4; j < posY+4; j++)
		{
			if(rand()%4 < 3)
				map[i][j].effect = 1;
		}
	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x50(%rbp), %rax
leaq 0x10(%rbp), %rax
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, -0x2c(%rbp)
movl $0x0, -0x34(%rbp)
movl 0x14(%rax), %ecx
movl %ecx, -0x38(%rbp)
movl 0x18(%rax), %eax
movl %eax, -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, -0x68(%rbp)
subl $0x19, %eax
ja 0x13475
movq -0x68(%rbp), %rax
leaq 0x6c5a(%rip), %rcx      # 0x1a048
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x34(%rbp)
jmp 0x13475
movl $0x1, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
jmp 0x13475
movl $0x0, -0x30(%rbp)
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
jmp 0x13475
movl $0x0, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
jmp 0x13475
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
jmp 0x13475
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x34(%rbp)
jmp 0x13475
movl $0x1, -0x30(%rbp)
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
jmp 0x13475
movl $0x1, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x30(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x40(%rbp)
movb %al, -0x69(%rbp)
jne 0x134be
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 0x134ca
jmp 0x136ad
movl $0x0, -0x48(%rbp)
movq 0x50(%rbp), %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %eax, %eax
movl %eax, %edx
callq 0x21d0
movq 0x50(%rbp), %rdi
movl -0x38(%rbp), %esi
addl $0x1, %esi
movl -0x3c(%rbp), %edx
addl $0x1, %edx
leaq 0x4b68(%rip), %rcx      # 0x18062
movb $0x0, %al
callq 0x2070
movq 0x50(%rbp), %rdi
movl $0xcb00, %esi           # imm = 0xCB00
xorl %eax, %eax
movl %eax, %edx
callq 0x2060
movq 0x50(%rbp), %rdi
movl -0x38(%rbp), %esi
addl $0x1, %esi
subl -0x30(%rbp), %esi
movl -0x3c(%rbp), %edx
addl $0x1, %edx
subl -0x34(%rbp), %edx
leaq 0x54c2(%rip), %rcx      # 0x189f2
movb $0x0, %al
callq 0x2070
movq 0x50(%rbp), %rdi
callq 0x2100
cmpl $0x1c9c380, -0x48(%rbp) # imm = 0x1C9C380
jge 0x13554
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x13540
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0xe38, %rcx, %rcx      # imm = 0xE38
addq %rcx, %rax
movslq -0x3c(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jle 0x13649
movq -0x18(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movl -0x20(%rbp), %ecx
callq 0x8a10
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
jl 0x13647
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x18(%rbp), %rax
movslq -0x50(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movslq -0x50(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x8(%rax)
jg 0x13640
movl $0x1, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x50(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, 0x20(%rax)
jne 0x13609
callq 0x21e0
movl $0xa, %ecx
cltd
idivl %ecx
addl $0x5, %edx
movl %edx, -0x54(%rbp)
movl -0x54(%rbp), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x1363e
movq -0x18(%rbp), %rax
movslq -0x50(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, 0x20(%rax)
jne 0x1363c
callq 0x21e0
movl $0xf, %ecx
cltd
idivl %ecx
addl $0x7, %edx
movl %edx, -0x58(%rbp)
movl -0x58(%rbp), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x1363e
jmp 0x13640
movl $0x1, -0x40(%rbp)
jmp 0x136a8
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0xe38, %rcx, %rcx      # imm = 0xE38
addq %rcx, %rax
movslq -0x3c(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x1368b
movq -0x8(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movq -0x10(%rbp), %rcx
leaq -0x4c(%rbp), %r8
callq 0xf750
movl $0x1, -0x40(%rbp)
jmp 0x136a6
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x30(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x136a8
jmp 0x134a3
movl $0x0, -0x60(%rbp)
movl -0x38(%rbp), %eax
subl $0x4, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl -0x38(%rbp), %ecx
addl $0x4, %ecx
cmpl %ecx, %eax
jge 0x13730
movl -0x3c(%rbp), %eax
subl $0x4, %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl -0x3c(%rbp), %ecx
addl $0x4, %ecx
cmpl %ecx, %eax
jge 0x13723
callq 0x21e0
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x3, %edx
jge 0x13716
movq -0x8(%rbp), %rax
movslq -0x5c(%rbp), %rcx
imulq $0xe38, %rcx, %rcx      # imm = 0xE38
addq %rcx, %rax
movslq -0x60(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x4(%rax)
jmp 0x13718
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x136d3
jmp 0x13725
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x136bd
movl -0x2c(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)