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


x86 assembly (clang, -O0):
<writeHexAmount>:
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,(%rax)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x4(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x4(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x4(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x4(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x7(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeHexAmount>:
mov    %edi,(%rsi)
ret

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

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