#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 len;

/* Variables and functions */
int /*<<< orphan*/ memcpy(long *, char *, int);
long C_string_aligned8(long **ptr, int len, char *str) {
  long *p = *ptr, *p0;
  p0 = p;
  *ptr = p + 1 + (((len) + 7) >> 3);
  *(p++) =
      (0x0200000000000000L | 0x4000000000000000L) | 0x1000000000000000L | len;
  memcpy(p, str, len);
  return (long)p0;
}


x86 assembly (clang, -O0):
<C_string_aligned8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rcx
add    $0x8,%rcx
mov    -0xc(%rbp),%eax
add    $0x7,%eax
sar    $0x3,%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movslq -0xc(%rbp),%rcx
movabs $0x5200000000000000,%rax
or     %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<C_string_aligned8>:
push   %rbx
mov    (%rdi),%rbx
lea    0x8(%rbx),%rax
lea    0x7(%rsi),%ecx
sar    $0x3,%ecx
movslq %ecx,%rcx
lea    (%rbx,%rcx,8),%rcx
add    $0x8,%rcx
mov    %rcx,(%rdi)
movslq %esi,%rcx
movabs $0x5200000000000000,%rsi
or     %rcx,%rsi
mov    %rsi,(%rbx)
mov    %rax,%rdi
mov    %rdx,%rsi
mov    %ecx,%edx
call   1030 <memcpy@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @C_string_aligned8(i64** %0, i32 %1, i8* %2) {
%4 = alloca i64**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i64*
store i64** %0, i64*** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i64**, i64*** %4
%10 = load i64*, i64** %9
store i64* %10, i64** %7
%11 = load i64*, i64** %7
store i64* %11, i64** %8
%12 = load i64*, i64** %7
%13 = getelementptr inbounds i64, i64* %12, i64 1
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 7
%16 = ashr i32 %15, 3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i64, i64* %13, i64 %17
%19 = load i64**, i64*** %4
store i64* %18, i64** %19
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = or i64 5908722711110090752, %21
%23 = load i64*, i64** %7
%24 = getelementptr inbounds i64, i64* %23, i32 1
store i64* %24, i64** %7
store i64 %22, i64* %23
%25 = load i64*, i64** %7
%26 = load i8*, i8** %6
%27 = load i32, i32* %5
%28 = call i32 @memcpy(i64* %25, i8* %26, i32 %27)
%29 = load i64*, i64** %8
%30 = ptrtoint i64* %29 to i64
ret i64 %30
}

LLVM IR (-O2):
define i64 @C_string_aligned8(i64** nocapture %0, i32 %1, i8* %2) {
%4 = load i64*, i64** %0
%5 = getelementptr inbounds i64, i64* %4, i64 1
%6 = add nsw i32 %1, 7
%7 = ashr i32 %6, 3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i64, i64* %5, i64 %8
store i64* %9, i64** %0
%10 = sext i32 %1 to i64
%11 = or i64 %10, 5908722711110090752
store i64 %11, i64* %4
%12 = tail call i32 @memcpy(i64* %5, i8* %2, i32 %1)
%13 = ptrtoint i64* %4 to i64
ret i64 %13
}