#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 */
int /*<<< orphan*/ assert(int);
int get_pointer(void *stub) {
  int *ptr = (int *)(stub + 8);
  int *ptr2 = (int *)(stub + 12);
  assert((*ptr & 0x0ff00000) == 0x03000000);
  assert((*ptr2 & 0x0ff00000) == 0x03400000);
  int *i_ptr = (int *)((*ptr & 0xfff) | ((*ptr >> 4) & 0xf000) |
                       ((*ptr2 & 0xfff) << 16) | ((*ptr2 & 0xf0000) << 12));
  assert((*i_ptr & 0x0f000000) == 0x0a000000);
  return (int)i_ptr + ((*i_ptr << 8) >> 6) + 8;
}


x86 assembly (clang, -O0):
<get_pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0xff00000,%eax
cmp    $0x3000000,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
and    $0xff00000,%eax
cmp    $0x3400000,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0xfff,%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sar    $0x4,%ecx
and    $0xf000,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
and    $0xfff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
and    $0xf0000,%ecx
shl    $0xc,%ecx
or     %ecx,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
and    $0xf000000,%eax
cmp    $0xa000000,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x20(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
shl    $0x8,%ecx
sar    $0x6,%ecx
add    %ecx,%eax
add    $0x8,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pointer>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0xff00000,%ebp
mov    0x8(%rdi),%eax
and    %ebp,%eax
xor    %edi,%edi
cmp    $0x3000000,%eax
sete   %dil
call   1030 <assert@plt>
and    0xc(%rbx),%ebp
xor    %edi,%edi
cmp    $0x3400000,%ebp
sete   %dil
call   1030 <assert@plt>
mov    0x8(%rbx),%eax
mov    0xc(%rbx),%ecx
mov    %eax,%edx
and    $0xfff,%edx
shr    $0x4,%eax
and    $0xf000,%eax
or     %edx,%eax
mov    %ecx,%edx
shl    $0x10,%edx
and    $0xfff0000,%edx
or     %eax,%edx
shl    $0xc,%ecx
and    $0xf0000000,%ecx
or     %edx,%ecx
movslq %ecx,%rbx
mov    $0xf000000,%eax
and    (%rbx),%eax
xor    %edi,%edi
cmp    $0xa000000,%eax
sete   %dil
call   1030 <assert@plt>
mov    (%rbx),%eax
shl    $0x8,%eax
sar    $0x6,%eax
add    %ebx,%eax
add    $0x8,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_pointer(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = getelementptr i8, i8* %6, i64 8
%8 = bitcast i8* %7 to i32*
store i32* %8, i32** %3
%9 = load i8*, i8** %2
%10 = getelementptr i8, i8* %9, i64 12
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %4
%12 = load i32*, i32** %3
%13 = load i32, i32* %12
%14 = and i32 %13, 267386880
%15 = icmp eq i32 %14, 50331648
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = and i32 %19, 267386880
%21 = icmp eq i32 %20, 54525952
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i32*, i32** %3
%25 = load i32, i32* %24
%26 = and i32 %25, 4095
%27 = load i32*, i32** %3
%28 = load i32, i32* %27
%29 = ashr i32 %28, 4
%30 = and i32 %29, 61440
%31 = or i32 %26, %30
%32 = load i32*, i32** %4
%33 = load i32, i32* %32
%34 = and i32 %33, 4095
%35 = shl i32 %34, 16
%36 = or i32 %31, %35
%37 = load i32*, i32** %4
%38 = load i32, i32* %37
%39 = and i32 %38, 983040
%40 = shl i32 %39, 12
%41 = or i32 %36, %40
%42 = sext i32 %41 to i64
%43 = inttoptr i64 %42 to i32*
store i32* %43, i32** %5
%44 = load i32*, i32** %5
%45 = load i32, i32* %44
%46 = and i32 %45, 251658240
%47 = icmp eq i32 %46, 167772160
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i32*, i32** %5
%51 = ptrtoint i32* %50 to i32
%52 = load i32*, i32** %5
%53 = load i32, i32* %52
%54 = shl i32 %53, 8
%55 = ashr i32 %54, 6
%56 = add nsw i32 %51, %55
%57 = add nsw i32 %56, 8
ret i32 %57
}

LLVM IR (-O2):
define i32 @get_pointer(i8* nocapture %0) {
%2 = getelementptr i8, i8* %0, i64 8
%3 = bitcast i8* %2 to i32*
%4 = getelementptr i8, i8* %0, i64 12
%5 = bitcast i8* %4 to i32*
%6 = load i32, i32* %3
%7 = and i32 %6, 267386880
%8 = icmp eq i32 %7, 50331648
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = load i32, i32* %5
%12 = and i32 %11, 267386880
%13 = icmp eq i32 %12, 54525952
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = load i32, i32* %3
%17 = and i32 %16, 4095
%18 = lshr i32 %16, 4
%19 = and i32 %18, 61440
%20 = or i32 %19, %17
%21 = load i32, i32* %5
%22 = shl i32 %21, 16
%23 = and i32 %22, 268369920
%24 = or i32 %20, %23
%25 = shl i32 %21, 12
%26 = and i32 %25, -268435456
%27 = or i32 %24, %26
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i32*
%30 = load i32, i32* %29
%31 = and i32 %30, 251658240
%32 = icmp eq i32 %31, 167772160
%33 = zext i1 %32 to i32
%34 = tail call i32 @assert(i32 %33)
%35 = load i32, i32* %29
%36 = shl i32 %35, 8
%37 = ashr exact i32 %36, 6
%38 = add i32 %27, 8
%39 = add i32 %38, %37
ret i32 %39
}