#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 */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ read_uint64(unsigned char *);
void read_trailer(unsigned char *data, int length, int *offsetSize,
                  int *objectRefSize, uint64_t *numObjects, uint64_t *topObject,
                  uint64_t *offsetTableOffset) {
  unsigned char *trailer = &data[length - 32];
  *offsetSize = trailer[6];
  *objectRefSize = trailer[7];
  *numObjects = read_uint64(&trailer[8]);
  *topObject = read_uint64(&trailer[16]);
  *offsetTableOffset = read_uint64(&trailer[24]);
}


x86 assembly (clang, -O0):
<read_trailer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x20,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movzbl 0x6(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
movzbl 0x7(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rdi
add    $0x8,%rdi
call   1030 <read_uint64@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rdi
add    $0x10,%rdi
call   1030 <read_uint64@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rdi
add    $0x18,%rdi
call   1030 <read_uint64@plt>
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_trailer>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,%r14
mov    %r8,%r15
mov    %rdi,%r13
mov    0x30(%rsp),%r12
movslq %esi,%rbx
movzbl -0x1a(%rbx,%rdi,1),%eax
mov    %eax,(%rdx)
movzbl -0x19(%rbx,%rdi,1),%eax
mov    %eax,(%rcx)
add    %rbx,%rdi
add    $0xffffffffffffffe8,%rdi
call   1030 <read_uint64@plt>
mov    %eax,(%r15)
lea    (%rbx,%r13,1),%rdi
add    $0xfffffffffffffff0,%rdi
call   1030 <read_uint64@plt>
mov    %eax,(%r14)
lea    (%rbx,%r13,1),%rdi
add    $0xfffffffffffffff8,%rdi
call   1030 <read_uint64@plt>
mov    %eax,(%r12)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @read_trailer(i8* %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i8*
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%16 = load i8*, i8** %8
%17 = load i32, i32* %9
%18 = sub nsw i32 %17, 32
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
store i8* %20, i8** %15
%21 = load i8*, i8** %15
%22 = getelementptr inbounds i8, i8* %21, i64 6
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = load i32*, i32** %10
store i32 %24, i32* %25
%26 = load i8*, i8** %15
%27 = getelementptr inbounds i8, i8* %26, i64 7
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = load i32*, i32** %11
store i32 %29, i32* %30
%31 = load i8*, i8** %15
%32 = getelementptr inbounds i8, i8* %31, i64 8
%33 = call i32 @read_uint64(i8* %32)
%34 = load i32*, i32** %12
store i32 %33, i32* %34
%35 = load i8*, i8** %15
%36 = getelementptr inbounds i8, i8* %35, i64 16
%37 = call i32 @read_uint64(i8* %36)
%38 = load i32*, i32** %13
store i32 %37, i32* %38
%39 = load i8*, i8** %15
%40 = getelementptr inbounds i8, i8* %39, i64 24
%41 = call i32 @read_uint64(i8* %40)
%42 = load i32*, i32** %14
store i32 %41, i32* %42
ret void
}

LLVM IR (-O2):
define void @read_trailer(i8* %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6) {
%8 = add nsw i32 %1, -32
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 6
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
store i32 %13, i32* %2
%14 = getelementptr inbounds i8, i8* %10, i64 7
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
store i32 %16, i32* %3
%17 = getelementptr inbounds i8, i8* %10, i64 8
%18 = tail call i32 @read_uint64(i8* %17)
store i32 %18, i32* %4
%19 = getelementptr inbounds i8, i8* %10, i64 16
%20 = tail call i32 @read_uint64(i8* %19)
store i32 %20, i32* %5
%21 = getelementptr inbounds i8, i8* %10, i64 24
%22 = tail call i32 @read_uint64(i8* %21)
store i32 %22, i32* %6
ret void
}