#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
size_t EI_MAG0;
size_t EI_MAG1;
size_t EI_MAG2;
size_t EI_MAG3;
int check_file_format(unsigned char *e) {
  return (e[EI_MAG0] == 0x7f && e[EI_MAG1] == 'E' && e[EI_MAG2] == 'L' &&
          e[EI_MAG3] == 'F');
}


x86 assembly (clang, -O0):
<check_file_format>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2ed5(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x7f,%ecx
mov    %al,-0x9(%rbp)
jne    1183 <check_file_format+0x83>
mov    -0x8(%rbp),%rax
mov    0x2e95(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x45,%ecx
mov    %al,-0x9(%rbp)
jne    1183 <check_file_format+0x83>
mov    -0x8(%rbp),%rax
mov    0x2e8d(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x4c,%ecx
mov    %al,-0x9(%rbp)
jne    1183 <check_file_format+0x83>
mov    -0x8(%rbp),%rax
mov    0x2e5d(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x46,%eax
sete   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_file_format>:
mov    0x2ee1(%rip),%rax
mov    (%rax),%rcx
xor    %eax,%eax
cmpb   $0x7f,(%rdi,%rcx,1)
jne    1145 <check_file_format+0x45>
mov    0x2eaf(%rip),%rcx
mov    (%rcx),%rcx
cmpb   $0x45,(%rdi,%rcx,1)
jne    1145 <check_file_format+0x45>
mov    0x2eb7(%rip),%rcx
mov    (%rcx),%rcx
cmpb   $0x4c,(%rdi,%rcx,1)
jne    1145 <check_file_format+0x45>
mov    0x2e97(%rip),%rax
mov    (%rax),%rcx
xor    %eax,%eax
cmpb   $0x46,(%rdi,%rcx,1)
sete   %al
ret

LLVM IR (-O0):
@EI_MAG0 = global i64 0
@EI_MAG1 = global i64 0
@EI_MAG2 = global i64 0
@EI_MAG3 = global i64 0
define i32 @check_file_format(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i64, i64* @EI_MAG0
%5 = getelementptr inbounds i8, i8* %3, i64 %4
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = icmp eq i32 %7, 127
br i1 %8, label %9, label %30
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = load i64, i64* @EI_MAG1
%12 = getelementptr inbounds i8, i8* %10, i64 %11
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = icmp eq i32 %14, 69
br i1 %15, label %16, label %30
16: ; preds = %9
%17 = load i8*, i8** %2
%18 = load i64, i64* @EI_MAG2
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = icmp eq i32 %21, 76
br i1 %22, label %23, label %30
23: ; preds = %16
%24 = load i8*, i8** %2
%25 = load i64, i64* @EI_MAG3
%26 = getelementptr inbounds i8, i8* %24, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = icmp eq i32 %28, 70
br label %30
30: ; preds = %23, %16, %9, %1
%31 = phi i1 [ false, %16 ], [ false, %9 ], [ false, %1 ], [ %29, %23 ]
%32 = zext i1 %31 to i32
ret i32 %32
}

LLVM IR (-O2):
@EI_MAG0 = global i64 0
@EI_MAG1 = global i64 0
@EI_MAG2 = global i64 0
@EI_MAG3 = global i64 0
define i32 @check_file_format(i8* nocapture %0) {
%2 = load i64, i64* @EI_MAG0
%3 = getelementptr inbounds i8, i8* %0, i64 %2
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 127
br i1 %5, label %6, label %22
6: ; preds = %1
%7 = load i64, i64* @EI_MAG1
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 69
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = load i64, i64* @EI_MAG2
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 76
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = load i64, i64* @EI_MAG3
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 70
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %16, %11, %6, %1
%23 = phi i32 [ 0, %11 ], [ 0, %6 ], [ 0, %1 ], [ %21, %16 ]
ret i32 %23
}