#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 *)((int)stub + 8);
  int *ptr2 = (int *)((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,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0xc,%eax
cltq
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   %r14
push   %rbx
shl    $0x20,%rdi
movabs $0x800000000,%rbx
add    %rdi,%rbx
sar    $0x20,%rbx
movabs $0xc00000000,%r14
add    %rdi,%r14
sar    $0x20,%r14
mov    $0xff00000,%ebp
mov    (%rbx),%eax
and    %ebp,%eax
xor    %edi,%edi
cmp    $0x3000000,%eax
sete   %dil
call   1030 <assert@plt>
and    (%r14),%ebp
xor    %edi,%edi
cmp    $0x3400000,%ebp
sete   %dil
call   1030 <assert@plt>
mov    (%rbx),%eax
mov    %eax,%ecx
and    $0xfff,%ecx
shr    $0x4,%eax
and    $0xf000,%eax
or     %ecx,%eax
mov    (%r14),%ecx
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
pop    %rbx
pop    %r14
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 = ptrtoint i8* %6 to i32
%8 = add nsw i32 %7, 8
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %3
%11 = load i8*, i8** %2
%12 = ptrtoint i8* %11 to i32
%13 = add nsw i32 %12, 12
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %4
%16 = load i32*, i32** %3
%17 = load i32, i32* %16
%18 = and i32 %17, 267386880
%19 = icmp eq i32 %18, 50331648
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = and i32 %23, 267386880
%25 = icmp eq i32 %24, 54525952
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32*, i32** %3
%29 = load i32, i32* %28
%30 = and i32 %29, 4095
%31 = load i32*, i32** %3
%32 = load i32, i32* %31
%33 = ashr i32 %32, 4
%34 = and i32 %33, 61440
%35 = or i32 %30, %34
%36 = load i32*, i32** %4
%37 = load i32, i32* %36
%38 = and i32 %37, 4095
%39 = shl i32 %38, 16
%40 = or i32 %35, %39
%41 = load i32*, i32** %4
%42 = load i32, i32* %41
%43 = and i32 %42, 983040
%44 = shl i32 %43, 12
%45 = or i32 %40, %44
%46 = sext i32 %45 to i64
%47 = inttoptr i64 %46 to i32*
store i32* %47, i32** %5
%48 = load i32*, i32** %5
%49 = load i32, i32* %48
%50 = and i32 %49, 251658240
%51 = icmp eq i32 %50, 167772160
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load i32*, i32** %5
%55 = ptrtoint i32* %54 to i32
%56 = load i32*, i32** %5
%57 = load i32, i32* %56
%58 = shl i32 %57, 8
%59 = ashr i32 %58, 6
%60 = add nsw i32 %55, %59
%61 = add nsw i32 %60, 8
ret i32 %61
}

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