#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  int /*<<< orphan*/ e_shoff;
};
struct TYPE_5__ {
  int /*<<< orphan*/ sh_offset;
  int /*<<< orphan*/ sh_link;
};
typedef int /*<<< orphan*/ Elf64_Sym;
typedef TYPE_1__ Elf64_Shdr;
typedef int /*<<< orphan*/ Elf64_Rel;
typedef TYPE_2__ Elf64_Ehdr;

/* Variables and functions */
size_t w(int /*<<< orphan*/);
int w8(int /*<<< orphan*/);
void get_sym_str_and_relp_64(Elf64_Shdr const *const relhdr,
                             Elf64_Ehdr const *const ehdr,
                             Elf64_Sym const **sym0, char const **str0,
                             Elf64_Rel const **relp) {
  Elf64_Shdr *const shdr0 = (Elf64_Shdr *)(w8(ehdr->e_shoff) + (void *)ehdr);
  unsigned const symsec_sh_link = w(relhdr->sh_link);
  Elf64_Shdr const *const symsec = &shdr0[symsec_sh_link];
  Elf64_Shdr const *const strsec = &shdr0[w(symsec->sh_link)];
  Elf64_Rel const *const rel0 =
      (Elf64_Rel const *)(w8(relhdr->sh_offset) + (void *)ehdr);
  *sym0 = (Elf64_Sym const *)(w8(symsec->sh_offset) + (void *)ehdr);
  *str0 = (char const *)(w8(strsec->sh_offset) + (void *)ehdr);
  *relp = rel0;
}


x86 assembly (clang, -O0):
<get_sym_str_and_relp_64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <w8@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <w@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <w@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <w8@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%edi
call   1030 <w8@plt>
mov    -0x10(%rbp),%rcx
cltq
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x48(%rbp),%rax
mov    (%rax),%edi
call   1030 <w8@plt>
mov    -0x10(%rbp),%rcx
cltq
add    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x50(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sym_str_and_relp_64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r13
mov    (%rsi),%edi
call   1030 <w8@plt>
movslq %eax,%r14
add    %rbx,%r14
mov    0x4(%r13),%edi
call   1040 <w@plt>
mov    %eax,%r15d
mov    0x4(%r14,%r15,8),%edi
call   1040 <w@plt>
mov    %rax,%r12
mov    0x0(%r13),%edi
call   1030 <w8@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    (%r14,%r15,8),%edi
call   1030 <w8@plt>
cltq
add    %rbx,%rax
mov    (%rsp),%rcx
mov    %rax,(%rcx)
mov    (%r14,%r12,8),%edi
call   1030 <w8@plt>
cltq
add    %rbx,%rax
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
mov    0x10(%rsp),%rax
mov    %rbp,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i32 }
%struct.TYPE_6__ = type { i32 }
define void @get_sym_str_and_relp_64(%struct.TYPE_5__* %0, %struct.TYPE_6__* %1, i32** %2, i8** %3, i32** %4) {
%6 = alloca %struct.TYPE_5__*
%7 = alloca %struct.TYPE_6__*
%8 = alloca i32**
%9 = alloca i8**
%10 = alloca i32**
%11 = alloca %struct.TYPE_5__*
%12 = alloca i32
%13 = alloca %struct.TYPE_5__*
%14 = alloca %struct.TYPE_5__*
%15 = alloca i32*
store %struct.TYPE_5__* %0, %struct.TYPE_5__** %6
store %struct.TYPE_6__* %1, %struct.TYPE_6__** %7
store i32** %2, i32*** %8
store i8** %3, i8*** %9
store i32** %4, i32*** %10
%16 = load %struct.TYPE_6__*, %struct.TYPE_6__** %7
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 @w8(i32 %18)
%20 = load %struct.TYPE_6__*, %struct.TYPE_6__** %7
%21 = bitcast %struct.TYPE_6__* %20 to i8*
%22 = sext i32 %19 to i64
%23 = getelementptr i8, i8* %21, i64 %22
%24 = bitcast i8* %23 to %struct.TYPE_5__*
store %struct.TYPE_5__* %24, %struct.TYPE_5__** %11
%25 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%26 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = call i64 @w(i32 %27)
%29 = trunc i64 %28 to i32
store i32 %29, i32* %12
%30 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%31 = load i32, i32* %12
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %30, i64 %32
store %struct.TYPE_5__* %33, %struct.TYPE_5__** %13
%34 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%35 = load %struct.TYPE_5__*, %struct.TYPE_5__** %13
%36 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = call i64 @w(i32 %37)
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %34, i64 %38
store %struct.TYPE_5__* %39, %struct.TYPE_5__** %14
%40 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%41 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %40, i32 0, i32 0
%42 = load i32, i32* %41
%43 = call i32 @w8(i32 %42)
%44 = load %struct.TYPE_6__*, %struct.TYPE_6__** %7
%45 = bitcast %struct.TYPE_6__* %44 to i8*
%46 = sext i32 %43 to i64
%47 = getelementptr i8, i8* %45, i64 %46
%48 = bitcast i8* %47 to i32*
store i32* %48, i32** %15
%49 = load %struct.TYPE_5__*, %struct.TYPE_5__** %13
%50 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %49, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i32 @w8(i32 %51)
%53 = load %struct.TYPE_6__*, %struct.TYPE_6__** %7
%54 = bitcast %struct.TYPE_6__* %53 to i8*
%55 = sext i32 %52 to i64
%56 = getelementptr i8, i8* %54, i64 %55
%57 = bitcast i8* %56 to i32*
%58 = load i32**, i32*** %8
store i32* %57, i32** %58
%59 = load %struct.TYPE_5__*, %struct.TYPE_5__** %14
%60 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %59, i32 0, i32 0
%61 = load i32, i32* %60
%62 = call i32 @w8(i32 %61)
%63 = load %struct.TYPE_6__*, %struct.TYPE_6__** %7
%64 = bitcast %struct.TYPE_6__* %63 to i8*
%65 = sext i32 %62 to i64
%66 = getelementptr i8, i8* %64, i64 %65
%67 = load i8**, i8*** %9
store i8* %66, i8** %67
%68 = load i32*, i32** %15
%69 = load i32**, i32*** %10
store i32* %68, i32** %69
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i32 }
%struct.TYPE_6__ = type { i32 }
define void @get_sym_str_and_relp_64(%struct.TYPE_5__* nocapture %0, %struct.TYPE_6__* %1, i32** nocapture writeonly %2, i8** nocapture writeonly %3, i32** nocapture writeonly %4) {
%6 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = tail call i32 @w8(i32 %7)
%9 = bitcast %struct.TYPE_6__* %1 to i8*
%10 = sext i32 %8 to i64
%11 = getelementptr i8, i8* %9, i64 %10
%12 = bitcast i8* %11 to %struct.TYPE_5__*
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 1
%14 = load i32, i32* %13
%15 = tail call i64 @w(i32 %14)
%16 = and i64 %15, 4294967295
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i64 %16, i32 1
%18 = load i32, i32* %17
%19 = tail call i64 @w(i32 %18)
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0
%21 = load i32, i32* %20
%22 = tail call i32 @w8(i32 %21)
%23 = sext i32 %22 to i64
%24 = getelementptr i8, i8* %9, i64 %23
%25 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i64 %16, i32 0
%26 = load i32, i32* %25
%27 = tail call i32 @w8(i32 %26)
%28 = sext i32 %27 to i64
%29 = getelementptr i8, i8* %9, i64 %28
%30 = bitcast i32** %2 to i8**
store i8* %29, i8** %30
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i64 %19, i32 0
%32 = load i32, i32* %31
%33 = tail call i32 @w8(i32 %32)
%34 = sext i32 %33 to i64
%35 = getelementptr i8, i8* %9, i64 %34
store i8* %35, i8** %3
%36 = bitcast i32** %4 to i8**
store i8* %24, i8** %36
ret void
}