// File: /workspace/github_c_makefile_star2_O0/Astor-Bizard[P]ProjetS5_Groupe2/src/lecture_headers.c
// Function: lecture_Headers
Elf32_Ehdr lecture_Headers(FILE *f, int silent)
{
	long long int lec_Cour = 0;
	Elf32_Ehdr headers;
	headers.e_ident[EI_DATA]=(char) B_ENDIAN;
	int i;

	lec_Cour = lire_octets(headers.e_ident[EI_DATA],f,4);

	if (lec_Cour != 0x7f454c46)
	{
		printf("Erreur lecture_Header : 7f45 4c46\n");
		printf("Octets lus : %llx\n", lec_Cour);
		exit(1);
	}

	MEMORISER(1,headers.e_ident[EI_CLASS]);
	if (headers.e_ident[EI_CLASS] != 1 && headers.e_ident[EI_CLASS] != 2)
	{
		printf("Erreur lecture_Header : Classe\n");
		printf("Octets lus : %x\n", headers.e_ident[EI_CLASS]);
		exit(1);
	}

	headers.e_ident[EI_MAG0]=0x7F;
	headers.e_ident[EI_MAG1]='E';
	headers.e_ident[EI_MAG2]='L';
	headers.e_ident[EI_MAG3]='F';

	MEMORISER(1,headers.e_ident[EI_DATA]);
	if (headers.e_ident[EI_DATA] != 1 && headers.e_ident[EI_DATA] != 2)
	{
		printf("Erreur lecture_Header : Data\n");
		printf("Octets lus : %x\n", headers.e_ident[EI_DATA]);
		exit(1);
	}

	if (headers.e_ident[EI_DATA] == 0x01)
		headers.e_ident[EI_DATA] = (char) L_ENDIAN;
	else
		headers.e_ident[EI_DATA] = (char) B_ENDIAN;

	MEMORISER(1,headers.e_ident[EI_VERSION]);
	if(! (headers.e_ident[EI_VERSION]))
	{
		printf("Erreur lecture_Header : Version header\n");
		printf("Octets lus : %x\n", headers.e_ident[EI_VERSION]);
		exit(1);
	}

	lire_octets(headers.e_ident[EI_DATA],f,9);
	for(i=7;i<EI_NIDENT;i++) headers.e_ident[i]=0x0;

	MEMORISER(2,headers.e_type);
	switch(headers.e_type)
	{
		case ET_NONE:
		case ET_REL:
		case ET_EXEC:
		case ET_DYN:
		case ET_CORE:
		case ET_LOPROC:
		case ET_HIPROC:
			break;
		default:
			printf("Erreur lecture_Header : Type\n");
			exit(1);
	}

	MEMORISER(2,headers.e_machine);

	MEMORISER(4,headers.e_version);
	if(! (headers.e_version))
	{
		printf("Erreur lecture_Header : Version\n");
		printf("Octets lus : %llx\n", lec_Cour);
		exit(1);
	}

	MEMORISER(4,headers.e_entry);

	MEMORISER(4,headers.e_phoff);

	MEMORISER(4,headers.e_shoff);

	MEMORISER(4,headers.e_flags);

	MEMORISER(2,headers.e_ehsize);

	MEMORISER(2,headers.e_phentsize);

	MEMORISER(2,headers.e_phnum);

	MEMORISER(2,headers.e_shentsize);

	MEMORISER(2,headers.e_shnum);

	MEMORISER(2,headers.e_shstrndx);

	if(!silent)
	{
		afficher_headers(headers);
	}

	return headers;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x60(%rbp)
movq %rdi, %rax
movq %rax, -0x58(%rbp)
movq %rsi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movq $0x0, -0x18(%rbp)
movb $0x2, 0x5(%rdi)
movb 0x5(%rdi), %al
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, -0x18(%rbp)
cmpq $0x7f454c46, -0x18(%rbp) # imm = 0x7F454C46
je 0x19a5
leaq 0x39ea(%rip), %rdi      # 0x536c
movb $0x0, %al
callq 0x1070
movq -0x18(%rbp), %rsi
leaq 0x39fb(%rip), %rdi      # 0x538f
movb $0x0, %al
callq 0x1070
movl $0x1, %edi
callq 0x1120
movq -0x60(%rbp), %rax
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x1, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movb %cl, 0x4(%rax)
movzbl 0x4(%rax), %eax
cmpl $0x1, %eax
je 0x1a0b
movq -0x60(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x2, %eax
je 0x1a0b
leaq 0x39be(%rip), %rdi      # 0x53a2
movb $0x0, %al
callq 0x1070
movq -0x60(%rbp), %rax
movzbl 0x4(%rax), %esi
leaq 0x39c8(%rip), %rdi      # 0x53c2
movb $0x0, %al
callq 0x1070
movl $0x1, %edi
callq 0x1120
movq -0x60(%rbp), %rax
movb $0x7f, (%rax)
movb $0x45, 0x1(%rax)
movb $0x4c, 0x2(%rax)
movb $0x46, 0x3(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x1, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movb %cl, 0x5(%rax)
movzbl 0x5(%rax), %eax
cmpl $0x1, %eax
je 0x1a80
movq -0x60(%rbp), %rax
movzbl 0x5(%rax), %eax
cmpl $0x2, %eax
je 0x1a80
leaq 0x397a(%rip), %rdi      # 0x53d3
movb $0x0, %al
callq 0x1070
movq -0x60(%rbp), %rax
movzbl 0x5(%rax), %esi
leaq 0x3953(%rip), %rdi      # 0x53c2
movb $0x0, %al
callq 0x1070
movl $0x1, %edi
callq 0x1120
movq -0x60(%rbp), %rax
movzbl 0x5(%rax), %eax
cmpl $0x1, %eax
jne 0x1a97
movq -0x60(%rbp), %rax
movb $0x1, 0x5(%rax)
jmp 0x1a9f
movq -0x60(%rbp), %rax
movb $0x2, 0x5(%rax)
movq -0x60(%rbp), %rax
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x1, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movb %cl, 0x6(%rax)
cmpb $0x0, 0x6(%rax)
jne 0x1af5
leaq 0x3923(%rip), %rdi      # 0x53f1
movb $0x0, %al
callq 0x1070
movq -0x60(%rbp), %rax
movzbl 0x6(%rax), %esi
leaq 0x38de(%rip), %rdi      # 0x53c2
movb $0x0, %al
callq 0x1070
movl $0x1, %edi
callq 0x1120
movq -0x60(%rbp), %rax
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x9, %edx
movsbl %al, %edi
callq 0x1880
movl $0x7, -0x1c(%rbp)
cmpl $0x10, -0x1c(%rbp)
jge 0x1b31
movq -0x60(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1b14
movq -0x60(%rbp), %rax
movsbl 0x5(%rax), %edi
movq -0x8(%rbp), %rsi
movl $0x2, %edx
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movw %cx, 0x10(%rax)
movzwl 0x10(%rax), %eax
movl %eax, -0x64(%rbp)
subl $0x5, %eax
jb 0x1b78
jmp 0x1b60
movl -0x64(%rbp), %eax
subl $0xff00, %eax           # imm = 0xFF00
je 0x1b78
jmp 0x1b6c
movl -0x64(%rbp), %eax
subl $0xffff, %eax           # imm = 0xFFFF
jne 0x1b7a
jmp 0x1b78
jmp 0x1b92
leaq 0x3898(%rip), %rdi      # 0x5419
movb $0x0, %al
callq 0x1070
movl $0x1, %edi
callq 0x1120
movq -0x60(%rbp), %rax
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x2, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movw %cx, 0x12(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movl %ecx, 0x14(%rax)
cmpl $0x0, 0x14(%rax)
jne 0x1c03
leaq 0x3857(%rip), %rdi      # 0x5437
movb $0x0, %al
callq 0x1070
movq -0x18(%rbp), %rsi
leaq 0x379d(%rip), %rdi      # 0x538f
movb $0x0, %al
callq 0x1070
movl $0x1, %edi
callq 0x1120
movq -0x60(%rbp), %rax
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movl %ecx, 0x18(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movl %ecx, 0x1c(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movl %ecx, 0x20(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x4, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movl %ecx, 0x24(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x2, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movw %cx, 0x28(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x2, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movw %cx, 0x2a(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x2, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movw %cx, 0x2c(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x2, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movw %cx, 0x2e(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x2, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movw %cx, 0x30(%rax)
movb 0x5(%rax), %al
movq -0x8(%rbp), %rsi
movl $0x2, %edx
movsbl %al, %edi
callq 0x1880
movq %rax, %rcx
movq -0x60(%rbp), %rax
movw %cx, 0x32(%rax)
cmpl $0x0, -0xc(%rbp)
jne 0x1d76
movq -0x60(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movl $0x34, %edx
callq 0x10b0
movl -0x20(%rbp), %ecx
movq %rsp, %rax
movl %ecx, 0x30(%rax)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups -0x30(%rbp), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x1d90
movq -0x58(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)