#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*/ memset(unsigned char *, int /*<<< orphan*/, int);
void int64_to_byte(long long i, unsigned char *bytes) {
  int size = 8;
  memset(bytes, 0, sizeof(unsigned char) * size);
  bytes[0] = (unsigned char)(0xff & i);
  bytes[1] = (unsigned char)((0xff00 & i) >> 8);
  bytes[2] = (unsigned char)((0xff0000 & i) >> 16);
  bytes[3] = (unsigned char)((0xff000000 & i) >> 24);
  bytes[4] = (unsigned char)((0xff00000000 & i) >> 32);
  bytes[5] = (unsigned char)((0xff0000000000 & i) >> 40);
  bytes[6] = (unsigned char)((0xff000000000000 & i) >> 48);
  bytes[7] = (unsigned char)((0xff00000000000000 & i) >> 56);
}


x86 assembly (clang, -O0):
<int64_to_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x8,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
and    $0xff00,%rax
sar    $0x8,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%rax
and    $0xff0000,%rax
sar    $0x10,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
movabs $0xff000000,%rax
and    -0x8(%rbp),%rax
sar    $0x18,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
movabs $0xff00000000,%rax
and    -0x8(%rbp),%rax
sar    $0x20,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
movabs $0xff0000000000,%rax
and    -0x8(%rbp),%rax
sar    $0x28,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
movabs $0xff000000000000,%rax
and    -0x8(%rbp),%rax
sar    $0x30,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
movabs $0xff00000000000000,%rax
and    -0x8(%rbp),%rax
shr    $0x38,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x7(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int64_to_byte>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    %r14,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @int64_to_byte(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
store i64 %0, i64* %3
store i8* %1, i8** %4
store i32 8, i32* %5
%6 = load i8*, i8** %4
%7 = load i32, i32* %5
%8 = sext i32 %7 to i64
%9 = mul i64 1, %8
%10 = trunc i64 %9 to i32
%11 = call i32 @memset(i8* %6, i32 0, i32 %10)
%12 = load i64, i64* %3
%13 = and i64 255, %12
%14 = trunc i64 %13 to i8
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 %14, i8* %16
%17 = load i64, i64* %3
%18 = and i64 65280, %17
%19 = ashr i64 %18, 8
%20 = trunc i64 %19 to i8
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8 %20, i8* %22
%23 = load i64, i64* %3
%24 = and i64 16711680, %23
%25 = ashr i64 %24, 16
%26 = trunc i64 %25 to i8
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8 %26, i8* %28
%29 = load i64, i64* %3
%30 = and i64 4278190080, %29
%31 = ashr i64 %30, 24
%32 = trunc i64 %31 to i8
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 3
store i8 %32, i8* %34
%35 = load i64, i64* %3
%36 = and i64 1095216660480, %35
%37 = ashr i64 %36, 32
%38 = trunc i64 %37 to i8
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 4
store i8 %38, i8* %40
%41 = load i64, i64* %3
%42 = and i64 280375465082880, %41
%43 = ashr i64 %42, 40
%44 = trunc i64 %43 to i8
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 5
store i8 %44, i8* %46
%47 = load i64, i64* %3
%48 = and i64 71776119061217280, %47
%49 = ashr i64 %48, 48
%50 = trunc i64 %49 to i8
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i64 6
store i8 %50, i8* %52
%53 = load i64, i64* %3
%54 = and i64 -72057594037927936, %53
%55 = lshr i64 %54, 56
%56 = trunc i64 %55 to i8
%57 = load i8*, i8** %4
%58 = getelementptr inbounds i8, i8* %57, i64 7
store i8 %56, i8* %58
ret void
}

LLVM IR (-O2):
define void @int64_to_byte(i64 %0, i8* %1) {
%3 = tail call i32 @memset(i8* %1, i32 0, i32 8)
%4 = trunc i64 %0 to i8
store i8 %4, i8* %1
%5 = lshr i64 %0, 8
%6 = trunc i64 %5 to i8
%7 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %6, i8* %7
%8 = lshr i64 %0, 16
%9 = trunc i64 %8 to i8
%10 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %9, i8* %10
%11 = lshr i64 %0, 24
%12 = trunc i64 %11 to i8
%13 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %12, i8* %13
%14 = lshr i64 %0, 32
%15 = trunc i64 %14 to i8
%16 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %15, i8* %16
%17 = lshr i64 %0, 40
%18 = trunc i64 %17 to i8
%19 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %18, i8* %19
%20 = lshr i64 %0, 48
%21 = trunc i64 %20 to i8
%22 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %21, i8* %22
%23 = lshr i64 %0, 56
%24 = trunc i64 %23 to i8
%25 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %24, i8* %25
ret void
}