int GLUE_COPY_VALUE_AT_P1_TO_PTR(unsigned char *buf, void *destptr) {
  if (buf) {
    *buf++ = 0x48;
    *buf++ = 0xB9;
    *(void **)buf = destptr;
    buf += 8;
    *buf++ = 0x48;
    *buf++ = 0x8B;
    *buf++ = 0x38;
    *buf++ = 0x48;
    *buf++ = 0x89;
    *buf++ = 0x39;
  }
  return 3 + 10 + 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     11be <GLUE_COPY_VALUE_AT_P1_TO_PTR+0xbe>
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   $0xb9,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
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   $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   $0x48,(%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   $0x39,(%rax)
mov    $0x10,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GLUE_COPY_VALUE_AT_P1_TO_PTR>:
test   %rdi,%rdi
je     111b <GLUE_COPY_VALUE_AT_P1_TO_PTR+0x1b>
movw   $0xb948,(%rdi)
mov    %rsi,0x2(%rdi)
movl   $0x48388b48,0xa(%rdi)
movw   $0x3989,0xe(%rdi)
mov    $0x10,%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 %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** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
store i8 -71, i8* %10
%12 = load i8*, i8** %4
%13 = load i8*, i8** %3
%14 = bitcast i8* %13 to i8**
store i8* %12, i8** %14
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 8
store i8* %16, i8** %3
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
store i8 72, i8* %17
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
store i8 -117, i8* %19
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
store i8 56, i8* %21
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
store i8 72, i8* %23
%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 57, i8* %27
br label %29
29: ; preds = %7, %2
ret i32 16
}

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 %14, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %0, i64 1
store i8 72, i8* %0
%6 = getelementptr inbounds i8, i8* %0, i64 2
store i8 -71, i8* %5
%7 = bitcast i8* %6 to i8**
store i8* %1, i8** %7
%8 = getelementptr inbounds i8, i8* %0, i64 10
%9 = getelementptr inbounds i8, i8* %0, i64 11
store i8 72, i8* %8
%10 = getelementptr inbounds i8, i8* %0, i64 12
store i8 -117, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 13
store i8 56, i8* %10
%12 = getelementptr inbounds i8, i8* %0, i64 14
store i8 72, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 15
store i8 -119, i8* %12
store i8 57, i8* %13
br label %14
14: ; preds = %4, %2
ret i32 16
}