#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 unsigned char uint8_t;

/* Variables and functions */
void swap64(const uint8_t *buffer, void *out) {
  unsigned char *ptr = (unsigned char *)out;
  ptr[0] = buffer[7];
  ptr[1] = buffer[6];
  ptr[2] = buffer[5];
  ptr[3] = buffer[4];
  ptr[4] = buffer[3];
  ptr[5] = buffer[2];
  ptr[6] = buffer[1];
  ptr[7] = buffer[0];
}


x86 assembly (clang, -O0):
<swap64>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x7(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
mov    0x6(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%rax
mov    0x5(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x8(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x7(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap64>:
mov    0x7(%rdi),%al
mov    %al,(%rsi)
mov    0x6(%rdi),%al
mov    %al,0x1(%rsi)
mov    0x5(%rdi),%al
mov    %al,0x2(%rsi)
mov    0x4(%rdi),%al
mov    %al,0x3(%rsi)
mov    0x3(%rdi),%al
mov    %al,0x4(%rsi)
mov    0x2(%rdi),%al
mov    %al,0x5(%rsi)
mov    0x1(%rdi),%al
mov    %al,0x6(%rsi)
mov    (%rdi),%al
mov    %al,0x7(%rsi)
ret

LLVM IR (-O0):
define void @swap64(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
store i8* %6, i8** %5
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 7
%9 = load i8, i8* %8
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 %9, i8* %11
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 6
%14 = load i8, i8* %13
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %14, i8* %16
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 5
%19 = load i8, i8* %18
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 2
store i8 %19, i8* %21
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 4
%24 = load i8, i8* %23
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i64 3
store i8 %24, i8* %26
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = load i8, i8* %28
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 4
store i8 %29, i8* %31
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 2
%34 = load i8, i8* %33
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 5
store i8 %34, i8* %36
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 6
store i8 %39, i8* %41
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 0
%44 = load i8, i8* %43
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i64 7
store i8 %44, i8* %46
ret void
}

LLVM IR (-O2):
define void @swap64(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 7
%4 = load i8, i8* %3
store i8 %4, i8* %1
%5 = getelementptr inbounds i8, i8* %0, i64 6
%6 = load i8, i8* %5
%7 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %6, i8* %7
%8 = getelementptr inbounds i8, i8* %0, i64 5
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %9, i8* %10
%11 = getelementptr inbounds i8, i8* %0, i64 4
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %12, i8* %13
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %0, i64 2
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %18, i8* %19
%20 = getelementptr inbounds i8, i8* %0, i64 1
%21 = load i8, i8* %20
%22 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %21, i8* %22
%23 = load i8, i8* %0
%24 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %23, i8* %24
ret void
}