#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_CLASS;
size_t EI_DATA;
size_t EI_MAG0;
size_t EI_MAG1;
size_t EI_MAG2;
size_t EI_MAG3;
size_t EI_VERSION;
unsigned char const ELFMAG0;
unsigned char const ELFMAG1;
unsigned char const ELFMAG2;
unsigned char const ELFMAG3;
int elfrw_initialize_direct(unsigned char const, unsigned char const,
                            unsigned char const);
int elfrw_initialize_ident(unsigned char const *ident) {
  if (ident[EI_MAG0] != ELFMAG0 || ident[EI_MAG1] != ELFMAG1 ||
      ident[EI_MAG2] != ELFMAG2 || ident[EI_MAG3] != ELFMAG3)
    return -1;
  return elfrw_initialize_direct(ident[EI_CLASS], ident[EI_DATA],
                                 ident[EI_VERSION]);
}


x86 assembly (clang, -O0):
<elfrw_initialize_ident>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2eb1(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%eax
mov    0x2e83(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11ac <elfrw_initialize_ident+0x9c>
mov    -0x10(%rbp),%rax
mov    0x2e4d(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%eax
mov    0x2e97(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11ac <elfrw_initialize_ident+0x9c>
mov    -0x10(%rbp),%rax
mov    0x2e61(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%eax
mov    0x2e13(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11ac <elfrw_initialize_ident+0x9c>
mov    -0x10(%rbp),%rax
mov    0x2e0d(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rax,%rcx,1),%eax
mov    0x2e57(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
je     11b8 <elfrw_initialize_ident+0xa8>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fc <elfrw_initialize_ident+0xec>
mov    -0x10(%rbp),%rax
mov    0x2de5(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,1),%sil
mov    -0x10(%rbp),%rax
mov    0x2df3(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    0x2dda(%rip),%rcx
mov    (%rcx),%rcx
movzbl %sil,%edi
movzbl %dl,%esi
movzbl (%rax,%rcx,1),%edx
call   1030 <elfrw_initialize_direct@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elfrw_initialize_ident>:
mov    0x2ed1(%rip),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rdi,%rax,1)
jne    1150 <elfrw_initialize_ident+0x40>
mov    0x2e89(%rip),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rdi,%rax,1)
jne    1150 <elfrw_initialize_ident+0x40>
mov    0x2ea9(%rip),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rdi,%rax,1)
jne    1150 <elfrw_initialize_ident+0x40>
mov    0x2e71(%rip),%rax
mov    (%rax),%rax
cmpb   $0x0,(%rdi,%rax,1)
je     1156 <elfrw_initialize_ident+0x46>
mov    $0xffffffff,%eax
ret
mov    0x2e63(%rip),%rax
mov    (%rax),%rax
movzbl (%rdi,%rax,1),%eax
mov    0x2e6d(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rdi,%rcx,1),%esi
mov    0x2e57(%rip),%rcx
mov    (%rcx),%rcx
movzbl (%rdi,%rcx,1),%edx
mov    %eax,%edi
jmp    1030 <elfrw_initialize_direct@plt>

LLVM IR (-O0):
@EI_MAG0 = global i64 0
@ELFMAG0 = constant i8 0
@EI_MAG1 = global i64 0
@ELFMAG1 = constant i8 0
@EI_MAG2 = global i64 0
@ELFMAG2 = constant i8 0
@EI_MAG3 = global i64 0
@ELFMAG3 = constant i8 0
@EI_CLASS = global i64 0
@EI_DATA = global i64 0
@EI_VERSION = global i64 0
define i32 @elfrw_initialize_ident(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i64, i64* @EI_MAG0
%6 = getelementptr inbounds i8, i8* %4, i64 %5
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = load i8, i8* @ELFMAG0
%10 = zext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %39, label %12
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = load i64, i64* @EI_MAG1
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = load i8, i8* @ELFMAG1
%19 = zext i8 %18 to i32
%20 = icmp ne i32 %17, %19
br i1 %20, label %39, label %21
21: ; preds = %12
%22 = load i8*, i8** %3
%23 = load i64, i64* @EI_MAG2
%24 = getelementptr inbounds i8, i8* %22, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = load i8, i8* @ELFMAG2
%28 = zext i8 %27 to i32
%29 = icmp ne i32 %26, %28
br i1 %29, label %39, label %30
30: ; preds = %21
%31 = load i8*, i8** %3
%32 = load i64, i64* @EI_MAG3
%33 = getelementptr inbounds i8, i8* %31, i64 %32
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = load i8, i8* @ELFMAG3
%37 = zext i8 %36 to i32
%38 = icmp ne i32 %35, %37
br i1 %38, label %39, label %40
39: ; preds = %30, %21, %12, %1
store i32 -1, i32* %2
br label %54
40: ; preds = %30
%41 = load i8*, i8** %3
%42 = load i64, i64* @EI_CLASS
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i8, i8* %43
%45 = load i8*, i8** %3
%46 = load i64, i64* @EI_DATA
%47 = getelementptr inbounds i8, i8* %45, i64 %46
%48 = load i8, i8* %47
%49 = load i8*, i8** %3
%50 = load i64, i64* @EI_VERSION
%51 = getelementptr inbounds i8, i8* %49, i64 %50
%52 = load i8, i8* %51
%53 = call i32 @elfrw_initialize_direct(i8 zeroext %44, i8 zeroext %48, i8 zeroext %52)
store i32 %53, i32* %2
br label %54
54: ; preds = %40, %39
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
@EI_MAG0 = global i64 0
@ELFMAG0 = constant i8 0
@EI_MAG1 = global i64 0
@ELFMAG1 = constant i8 0
@EI_MAG2 = global i64 0
@ELFMAG2 = constant i8 0
@EI_MAG3 = global i64 0
@ELFMAG3 = constant i8 0
@EI_CLASS = global i64 0
@EI_DATA = global i64 0
@EI_VERSION = global i64 0
define i32 @elfrw_initialize_ident(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, 0
br i1 %5, label %6, label %32
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, 0
br i1 %10, label %11, label %32
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, 0
br i1 %15, label %16, label %32
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, 0
br i1 %20, label %21, label %32
21: ; preds = %16
%22 = load i64, i64* @EI_CLASS
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = load i64, i64* @EI_DATA
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = load i8, i8* %26
%28 = load i64, i64* @EI_VERSION
%29 = getelementptr inbounds i8, i8* %0, i64 %28
%30 = load i8, i8* %29
%31 = tail call i32 @elfrw_initialize_direct(i8 zeroext %24, i8 zeroext %27, i8 zeroext %30)
br label %32
32: ; preds = %1, %6, %11, %16, %21
%33 = phi i32 [ %31, %21 ], [ -1, %16 ], [ -1, %11 ], [ -1, %6 ], [ -1, %1 ]
ret i32 %33
}