// File: /workspace/github_c_makefile_star2_O2/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 $0x68, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movzwl 0xd0(%rsp), %eax
movl %eax, 0x10(%rdi)
imulq $0x28, %rax, %r15
movq %r15, %rdi
callq 0x10d0
movq %rax, (%rbx)
testq %rax, %rax
je 0x2160
movq %rax, %r12
movl %ebp, 0x5c(%rsp)
movq %rbx, 0x60(%rsp)
leaq 0xa0(%rsp), %r13
movl 0x20(%r13), %esi
xorl %ebx, %ebx
movq %r14, %rdi
xorl %edx, %edx
callq 0x10e0
movsbl 0x5(%r13), %r13d
pushq $0x4
popq %rbp
cmpq %rbx, %r15
je 0x20cf
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, (%r12,%rbx)
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, 0x4(%r12,%rbx)
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, 0x8(%r12,%rbx)
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, 0xc(%r12,%rbx)
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, 0x10(%r12,%rbx)
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, 0x14(%r12,%rbx)
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, 0x18(%r12,%rbx)
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, 0x1c(%r12,%rbx)
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, 0x20(%r12,%rbx)
movl %r13d, %edi
movq %r14, %rsi
movl %ebp, %edx
callq 0x160c
movl %eax, 0x24(%r12,%rbx)
addq $0x28, %rbx
jmp 0x200a
movq 0x60(%rsp), %rbx
movq 0x10(%rbx), %rax
movq %rax, 0x48(%rsp)
movups (%rbx), %xmm0
movups %xmm0, 0x38(%rsp)
leaq 0xa0(%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 0x1ca8
movq %rax, 0x8(%rbx)
cmpl $0x0, 0x5c(%rsp)
jne 0x2176
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 0x1e59
jmp 0x2176
leaq 0x29cc(%rip), %rdi      # 0x4b33
callq 0x1060
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
andl $0x0, 0x10(%rbx)
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq