#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*/ sig;

/* Variables and functions */
scalar_t__ memcmp(unsigned char *, unsigned char const *, int);
void *GLUE_realAddress(void *fn, void *fn_e, int *size) {
  static const unsigned char sig[12] = {0x89, 0x90, 0x90, 0x90, 0x90, 0x90,
                                        0x90, 0x90, 0x90, 0x90, 0x90, 0x90};
  unsigned char *p = (unsigned char *)fn;
  while (memcmp(p, sig, sizeof(sig)))
    p++;
  p += sizeof(sig);
  fn = p;
  while (memcmp(p, sig, sizeof(sig)))
    p++;
  *size = p - (unsigned char *)fn;
  return fn;
}


x86 assembly (clang, -O0):
<GLUE_realAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0xc,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     115c <GLUE_realAddress+0x4c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <GLUE_realAddress+0x1c>
mov    -0x20(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe85(%rip),%rsi
mov    $0xc,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     11a0 <GLUE_realAddress+0x90>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1170 <GLUE_realAddress+0x60>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GLUE_realAddress>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rdi,%r12
lea    0xedb(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1030 <memcmp@plt>
add    $0x1,%r12
test   %rax,%rax
jne    1130 <GLUE_realAddress+0x20>
add    $0xb,%r12
mov    $0xffffffff,%ebp
lea    0xea7(%rip),%r15
mov    %r12,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0xc,%edx
call   1030 <memcmp@plt>
add    $0x1,%rbx
add    $0x1,%ebp
test   %rax,%rax
jne    1160 <GLUE_realAddress+0x50>
mov    %ebp,(%r14)
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GLUE_realAddress.sig = internal constant [12 x i8] c"\89\90\90\90\90\90\90\90\90\90\90\90"
define i8* @GLUE_realAddress(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
br label %9
9: ; preds = %13, %3
%10 = load i8*, i8** %7
%11 = call i64 @memcmp(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @GLUE_realAddress.sig, i64 0, i64 0), i32 12)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %7
br label %9
16: ; preds = %9
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i64 12
store i8* %18, i8** %7
%19 = load i8*, i8** %7
store i8* %19, i8** %4
br label %20
20: ; preds = %24, %16
%21 = load i8*, i8** %7
%22 = call i64 @memcmp(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @GLUE_realAddress.sig, i64 0, i64 0), i32 12)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %7
br label %20
27: ; preds = %20
%28 = load i8*, i8** %7
%29 = load i8*, i8** %4
%30 = ptrtoint i8* %28 to i64
%31 = ptrtoint i8* %29 to i64
%32 = sub i64 %30, %31
%33 = trunc i64 %32 to i32
%34 = load i32*, i32** %6
store i32 %33, i32* %34
%35 = load i8*, i8** %4
ret i8* %35
}

LLVM IR (-O2):
@GLUE_realAddress.sig = internal constant [12 x i8] c"\89\90\90\90\90\90\90\90\90\90\90\90"
define i8* @GLUE_realAddress(i8* %0, i8* nocapture readnone %1, i32* nocapture writeonly %2) {
br label %4
4: ; preds = %4, %3
%5 = phi i8* [ %0, %3 ], [ %8, %4 ]
%6 = tail call i64 @memcmp(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @GLUE_realAddress.sig, i64 0, i64 0), i32 12)
%7 = icmp eq i64 %6, 0
%8 = getelementptr inbounds i8, i8* %5, i64 1
br i1 %7, label %9, label %4
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %5, i64 12
br label %11
11: ; preds = %11, %9
%12 = phi i8* [ %10, %9 ], [ %15, %11 ]
%13 = tail call i64 @memcmp(i8* %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @GLUE_realAddress.sig, i64 0, i64 0), i32 12)
%14 = icmp eq i64 %13, 0
%15 = getelementptr inbounds i8, i8* %12, i64 1
br i1 %14, label %16, label %11
16: ; preds = %11
%17 = ptrtoint i8* %12 to i64
%18 = ptrtoint i8* %10 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
store i32 %20, i32* %2
ret i8* %10
}