int GLUE_POP_VALUE_TO_ADDR(unsigned char *buf, void *destptr) {
  if (buf) {
    *buf++ = 0xB8;
    *(void **)buf = destptr;
    buf += 4;
    *buf++ = 0x8f;
    *buf++ = 0x00;
    *buf++ = 0x8f;
    *buf++ = 0x40;
    *buf++ = 4;
    *buf++ = 0x59;
    *buf++ = 0x59;
  }
  return 12;
}


x86 assembly (clang, -O0):
<GLUE_POP_VALUE_TO_ADDR>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11be <GLUE_POP_VALUE_TO_ADDR+0xbe>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0xb8,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x8f,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x8f,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x40,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x4,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x59,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x59,(%rax)
mov    $0xc,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GLUE_POP_VALUE_TO_ADDR>:
test   %rdi,%rdi
je     111d <GLUE_POP_VALUE_TO_ADDR+0x1d>
movb   $0xb8,(%rdi)
mov    %rsi,0x1(%rdi)
movl   $0x408f008f,0x5(%rdi)
movw   $0x5904,0x9(%rdi)
movb   $0x59,0xb(%rdi)
mov    $0xc,%eax
ret

LLVM IR (-O0):
define i32 @GLUE_POP_VALUE_TO_ADDR(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %29
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
store i8 -72, i8* %8
%10 = load i8*, i8** %4
%11 = load i8*, i8** %3
%12 = bitcast i8* %11 to i8**
store i8* %10, i8** %12
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 4
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
store i8 -113, i8* %15
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
store i8 0, i8* %17
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
store i8 -113, i8* %19
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
store i8 64, i8* %21
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
store i8 4, i8* %23
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
store i8 89, i8* %25
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
store i8 89, i8* %27
br label %29
29: ; preds = %7, %2
ret i32 12
}

LLVM IR (-O2):
define i32 @GLUE_POP_VALUE_TO_ADDR(i8* writeonly %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %0, i64 1
store i8 -72, i8* %0
%6 = bitcast i8* %5 to i8**
store i8* %1, i8** %6
%7 = getelementptr inbounds i8, i8* %0, i64 5
%8 = getelementptr inbounds i8, i8* %0, i64 6
store i8 -113, i8* %7
%9 = getelementptr inbounds i8, i8* %0, i64 7
store i8 0, i8* %8
%10 = getelementptr inbounds i8, i8* %0, i64 8
store i8 -113, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 9
store i8 64, i8* %10
%12 = getelementptr inbounds i8, i8* %0, i64 10
store i8 4, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 11
store i8 89, i8* %12
store i8 89, i8* %13
br label %14
14: ; preds = %4, %2
ret i32 12
}