int GLUE_COPY_VALUE_AT_P1_TO_PTR(unsigned char *buf, void *destptr) {
  if (buf) {
    *buf++ = 0x8B;
    *buf++ = 0x38;
    *buf++ = 0x8B;
    *buf++ = 0x48;
    *buf++ = 0x04;
    *buf++ = 0xB8;
    *(void **)buf = destptr;
    buf += 4;
    *buf++ = 0x89;
    *buf++ = 0x38;
    *buf++ = 0x89;
    *buf++ = 0x48;
    *buf++ = 0x04;
  }
  return 2 + 3 + 5 + 2 + 3;
}


x86 assembly (clang, -O0):
<GLUE_COPY_VALUE_AT_P1_TO_PTR>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11f4 <GLUE_COPY_VALUE_AT_P1_TO_PTR+0xf4>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x8b,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x38,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x8b,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x48,(%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   $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   $0x89,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x38,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x89,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x48,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x4,(%rax)
mov    $0xf,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GLUE_COPY_VALUE_AT_P1_TO_PTR>:
test   %rdi,%rdi
je     1120 <GLUE_COPY_VALUE_AT_P1_TO_PTR+0x20>
movl   $0x488b388b,(%rdi)
movw   $0xb804,0x4(%rdi)
mov    %rsi,0x6(%rdi)
movl   $0x48893889,0xa(%rdi)
movb   $0x4,0xe(%rdi)
mov    $0xf,%eax
ret

LLVM IR (-O0):
define i32 @GLUE_COPY_VALUE_AT_P1_TO_PTR(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 %35
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
store i8 -117, i8* %8
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
store i8 56, i8* %10
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %3
store i8 -117, i8* %12
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %3
store i8 72, i8* %14
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %3
store i8 4, i8* %16
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
store i8 -72, i8* %18
%20 = load i8*, i8** %4
%21 = load i8*, i8** %3
%22 = bitcast i8* %21 to i8**
store i8* %20, i8** %22
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 4
store i8* %24, i8** %3
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
store i8 -119, i8* %25
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
store i8 56, i8* %27
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %3
store i8 -119, i8* %29
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
store i8 72, i8* %31
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
store i8 4, i8* %33
br label %35
35: ; preds = %7, %2
ret i32 15
}

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