// File: /workspace/github_c_makefile_star2_O0/j4r0g[P]Projet_Labyrinthe/fonctions/insecte.c
// Function: gene_ins
int gene_ins(int bouffe, int dureevie, t_lab lab[X][Y], int a, int b, t_fourmi fourmi[], int choixsexe) {
	srand(time(NULL));
  if(a<=0 || a>=X || b<=0 || b>=Y || lab[a][b].etat!=vide)
    return 1;
	else if(nb_ins>Z){
		printf("\nNombre maximum d'insecte atteint\n");
	}
  else {
    lab[a][b].etat=insecte;
  	lab[a][b].insecte=nb_ins;
		nb_ins++;
		int indice=lab[a][b].insecte;
		//Si on veut un choix aléatoire du sexe
		if(choixsexe==0) {
			int sexe=rand()%100;
	  	if(sexe<50)
	  		fourmi[indice].sexe = MALE;
	  	else
	  		fourmi[indice].sexe = FEMELLE;
		}
		// Si on veut un male
		else if(choixsexe==1) {
			fourmi[indice].sexe = MALE;
		}
		// Si on veut une femelle
		else {
			fourmi[indice].sexe = FEMELLE;
		}

  	fourmi[indice].nourriture = bouffe;
  	fourmi[indice].age = dureevie;
		fourmi[indice].x=a;
		fourmi[indice].y=b;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl 0x10(%rbp), %eax
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x10e0
movl %eax, %edi
callq 0x10a0
cmpl $0x0, -0x1c(%rbp)
jle 0x462b
cmpl $0x1e, -0x1c(%rbp)
jge 0x462b
cmpl $0x0, -0x20(%rbp)
jle 0x462b
cmpl $0x3c, -0x20(%rbp)
jge 0x462b
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x2d0, %rcx, %rcx      # imm = 0x2D0
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
cmpl $0x20, 0x4(%rax)
je 0x4637
movl $0x1, -0x4(%rbp)
jmp 0x47aa
cmpl $0x28, 0xf222(%rip)     # 0x13860
jle 0x4653
leaq 0x5102(%rip), %rdi      # 0x9749
movb $0x0, %al
callq 0x1080
jmp 0x47a1
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x2d0, %rcx, %rcx      # imm = 0x2D0
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl $0x25, 0x4(%rax)
movl 0xf1e3(%rip), %ecx      # 0x13860
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rdx
imulq $0x2d0, %rdx, %rdx      # imm = 0x2D0
addq %rdx, %rax
movslq -0x20(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl 0xf1bd(%rip), %eax      # 0x13860
addl $0x1, %eax
movl %eax, 0xf1b4(%rip)      # 0x13860
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x2d0, %rcx, %rcx      # imm = 0x2D0
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, 0x10(%rbp)
jne 0x4719
callq 0x1150
movl $0x64, %ecx
cltd
idivl %ecx
movl %edx, -0x30(%rbp)
cmpl $0x32, -0x30(%rbp)
jge 0x4702
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl $0x0, (%rax)
jmp 0x4717
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl $0x1, (%rax)
jmp 0x474d
cmpl $0x1, 0x10(%rbp)
jne 0x4736
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl $0x0, (%rax)
jmp 0x474b
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl $0x1, (%rax)
jmp 0x474d
movl -0x8(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0xc(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movl -0x20(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
jmp 0x47a3
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)