void *get_member(ref, i) void *ref;
unsigned int i;
{
  if (*((unsigned int *)((unsigned char *)(ref) + sizeof(void *) +
                         sizeof(unsigned int) + sizeof(void *))) == 0) {
    return *((void **)((unsigned char *)(ref) + sizeof(int) + sizeof(void *) +
                       sizeof(unsigned int) + sizeof(void *) +
                       sizeof(unsigned int)) +
             (i));
  } else {
    return *(
        (void **)((unsigned char *)(ref) + sizeof(int) + sizeof(void *) +
                  sizeof(unsigned int) + sizeof(void *) + sizeof(unsigned int) +
                  ((*((unsigned int *)((unsigned char *)(ref) + sizeof(void *) +
                                       sizeof(unsigned int) +
                                       sizeof(void *)))) *
                   sizeof(unsigned int))) +
        (i));
  }
}


x86 assembly (clang, -O0):
<get_member>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,0x14(%rax)
jne    112e <get_member+0x2e>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    0x1c(%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    115f <get_member+0x5f>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
add    $0x8,%rax
add    $0x4,%rax
add    $0x8,%rax
add    $0x4,%rax
mov    -0x10(%rbp),%rcx
mov    0x14(%rcx),%ecx
shl    $0x2,%rcx
add    %rcx,%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_member>:
mov    0x14(%rdi),%eax
lea    0x0(,%rax,4),%rcx
test   %rax,%rax
cmove  %rax,%rcx
add    %rdi,%rcx
mov    %esi,%eax
mov    0x1c(%rcx,%rax,8),%rax
ret

LLVM IR (-O0):
define i8* @get_member(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 8
%8 = getelementptr inbounds i8, i8* %7, i64 4
%9 = getelementptr inbounds i8, i8* %8, i64 8
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 4
%16 = getelementptr inbounds i8, i8* %15, i64 8
%17 = getelementptr inbounds i8, i8* %16, i64 4
%18 = getelementptr inbounds i8, i8* %17, i64 8
%19 = getelementptr inbounds i8, i8* %18, i64 4
%20 = bitcast i8* %19 to i8**
%21 = load i32, i32* %5
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
store i8* %24, i8** %3
br label %46
25: ; preds = %2
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 4
%28 = getelementptr inbounds i8, i8* %27, i64 8
%29 = getelementptr inbounds i8, i8* %28, i64 4
%30 = getelementptr inbounds i8, i8* %29, i64 8
%31 = getelementptr inbounds i8, i8* %30, i64 4
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 8
%34 = getelementptr inbounds i8, i8* %33, i64 4
%35 = getelementptr inbounds i8, i8* %34, i64 8
%36 = bitcast i8* %35 to i32*
%37 = load i32, i32* %36
%38 = zext i32 %37 to i64
%39 = mul i64 %38, 4
%40 = getelementptr inbounds i8, i8* %31, i64 %39
%41 = bitcast i8* %40 to i8**
%42 = load i32, i32* %5
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
store i8* %45, i8** %3
br label %46
46: ; preds = %25, %13
%47 = load i8*, i8** %3
ret i8* %47
}

LLVM IR (-O2):
define i8* @get_member(i8* nocapture %0, i32 %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 20
%4 = bitcast i8* %3 to i32*
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
%7 = getelementptr inbounds i8, i8* %0, i64 28
%8 = zext i32 %1 to i64
%9 = zext i32 %5 to i64
%10 = shl nuw nsw i64 %9, 2
%11 = select i1 %6, i64 0, i64 %10
%12 = getelementptr i8, i8* %7, i64 %11
%13 = bitcast i8* %12 to i8**
%14 = getelementptr inbounds i8*, i8** %13, i64 %8
%15 = load i8*, i8** %14
ret i8* %15
}