// File: /workspace/github_c_makefile_star2_O3/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 0x4025(%rip), %rdi      # 0x6754
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 0x2679
movl %eax, %ebx
leaq 0x20(%rsp), %rdi
callq 0x1100
movl %eax, %edi
callq 0x10d0
callq 0x1170
leal -0x1(%r12), %edi
movslq %edi, %rcx
movslq %r15d, %r9
imulq $0x2d0, %rcx, %rdx      # imm = 0x2D0
addq %rbp, %rdx
leaq (%r9,%r9,2), %r10
decl %r9d
cmpl $0x23, 0x4(%rdx,%r10,4)
movslq %r12d, %r14
movslq %r9d, %rcx
leaq (%rcx,%rcx,2), %r11
jne 0x27d6
imulq $0x2d0, %r14, %rcx      # imm = 0x2D0
addq %rbp, %rcx
cmpl $0x23, 0x4(%rcx,%r11,4)
jne 0x27d6
leal 0x1(%r15), %esi
movslq %esi, %rsi
leaq (%rsi,%rsi,2), %rsi
cmpl $0x23, 0x4(%rcx,%rsi,4)
jne 0x27d6
cmpl $0x23, 0x2d4(%rcx,%r10,4)
je 0x2903
testl %ebx, %ebx
jne 0x2903
movl %edi, 0x1c(%rsp)
movq %r13, (%rsp)
movslq %eax, %rcx
imulq $0x51eb851f, %rcx, %rax # imm = 0x51EB851F
movq %rax, %rsi
shrq $0x3f, %rsi
sarq $0x25, %rax
addl %esi, %eax
imull $0x64, %eax, %eax
subl %eax, %ecx
leaq (%rdx,%r10,4), %rdx
addq $0x4, %rdx
leal -0x19(%rcx), %esi
leal -0x32(%rcx), %edi
leal 0x1(%r14), %r8d
movslq %r8d, %rbx
imulq $0x2d0, %rbx, %rbx      # imm = 0x2D0
addq %rbp, %rbx
leaq (%rbx,%r10,4), %rbx
addq $0x4, %rbx
leal 0x1(%r15), %r10d
movslq %r10d, %r13
imulq $0x2d0, %r14, %rax      # imm = 0x2D0
addq %rbp, %rax
leaq (,%r13,2), %r14
addq %r13, %r14
leaq (%rax,%r14,4), %r14
addq $0x4, %r14
leaq (%rax,%r11,4), %r11
addq $0x4, %r11
cmpl $0x18, %ecx
ja 0x2863
movl (%rdx), %r13d
cmpl $0x23, %r13d
je 0x284d
cmpl $0x25, %r13d
je 0x284d
jmp 0x28b3
cmpl $0x18, %esi
ja 0x2879
movl (%r11), %r13d
cmpl $0x23, %r13d
je 0x284d
cmpl $0x25, %r13d
je 0x284d
jmp 0x28cb
cmpl $0x18, %edi
ja 0x288f
movl (%r14), %r13d
cmpl $0x23, %r13d
je 0x284d
cmpl $0x25, %r13d
je 0x284d
jmp 0x28de
cmpl $0x4b, %ecx
jl 0x284d
movl (%rbx), %r13d
cmpl $0x23, %r13d
je 0x284d
cmpl $0x25, %r13d
je 0x284d
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl %r12d, %edx
movl %r15d, %ecx
jmp 0x28c6
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl 0x1c(%rsp), %r8d
movl %r15d, %r9d
jmp 0x28f2
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl %r12d, %r8d
jmp 0x28f2
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 0x349e
addq $0x10, %rsp
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq