#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 writeHexAmountBE(int64_t amount, unsigned char *buffer) {
  *(buffer + 7) = (amount & 0xff);
  *(buffer + 6) = ((amount >> 8) & 0xff);
  *(buffer + 5) = ((amount >> 16) & 0xff);
  *(buffer + 4) = ((amount >> 24) & 0xff);
  *(buffer + 3) = ((amount >> 32) & 0xff);
  *(buffer + 2) = ((amount >> 40) & 0xff);
  *(buffer + 1) = ((amount >> 48) & 0xff);
  *(buffer) = ((amount >> 56) & 0xff);
}


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

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

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

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