#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 */

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int swap8(unsigned char *d) {
  unsigned char t[8];
  memcpy(t, d, 8);
  d[0] = t[7];
  d[1] = t[6];
  d[2] = t[5];
  d[3] = t[4];
  d[4] = t[3];
  d[5] = t[2];
  d[6] = t[1];
  d[7] = t[0];
  return 0;
}


x86 assembly (clang, -O0):
<swap8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0x9(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0xa(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0xb(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0xc(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0xd(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0xe(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0xf(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x10(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x7(%rax)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap8>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    0xf(%rsp),%al
mov    %al,(%rbx)
mov    0xe(%rsp),%al
mov    %al,0x1(%rbx)
mov    0xd(%rsp),%al
mov    %al,0x2(%rbx)
mov    0xc(%rsp),%al
mov    %al,0x3(%rbx)
mov    0xb(%rsp),%al
mov    %al,0x4(%rbx)
mov    0xa(%rsp),%al
mov    %al,0x5(%rbx)
mov    0x9(%rsp),%al
mov    %al,0x6(%rbx)
mov    0x8(%rsp),%al
mov    %al,0x7(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @swap8(i8* %0) {
%2 = alloca i8*
%3 = alloca [8 x i8]
store i8* %0, i8** %2
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %2
%6 = call i32 @memcpy(i8* %4, i8* %5, i32 8)
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 7
%8 = load i8, i8* %7
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 0
store i8 %8, i8* %10
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 6
%12 = load i8, i8* %11
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %12, i8* %14
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 5
%16 = load i8, i8* %15
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 2
store i8 %16, i8* %18
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 4
%20 = load i8, i8* %19
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 3
store i8 %20, i8* %22
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 3
%24 = load i8, i8* %23
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 4
store i8 %24, i8* %26
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 2
%28 = load i8, i8* %27
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 5
store i8 %28, i8* %30
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
%32 = load i8, i8* %31
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i64 6
store i8 %32, i8* %34
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%36 = load i8, i8* %35
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i64 7
store i8 %36, i8* %38
ret i32 0
}

LLVM IR (-O2):
define i32 @swap8(i8* %0) {
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%4 = call i32 @memcpy(i8* %3, i8* %0, i32 8)
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 7
%6 = load i8, i8* %5
store i8 %6, i8* %0
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 6
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %8, i8* %9
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 5
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %11, i8* %12
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 4
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %14, i8* %15
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 3
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %17, i8* %18
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 2
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %20, i8* %21
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 1
%23 = load i8, i8* %22
%24 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %23, i8* %24
%25 = load i8, i8* %3
%26 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %25, i8* %26
ret i32 0
}