// File: /workspace/github_c_makefile_star2_O2/j4r0g[P]Projet_Labyrinthe/fonctions/labyrinthe.c
// Function: afficher_lab
void afficher_lab(t_lab lab[X][Y], t_fourmi fourmi[]){
	int char_unseen = '?';
	int indice;
	t_etat etat_tmp;
	t_discover decouvert_tmp;
	int i,j;

	printf("\n\n");
	for(i =-1; i<(X+1); i++){					//*Toute la partie qui suit gère l'affichage des bordures (avec les espacements	*//
		for(j =-1; j<(Y+1); j++){					//*particuliers pour que tout soit aligné)
			if(i == -1 && j != -1 ){							//*nombres de l'axe horizontal du haut
				if(j==0){										//*affichage du "Y" sur l'axe horizontal
					printf("\033[1;33;40m Y\033[00m");
				}
				else if(j == 58){
					printf("\033[1;33;40m Y\033[00m");
				}
				if((j%2)!=0){
					if(j == 9){
						printf("%i ", j);
					}
					else if(j < 10 ){
						printf("%i ", j);
					}
					else if(j == (Y-1) && i == -1){
					printf(" ");
					}
					else{
						printf("%i", j);
					}
				}
				else{
					printf("  ");
				}
			}
			else if(i == (X) && j!= -1 ){						//*nombres de l'axe horizontal du bas
				if((j%2)==0){
					if(j == 0){
						printf("\033[1;33;40m  Y  \033[00m");
					}
					else if( j == 60){
						printf(" ");
					}
					else if(j < 10 ){
						printf(" %i  ", j);
					}
					else if(j == (Y-1) && i == -1){
						printf(" ");
					}
					else{
						printf(" %i ", j);
					}
				}

				else if(j == 59){
					printf("\033[1;33;40mY \033[00m");
				}
			}
			else if(j == -1 && i != -1 && i != X){				//*nombres de l'axe vertical, a gauche
				if(i == 0){									//*affichage du "X" sur l'axe vertical
					printf("\033[1;33;40m X \033[00m");
				}
				else if(i == 29){									//*affichage du "X" sur l'axe vertical
					printf("\033[1;33;40m X \033[00m");
				}
				else if(i < 10 ){
					printf(" %i ", i);
				}
				else if(j == -1 && i == (X-1)){
				printf("   ");
				}
				else{
					printf("%i ", i);
				}
			}
			else if(j == Y && i != -1 && i != X){				//*nombres de l'axe vertical, a droite
				if(i == 0){
					printf("\033[1;33;40m X \033[00m");
				}
				else if(i ==29){
					printf("\033[1;33;40m X \033[00m");
				}
				else if(i < 10 ){
					printf(" %i ", i);
				}
				else if(j == -1 && i == (X-1) && i == (X)){
				printf("  ");
				}
				else{
					printf(" %i ", i);
				}
			}
			else if(j == -1 && i == -1){						//*coin supérieur gauche
				printf("  ");
			}
			else if(j == -1 && i == (X)){						//*pas de nombre en bas a gauche
				printf(" ");
			}
			else if(j == -1 && i == (X)){						//*pas de nombre en bas a gauche
				printf(" ");
			}
			else{									//*le else gère tout ce qui est a l'intérieur des bordures (insectes, nourriture)
				etat_tmp = lab[i][j].etat;
				decouvert_tmp = lab[i][j].decouvert;

				if(decouvert_tmp == 0){
				printf("\033[0;30;40m%c \033[00m", char_unseen);
				}
				else{
					if(etat_tmp == vide){
						printf("\033[0;33;43m%c \033[00m", etat_tmp);
					}
					else if(etat_tmp == mur){
						printf("\033[0;37;47m%c \033[00m", etat_tmp);
					}
					else if(etat_tmp == insecte){
						indice = lab[i][j].insecte;
						if(fourmi[indice].age <= 1 || fourmi[indice].nourriture <= 1){
							printf("\033[1;30;43m%c \033[00m", etat_tmp);
						}
						else if(fourmi[indice].age < 5 ){
							printf("\033[1;31;43m%c \033[00m", etat_tmp);
						}
						else if(fourmi[indice].nourriture < 5){
							printf("\033[1;32;43m%c \033[00m", etat_tmp);
						}
						else{
							printf("\033[1;36;43m%c \033[00m", etat_tmp);
						}
					}
					else if(etat_tmp == food){
						printf("\033[1;34;43m%c \033[00m", etat_tmp);
					}
					else{
						printf("%c ", etat_tmp);
					}
				}
			}


		}
		printf("\n");
	}
	printf("\n\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, (%rsp)
movq %rdi, %rbx
leaq 0x3b58(%rip), %rdi      # 0x528b
callq 0x1070
addq $-0x2d4, %rbx           # imm = 0xFD2C
pushq $-0x1
popq %r15
leaq 0x3981(%rip), %r12      # 0x50cb
leaq 0x39a4(%rip), %r13      # 0x50f5
cmpq $0x1f, %r15
je 0x19a5
movq %rbx, %r14
xorl %ebp, %ebp
cmpq $0x3e, %rbp
je 0x198e
leaq -0x1(%rbp), %rsi
cmpq $-0x1, %r15
setne %al
testq %rbp, %rbp
sete %cl
orb %al, %cl
jne 0x17a1
testl %esi, %esi
je 0x1788
cmpl $0x3a, %esi
jne 0x17f9
movq %r12, %rdi
xorl %eax, %eax
callq 0x10a0
movq %r13, %rdi
xorl %eax, %eax
callq 0x10a0
jmp 0x1954
testq %rbp, %rbp
sete %al
cmpq $0x1e, %r15
setne %cl
orb %al, %cl
jne 0x17d2
testb $0x1, %sil
jne 0x1817
cmpl $0x3c, %esi
je 0x186f
testl %esi, %esi
jne 0x18b1
leaq 0x390d(%rip), %rdi      # 0x50dd
jmp 0x1795
testq %rbp, %rbp
je 0x182d
cmpq $0x3d, %rbp
jne 0x1854
cmpl $-0x1, %r15d
je 0x1854
cmpl $0x1e, %r15d
je 0x1854
cmpl $0x1d, %r15d
je 0x1848
testl %r15d, %r15d
je 0x1848
jmp 0x18ed
testb $0x1, %sil
je 0x1792
cmpq $0xa, %rbp
jne 0x18c0
leaq 0x38e9(%rip), %rdi      # 0x50f9
pushq $0x9
jmp 0x194c
cmpq $0x3c, %rbp
jne 0x1954
leaq 0x38d5(%rip), %rdi      # 0x50fd
jmp 0x1795
cmpl $-0x1, %r15d
je 0x1854
cmpl $0x1e, %r15d
je 0x1854
cmpl $0x1d, %r15d
je 0x1848
testl %r15d, %r15d
jne 0x18e7
leaq 0x38c0(%rip), %rdi      # 0x510f
jmp 0x1795
leal -0x1(%rbp), %eax
andl %r15d, %eax
cmpl $-0x1, %eax
je 0x1792
movq %r15, %rax
xorq $0x1e, %rax
orq %rbp, %rax
jne 0x187c
pushq $0x20
popq %rdi
callq 0x1040
jmp 0x1954
cmpl $0x0, -0x8(%r14)
je 0x18f6
movl -0x4(%r14), %esi
cmpl $0x2a, %esi
je 0x1943
cmpl $0x23, %esi
je 0x190d
cmpl $0x25, %esi
je 0x1918
cmpl $0x20, %esi
jne 0x1960
leaq 0x388b(%rip), %rdi      # 0x5135
pushq $0x20
jmp 0x194c
cmpq $0x9, %rsi
jg 0x18cf
leaq 0x3834(%rip), %rdi      # 0x50f2
jmp 0x18e5
cmpq $0x9, %rsi
jg 0x18d8
leaq 0x382c(%rip), %rdi      # 0x50f9
jmp 0x18e5
leaq 0x3822(%rip), %rdi      # 0x50f8
jmp 0x18e5
cmpq $0x3c, %rbp
je 0x186f
leaq 0x3cbe(%rip), %rdi      # 0x55a3
jmp 0x194d
cmpq $0x9, %r15
jg 0x1901
leaq 0x3804(%rip), %rdi      # 0x50f8
jmp 0x1908
leaq 0x3825(%rip), %rdi      # 0x5122
pushq $0x3f
jmp 0x194c
leaq 0x37f1(%rip), %rdi      # 0x50f9
movl %r15d, %esi
jmp 0x194d
leaq 0x3834(%rip), %rdi      # 0x5148
pushq $0x23
jmp 0x194c
movslq (%r14), %rax
imulq $0x14, %rax, %rcx
movq (%rsp), %rax
movl 0x8(%rax,%rcx), %eax
cmpl $0x2, %eax
jl 0x1938
addq (%rsp), %rcx
movl 0x4(%rcx), %ecx
cmpl $0x1, %ecx
jg 0x1969
leaq 0x381c(%rip), %rdi      # 0x515b
pushq $0x25
jmp 0x194c
leaq 0x385d(%rip), %rdi      # 0x51a7
pushq $0x2a
popq %rsi
xorl %eax, %eax
callq 0x10a0
incq %rbp
addq $0xc, %r14
jmp 0x1760
leaq 0x3853(%rip), %rdi      # 0x51ba
jmp 0x194d
cmpl $0x4, %eax
ja 0x1977
leaq 0x37f9(%rip), %rdi      # 0x516e
jmp 0x193f
cmpl $0x4, %ecx
ja 0x1985
leaq 0x37fe(%rip), %rdi      # 0x5181
jmp 0x193f
leaq 0x3808(%rip), %rdi      # 0x5194
jmp 0x193f
pushq $0xa
popq %rdi
callq 0x1040
incq %r15
addq $0x2d0, %rbx            # imm = 0x2D0
jmp 0x1751
leaq 0x38df(%rip), %rdi      # 0x528b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1070