// File: /workspace/github_c_makefile_star2_O2/j4r0g[P]Projet_Labyrinthe/fonctions/deplacement.c
// Function: prochain_deplacement
int prochain_deplacement (int pos_x, int pos_y, t_lab lab[X][Y], int bouffe, int dureevie, t_fourmi fourmi[]) {
	printf("prochian_deplacement\n");
	int ins_adj = insecte_adjacent(pos_x, pos_y, lab, bouffe, dureevie, fourmi);
	int depl=0;
	time_t t;
	srand((unsigned) time(&t));
	int random = rand()%100;
	if (lab[pos_x-1][pos_y].etat != mur || lab[pos_x][pos_y-1].etat != mur || lab[pos_x][pos_y+1].etat != mur || (lab[pos_x+1][pos_y].etat != mur && ins_adj==0)) {
		while(depl==0) {
			if (random >= 0 && random < 25 && lab[pos_x-1][pos_y].etat!=mur && lab[pos_x-1][pos_y].etat!=insecte) {
				modif_pos(lab, fourmi, pos_x, pos_y, pos_x-1, pos_y, bouffe, dureevie);
				depl=1;
			}
			else if (random >= 25 && random < 50 && lab[pos_x][pos_y-1].etat!=mur && lab[pos_x][pos_y-1].etat!=insecte) {
				modif_pos(lab, fourmi, pos_x, pos_y, pos_x, pos_y-1, bouffe, dureevie);
				depl=1;
			}
			else if (random >= 50 && random < 75 && lab[pos_x][pos_y+1].etat!=mur && lab[pos_x][pos_y+1].etat!=insecte) {
				modif_pos(lab, fourmi, pos_x, pos_y, pos_x, pos_y+1, bouffe, dureevie);
				depl=1;
			}
			else if (random >= 75 && random < 100 && lab[pos_x+1][pos_y].etat!=mur && lab[pos_x+1][pos_y].etat!=insecte) {
				modif_pos(lab, fourmi, pos_x, pos_y, pos_x+1, pos_y, bouffe, dureevie);
				depl=1;
			}
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r14
movl %r8d, %ebx
movl %ecx, %r13d
movq %rdx, %rbp
movl %esi, %r15d
movl %edi, %r12d
leaq 0x3128(%rip), %rdi      # 0x5721
callq 0x1070
movl %r12d, %edi
movl %r15d, %esi
movq %rbp, %rdx
movl %r13d, %ecx
movq %rbx, 0x10(%rsp)
movl %ebx, %r8d
movq %r14, 0x8(%rsp)
movq %r14, %r9
callq 0x2547
movl %eax, (%rsp)
leaq 0x20(%rsp), %rdi
callq 0x1100
movl %eax, %edi
callq 0x10d0
callq 0x1170
pushq $0x64
popq %rcx
cltd
idivl %ecx
leal -0x1(%r12), %edi
movslq %edi, %rax
movslq %r15d, %r9
imulq $0x2d0, %rax, %rax      # imm = 0x2D0
addq %rbp, %rax
imulq $0xc, %r9, %r10
decl %r9d
cmpl $0x23, 0x4(%r10,%rax)
movslq %r12d, %rbx
movslq %r9d, %r14
jne 0x26a8
imulq $0x2d0, %rbx, %rcx      # imm = 0x2D0
addq %rbp, %rcx
imulq $0xc, %r14, %rsi
cmpl $0x23, 0x4(%rsi,%rcx)
jne 0x26a8
leal 0x1(%r15), %esi
movslq %esi, %rsi
imulq $0xc, %rsi, %rsi
cmpl $0x23, 0x4(%rsi,%rcx)
jne 0x26a8
cmpl $0x23, 0x2d4(%r10,%rcx)
je 0x27b3
cmpl $0x0, (%rsp)
jne 0x27b3
movl %edi, 0x1c(%rsp)
movq %r13, (%rsp)
leaq (%r10,%rax), %rcx
addq $0x4, %rcx
leal -0x19(%rdx), %esi
leal -0x32(%rdx), %edi
leal 0x1(%rbx), %r8d
movslq %r8d, %r11
imulq $0x2d0, %r11, %r11      # imm = 0x2D0
addq %rbp, %r11
addq %r10, %r11
addq $0x4, %r11
leal 0x1(%r15), %r10d
movslq %r10d, %r13
imulq $0x2d0, %rbx, %rax      # imm = 0x2D0
addq %rbp, %rax
imulq $0xc, %r13, %rbx
addq %rax, %rbx
addq $0x4, %rbx
imulq $0xc, %r14, %r14
addq %rax, %r14
addq $0x4, %r14
cmpl $0x18, %edx
ja 0x2713
movl (%rcx), %r13d
cmpl $0x23, %r13d
je 0x26fd
cmpl $0x25, %r13d
je 0x26fd
jmp 0x2763
cmpl $0x18, %esi
ja 0x2729
movl (%r14), %r13d
cmpl $0x23, %r13d
je 0x26fd
cmpl $0x25, %r13d
je 0x26fd
jmp 0x277b
cmpl $0x18, %edi
ja 0x273f
movl (%rbx), %r13d
cmpl $0x23, %r13d
je 0x26fd
cmpl $0x25, %r13d
je 0x26fd
jmp 0x278e
cmpl $0x4b, %edx
jl 0x26fd
movl (%r11), %r13d
cmpl $0x23, %r13d
je 0x26fd
cmpl $0x25, %r13d
je 0x26fd
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl %r12d, %edx
movl %r15d, %ecx
jmp 0x2776
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl 0x1c(%rsp), %r8d
movl %r15d, %r9d
jmp 0x27a2
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl %r12d, %r8d
jmp 0x27a2
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl %r12d, %r8d
movl %r10d, %r9d
pushq 0x10(%rsp)
pushq 0x8(%rsp)
callq 0x31ea
addq $0x10, %rsp
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq