#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_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ *e_ident;
};
typedef int /*<<< orphan*/ FILE;
typedef TYPE_1__ Elf64_Ehdr;

/* Variables and functions */
size_t EI_CLASS;
scalar_t__ ELFCLASS32;
scalar_t__ ELFCLASS64;
int /*<<< orphan*/ fail(char *);
int /*<<< orphan*/ go32(void *, size_t, int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ go64(void *, size_t, int /*<<< orphan*/ *, char const *);
void go(void *addr, size_t len, FILE *outfile, const char *name) {
  Elf64_Ehdr *hdr = (Elf64_Ehdr *)addr;
  if (hdr->e_ident[EI_CLASS] == ELFCLASS64) {
    go64(addr, len, outfile, name);
  } else if (hdr->e_ident[EI_CLASS] == ELFCLASS32) {
    go32(addr, len, outfile, name);
  } else {
    fail("unknown ELF class\n");
  }
}


x86 assembly (clang, -O0):
<go>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2e7a(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%rax
jne    118f <go+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1050 <go64@plt>
jmp    11df <go+0xaf>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2e3b(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x2e25(%rip),%rcx
cmp    (%rcx),%rax
jne    11ce <go+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <go32@plt>
jmp    11da <go+0xaa>
lea    0xe2b(%rip),%rdi
call   1030 <fail@plt>
jmp    11df <go+0xaf>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<go>:
mov    (%rdi),%r8
mov    0x2e9e(%rip),%rax
mov    (%rax),%rax
mov    (%r8,%rax,8),%r8
mov    0x2ea0(%rip),%rax
cmp    (%rax),%r8
jne    1152 <go+0x22>
jmp    1050 <go64@plt>
mov    0x2e77(%rip),%rax
cmp    (%rax),%r8
jne    1163 <go+0x33>
jmp    1040 <go32@plt>
lea    0xe96(%rip),%rdi
jmp    1030 <fail@plt>

LLVM IR (-O0):
%struct.TYPE_2__ = type { i64* }
@EI_CLASS = global i64 0
@ELFCLASS64 = global i64 0
@ELFCLASS32 = global i64 0
@.str = [19 x i8] c"unknown ELF class\0A\00"
define void @go(i8* %0, i64 %1, i32* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca %struct.TYPE_2__*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i32* %2, i32** %7
store i8* %3, i8** %8
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to %struct.TYPE_2__*
store %struct.TYPE_2__* %11, %struct.TYPE_2__** %9
%12 = load %struct.TYPE_2__*, %struct.TYPE_2__** %9
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i32 0, i32 0
%14 = load i64*, i64** %13
%15 = load i64, i64* @EI_CLASS
%16 = getelementptr inbounds i64, i64* %14, i64 %15
%17 = load i64, i64* %16
%18 = load i64, i64* @ELFCLASS64
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %26
20: ; preds = %4
%21 = load i8*, i8** %5
%22 = load i64, i64* %6
%23 = load i32*, i32** %7
%24 = load i8*, i8** %8
%25 = call i32 @go64(i8* %21, i64 %22, i32* %23, i8* %24)
br label %44
26: ; preds = %4
%27 = load %struct.TYPE_2__*, %struct.TYPE_2__** %9
%28 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %27, i32 0, i32 0
%29 = load i64*, i64** %28
%30 = load i64, i64* @EI_CLASS
%31 = getelementptr inbounds i64, i64* %29, i64 %30
%32 = load i64, i64* %31
%33 = load i64, i64* @ELFCLASS32
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %41
35: ; preds = %26
%36 = load i8*, i8** %5
%37 = load i64, i64* %6
%38 = load i32*, i32** %7
%39 = load i8*, i8** %8
%40 = call i32 @go32(i8* %36, i64 %37, i32* %38, i8* %39)
br label %43
41: ; preds = %26
%42 = call i32 @fail(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %35
br label %44
44: ; preds = %43, %20
ret void
}

LLVM IR (-O2):
@EI_CLASS = global i64 0
@ELFCLASS64 = global i64 0
@ELFCLASS32 = global i64 0
@.str = [19 x i8] c"unknown ELF class\0A\00"
define void @go(i8* %0, i64 %1, i32* %2, i8* %3) {
%5 = bitcast i8* %0 to i64**
%6 = load i64*, i64** %5
%7 = load i64, i64* @EI_CLASS
%8 = getelementptr inbounds i64, i64* %6, i64 %7
%9 = load i64, i64* %8
%10 = load i64, i64* @ELFCLASS64
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = tail call i32 @go64(i8* %0, i64 %1, i32* %2, i8* %3)
br label %21
14: ; preds = %4
%15 = load i64, i64* @ELFCLASS32
%16 = icmp eq i64 %9, %15
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @go32(i8* %0, i64 %1, i32* %2, i8* %3)
br label %21
19: ; preds = %14
%20 = tail call i32 @fail(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %17, %19, %12
ret void
}