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

/* Variables and functions */
int /*<<< orphan*/ assert(unsigned char *);
void spy_mach_write_to_8(unsigned char *b, uint64_t data) {
  assert(b);
  b[0] = (unsigned char)(data >> 56);
  b[1] = (unsigned char)(data >> 48);
  b[2] = (unsigned char)(data >> 40);
  b[3] = (unsigned char)(data >> 32);
  b[4] = (unsigned char)(data >> 24);
  b[5] = (unsigned char)(data >> 16);
  b[6] = (unsigned char)(data >> 8);
  b[7] = (unsigned char)(data);
}


x86 assembly (clang, -O0):
<spy_mach_write_to_8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0xc(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0xc(%rbp),%eax
sar    $0x18,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x7(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spy_mach_write_to_8>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <assert@plt>
bswap  %ebx
mov    %ebx,0x4(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @spy_mach_write_to_8(i8* %0, i32 %1) {
%3 = tail call i32 @assert(i8* %0)
%4 = lshr i32 %1, 24
%5 = trunc i32 %4 to i8
%6 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %5, i8* %6
%7 = lshr i32 %1, 16
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds i8, i8* %0, i64 5
store i8 %8, i8* %9
%10 = lshr i32 %1, 8
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %11, i8* %12
%13 = trunc i32 %1 to i8
%14 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %13, i8* %14
ret void
}