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

/* Variables and functions */
void long2buff(int64_t n, char *buff) {
  unsigned char *p;
  p = (unsigned char *)buff;
  *p++ = (n >> 56) & 0xFF;
  *p++ = (n >> 48) & 0xFF;
  *p++ = (n >> 40) & 0xFF;
  *p++ = (n >> 32) & 0xFF;
  *p++ = (n >> 24) & 0xFF;
  *p++ = (n >> 16) & 0xFF;
  *p++ = (n >> 8) & 0xFF;
  *p++ = n & 0xFF;
}


x86 assembly (clang, -O0):
<long2buff>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<long2buff>:
bswap  %edi
mov    %edi,0x4(%rsi)
ret

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

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