#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ *e_ident;
};
typedef TYPE_1__ Elf32_Ehdr;

/* Variables and functions */
size_t EI_MAG0;
size_t EI_MAG1;
size_t EI_MAG2;
size_t EI_MAG3;
scalar_t__ ELFMAG0;
scalar_t__ ELFMAG1;
scalar_t__ ELFMAG2;
scalar_t__ ELFMAG3;
bool is_elf(Elf32_Ehdr *e) {
  return (e->e_ident[EI_MAG0] == ELFMAG0 && e->e_ident[EI_MAG1] == ELFMAG1 &&
          e->e_ident[EI_MAG2] == ELFMAG2 && e->e_ident[EI_MAG3] == ELFMAG3);
}


x86 assembly (clang, -O0):
<is_elf>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2ec2(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
xor    %eax,%eax
mov    0x2ea2(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x9(%rbp)
jne    11ab <is_elf+0xab>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2e70(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
xor    %eax,%eax
mov    0x2ea0(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x9(%rbp)
jne    11ab <is_elf+0xab>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2e66(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
xor    %eax,%eax
mov    0x2e2e(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x9(%rbp)
jne    11ab <is_elf+0xab>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2e24(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x2e56(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_elf>:
mov    (%rdi),%rcx
mov    0x2ece(%rip),%rax
mov    (%rax),%rax
mov    (%rcx,%rax,8),%rdx
mov    0x2eb0(%rip),%rsi
xor    %eax,%eax
cmp    (%rsi),%rdx
jne    1170 <is_elf+0x70>
mov    0x2e8a(%rip),%rdx
mov    (%rdx),%rdx
mov    (%rcx,%rdx,8),%rdx
mov    0x2ebc(%rip),%rsi
cmp    (%rsi),%rdx
jne    1170 <is_elf+0x70>
mov    0x2e90(%rip),%rdx
mov    (%rdx),%rdx
mov    (%rcx,%rdx,8),%rdx
mov    0x2e5a(%rip),%rsi
cmp    (%rsi),%rdx
jne    1170 <is_elf+0x70>
mov    0x2e5e(%rip),%rax
mov    (%rax),%rax
mov    (%rcx,%rax,8),%rcx
mov    0x2e90(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
sete   %al
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64* }
@EI_MAG0 = global i64 0
@ELFMAG0 = global i64 0
@EI_MAG1 = global i64 0
@ELFMAG1 = global i64 0
@EI_MAG2 = global i64 0
@ELFMAG2 = global i64 0
@EI_MAG3 = global i64 0
@ELFMAG3 = global i64 0
define i32 @is_elf(%struct.TYPE_3__* %0) {
%2 = alloca %struct.TYPE_3__*
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %2
%3 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i32 0, i32 0
%5 = load i64*, i64** %4
%6 = load i64, i64* @EI_MAG0
%7 = getelementptr inbounds i64, i64* %5, i64 %6
%8 = load i64, i64* %7
%9 = load i64, i64* @ELFMAG0
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %38
11: ; preds = %1
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
%14 = load i64*, i64** %13
%15 = load i64, i64* @EI_MAG1
%16 = getelementptr inbounds i64, i64* %14, i64 %15
%17 = load i64, i64* %16
%18 = load i64, i64* @ELFMAG1
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %38
20: ; preds = %11
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 0
%23 = load i64*, i64** %22
%24 = load i64, i64* @EI_MAG2
%25 = getelementptr inbounds i64, i64* %23, i64 %24
%26 = load i64, i64* %25
%27 = load i64, i64* @ELFMAG2
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %38
29: ; preds = %20
%30 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %30, i32 0, i32 0
%32 = load i64*, i64** %31
%33 = load i64, i64* @EI_MAG3
%34 = getelementptr inbounds i64, i64* %32, i64 %33
%35 = load i64, i64* %34
%36 = load i64, i64* @ELFMAG3
%37 = icmp eq i64 %35, %36
br label %38
38: ; preds = %29, %20, %11, %1
%39 = phi i1 [ false, %20 ], [ false, %11 ], [ false, %1 ], [ %37, %29 ]
%40 = zext i1 %39 to i32
ret i32 %40
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64* }
@EI_MAG0 = global i64 0
@ELFMAG0 = global i64 0
@EI_MAG1 = global i64 0
@ELFMAG1 = global i64 0
@EI_MAG2 = global i64 0
@ELFMAG2 = global i64 0
@EI_MAG3 = global i64 0
@ELFMAG3 = global i64 0
define i32 @is_elf(%struct.TYPE_3__* nocapture %0) {
%2 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%3 = load i64*, i64** %2
%4 = load i64, i64* @EI_MAG0
%5 = getelementptr inbounds i64, i64* %3, i64 %4
%6 = load i64, i64* %5
%7 = load i64, i64* @ELFMAG0
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %28
9: ; preds = %1
%10 = load i64, i64* @EI_MAG1
%11 = getelementptr inbounds i64, i64* %3, i64 %10
%12 = load i64, i64* %11
%13 = load i64, i64* @ELFMAG1
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %28
15: ; preds = %9
%16 = load i64, i64* @EI_MAG2
%17 = getelementptr inbounds i64, i64* %3, i64 %16
%18 = load i64, i64* %17
%19 = load i64, i64* @ELFMAG2
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %15
%22 = load i64, i64* @EI_MAG3
%23 = getelementptr inbounds i64, i64* %3, i64 %22
%24 = load i64, i64* %23
%25 = load i64, i64* @ELFMAG3
%26 = icmp eq i64 %24, %25
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %21, %15, %9, %1
%29 = phi i32 [ 0, %15 ], [ 0, %9 ], [ 0, %1 ], [ %27, %21 ]
ret i32 %29
}