// File: /workspace/github_c_makefile_star2_O3/Astor-Bizard[P]ProjetS5_Groupe2/src/lectureSH.c
// Function: readSectionsHeadersFromFile
SectionsHeadersList readSectionsHeadersFromFile(FILE *f, Elf32_Ehdr elfHeader, int silent) {
	int i;
	SectionsHeadersList shList;
	shList.size = elfHeader.e_shnum;

	// Allocation de la table des en-têtes de section
	shList.headers = (Elf32_Shdr*) malloc(sizeof(Elf32_Shdr)*shList.size);
	if (shList.headers==NULL) {
		printf("\nErreur lors de l'allocation initiale de shList.headers.\n");
		shList.names = NULL;
		shList.headers = NULL;
		shList.size = 0;
		return shList;
	}

	fseek(f, elfHeader.e_shoff, 0);
	for(i=0; i<shList.size; i++) {
		shList.headers[i].sh_name = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		shList.headers[i].sh_type = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		shList.headers[i].sh_flags = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		shList.headers[i].sh_addr = (Elf32_Addr) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		shList.headers[i].sh_offset = (Elf32_Off) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		shList.headers[i].sh_size = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		shList.headers[i].sh_link = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		shList.headers[i].sh_info = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		shList.headers[i].sh_addralign = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
		shList.headers[i].sh_entsize = (uint32_t) lire_octets(elfHeader.e_ident[EI_DATA], f, 4);
	}

	shList.names = fetchSectionNames(f, elfHeader, shList);

	if (!silent) {
		displaySectionsHeaders(elfHeader, shList);
	}

	return shList;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movzwl 0xc0(%rsp), %r12d
movl %r12d, 0x10(%rdi)
leal (,%r12,8), %eax
leaq (%rax,%rax,4), %rdi
callq 0x10d0
movq %rax, (%rbx)
testq %rax, %rax
je 0x2260
movq %rax, %r15
movl %ebp, 0x54(%rsp)
leaq 0x90(%rsp), %rax
movl 0x20(%rax), %esi
movq %r14, %rdi
xorl %edx, %edx
callq 0x10e0
testq %r12, %r12
je 0x21d4
shll $0x3, %r12d
leaq (%r12,%r12,4), %rbp
xorl %r13d, %r13d
leaq 0x90(%rsp), %rax
movsbl 0x5(%rax), %r12d
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, (%r15,%r13)
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, 0x4(%r15,%r13)
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, 0x8(%r15,%r13)
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, 0xc(%r15,%r13)
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, 0x10(%r15,%r13)
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, 0x14(%r15,%r13)
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, 0x18(%r15,%r13)
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, 0x1c(%r15,%r13)
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, 0x20(%r15,%r13)
movl %r12d, %edi
movq %r14, %rsi
movl $0x4, %edx
callq 0x168c
movl %eax, 0x24(%r15,%r13)
addq $0x28, %r13
cmpq %r13, %rbp
jne 0x20f6
movq 0x10(%rbx), %rax
movq %rax, 0x48(%rsp)
movups (%rbx), %xmm0
movups %xmm0, 0x38(%rsp)
leaq 0x90(%rsp), %r15
movl 0x30(%r15), %eax
movl %eax, 0x30(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x1d64
movq %rax, 0x8(%rbx)
cmpl $0x0, 0x54(%rsp)
jne 0x2279
movq 0x10(%rbx), %rax
movq %rax, 0x48(%rsp)
movups (%rbx), %xmm0
movups %xmm0, 0x38(%rsp)
movl 0x30(%r15), %eax
movl %eax, 0x30(%rsp)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x1f30
jmp 0x2279
leaq 0x28cc(%rip), %rdi      # 0x4b33
callq 0x1060
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movl $0x0, 0x10(%rbx)
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop