// File: /workspace/github_c_makefile_star2_O0/Astor-Bizard[P]ProjetS5_Groupe2/src/lectureST.c
// Function: lectureSymbolTab
ListeSymboles lectureSymbolTab(FILE *f, Elf32_Ehdr elfHeader, SectionsHeadersList shList, int silent)
{
	uint32_t sectionSymbolTabSize;
	uint32_t sectionSymbolTabOffset;
	int i = 0;
	int j = 0;
	ListeSymboles listeSymboles;

	char* nomSection = getSectionNameBis(shList.names, shList.headers[i]);
	while(i<shList.size && strcmp(nomSection, ".symtab"))
	{
		free(nomSection);
		i++;
		nomSection = getSectionNameBis(shList.names, shList.headers[i]);
	}
	if(i==shList.size){
		listeSymboles.symboles=NULL;
		listeSymboles.names=NULL;
		listeSymboles.nbSymboles=0;
		printf("Pas de table de symboles\n");
		return listeSymboles;
	}
	free(nomSection);
	sectionSymbolTabSize = shList.headers[i].sh_size;
	sectionSymbolTabOffset = shList.headers[i].sh_offset;

	listeSymboles.symboles = (Elf32_Sym*) malloc(sizeof(Elf32_Sym)*(sectionSymbolTabSize/16));
	if(listeSymboles.symboles == NULL)
	{
		printf("Erreur d'allocation\n");
		listeSymboles.symboles = NULL;
		listeSymboles.names = NULL;
		listeSymboles.nbSymboles = 0;
		return listeSymboles;
	}
	listeSymboles.names = fetchSymbolNames(f, shList, i);

	fseek(f, sectionSymbolTabOffset, SEEK_SET);
	for(i = 0; i<sectionSymbolTabSize; i=i+16)
	{
		listeSymboles.symboles[j].st_name = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		listeSymboles.symboles[j].st_value = (Elf32_Addr) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		listeSymboles.symboles[j].st_size = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		listeSymboles.symboles[j].st_info = (unsigned char) lire_octets(elfHeader.e_ident[EI_DATA], f, 1);
		listeSymboles.symboles[j].st_other = (unsigned char) lire_octets(elfHeader.e_ident[EI_DATA], f, 1);
		listeSymboles.symboles[j].st_shndx = (uint16_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 2);
		j++;
	}
	listeSymboles.nbSymboles = j;

	if (!silent)
		afficherTableSymboles(listeSymboles, elfHeader);

	return listeSymboles;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0xa0(%rbp)
movq %rdi, -0x98(%rbp)
leaq 0x48(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq 0x10(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq %rsi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x80(%rbp)
movq (%rax), %rsi
movslq -0x18(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
leaq -0x50(%rbp), %rdi
movl $0x28, %edx
callq 0x10b0
movq -0x80(%rbp), %rdi
movq -0x30(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x24f0
movq %rax, -0x28(%rbp)
movq -0x90(%rbp), %rdx
movl -0x18(%rbp), %ecx
xorl %eax, %eax
cmpl 0x10(%rdx), %ecx
movb %al, -0xa1(%rbp)
jge 0x3572
movq -0x28(%rbp), %rdi
leaq 0x28b3(%rip), %rsi      # 0x5e14
callq 0x1090
cmpl $0x0, %eax
setne %al
movb %al, -0xa1(%rbp)
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x357e
jmp 0x35ed
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x90(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x18(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0xb0(%rbp)
movq (%rax), %rsi
movslq -0x18(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
leaq -0x78(%rbp), %rdi
movl $0x28, %edx
callq 0x10b0
movq -0xb0(%rbp), %rdi
movq -0x58(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x78(%rbp), %xmm0
movups -0x68(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x24f0
movq %rax, -0x28(%rbp)
jmp 0x353f
movq -0x90(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x10(%rcx), %eax
jne 0x362c
movq -0xa0(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
leaq 0x27fc(%rip), %rdi      # 0x5e1c
movb $0x0, %al
callq 0x1070
jmp 0x38c8
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x90(%rbp), %rax
movq (%rax), %rcx
movslq -0x18(%rbp), %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl 0x14(%rcx), %ecx
movl %ecx, -0x10(%rbp)
movq (%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
shrl $0x4, %eax
movl %eax, %eax
movl %eax, %edi
shlq $0x4, %rdi
callq 0x10c0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, (%rax)
jne 0x36ba
leaq 0x27a5(%rip), %rdi      # 0x5e36
movb $0x0, %al
callq 0x1070
movq -0xa0(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
jmp 0x38c8
movq -0x90(%rbp), %rax
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x38e0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x10d0
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
jae 0x3872
movq -0x88(%rbp), %rax
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movsbl %al, %edi
callq 0x1880
movq -0xa0(%rbp), %rcx
movq %rax, %rdx
movq -0x88(%rbp), %rax
movq (%rcx), %rcx
movslq -0x1c(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rcx
movl %edx, (%rcx)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movsbl %al, %edi
callq 0x1880
movq -0xa0(%rbp), %rcx
movq %rax, %rdx
movq -0x88(%rbp), %rax
movq (%rcx), %rcx
movslq -0x1c(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rcx
movl %edx, 0x4(%rcx)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movsbl %al, %edi
callq 0x1880
movq -0xa0(%rbp), %rcx
movq %rax, %rdx
movq -0x88(%rbp), %rax
movq (%rcx), %rcx
movslq -0x1c(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rcx
movl %edx, 0x8(%rcx)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x1, %edx
movsbl %al, %edi
callq 0x1880
movq -0xa0(%rbp), %rcx
movq %rax, %rdx
movq -0x88(%rbp), %rax
movq (%rcx), %rcx
movslq -0x1c(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rcx
movb %dl, 0xc(%rcx)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x1, %edx
movsbl %al, %edi
callq 0x1880
movq -0xa0(%rbp), %rcx
movq %rax, %rdx
movq -0x88(%rbp), %rax
movq (%rcx), %rcx
movslq -0x1c(%rbp), %rsi
shlq $0x4, %rsi
addq %rsi, %rcx
movb %dl, 0xd(%rcx)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x2, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movw %cx, 0xe(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x18(%rbp)
jmp 0x370b
movq -0xa0(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, 0x10(%rax)
cmpl $0x0, -0xc(%rbp)
jne 0x38c6
movq -0xa0(%rbp), %rcx
movq -0x88(%rbp), %rdx
movl 0x30(%rdx), %esi
movq %rsp, %rax
movl %esi, 0x48(%rax)
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups 0x20(%rdx), %xmm2
movups %xmm2, 0x38(%rax)
movups %xmm1, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movups (%rcx), %xmm0
movups %xmm0, (%rax)
callq 0x39c0
jmp 0x38c8
movq -0x98(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax,%rax)