#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 scalar_t__ value;

/* Variables and functions */
int write_raw_byte(char, void *, int);
int write_raw_little_endian64(unsigned long long value, void *_buffer,
                              int offset) {
  offset = write_raw_byte((char)((value)&0xFF), _buffer, offset);
  offset = write_raw_byte((char)((value >> 8) & 0xFF), _buffer, offset);
  offset = write_raw_byte((char)((value >> 16) & 0xFF), _buffer, offset);
  offset = write_raw_byte((char)((value >> 24) & 0xFF), _buffer, offset);
  offset = write_raw_byte((char)((value >> 32) & 0xFF), _buffer, offset);
  offset = write_raw_byte((char)((value >> 40) & 0xFF), _buffer, offset);
  offset = write_raw_byte((char)((value >> 48) & 0xFF), _buffer, offset);
  offset = write_raw_byte((char)((value >> 56) & 0xFF), _buffer, offset);
  return offset;
}


x86 assembly (clang, -O0):
<write_raw_little_endian64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl %al,%edi
call   1030 <write_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl %al,%edi
call   1030 <write_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl %al,%edi
call   1030 <write_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl %al,%edi
call   1030 <write_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x20,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl %al,%edi
call   1030 <write_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x28,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl %al,%edi
call   1030 <write_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x30,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl %al,%edi
call   1030 <write_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x38,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsbl %al,%edi
call   1030 <write_raw_byte@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_raw_little_endian64>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl %bl,%edi
call   1030 <write_raw_byte@plt>
mov    %ebx,%ecx
shr    $0x8,%ecx
movsbl %cl,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_raw_byte@plt>
mov    %ebx,%ecx
shr    $0x10,%ecx
movsbl %cl,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_raw_byte@plt>
mov    %ebx,%edi
sar    $0x18,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_raw_byte@plt>
mov    %rbx,%rcx
shr    $0x20,%rcx
movsbl %cl,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_raw_byte@plt>
mov    %rbx,%rcx
shr    $0x28,%rcx
movsbl %cl,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_raw_byte@plt>
mov    %rbx,%rcx
shr    $0x30,%rcx
movsbl %cl,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_raw_byte@plt>
shr    $0x38,%rbx
movsbl %bl,%edi
mov    %r14,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <write_raw_byte@plt>

LLVM IR (-O0):
define i32 @write_raw_little_endian64(i64 %0, i8* %1, i32 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
store i64 %0, i64* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i64, i64* %4
%8 = and i64 %7, 255
%9 = trunc i64 %8 to i8
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = call i32 @write_raw_byte(i8 signext %9, i8* %10, i32 %11)
store i32 %12, i32* %6
%13 = load i64, i64* %4
%14 = lshr i64 %13, 8
%15 = and i64 %14, 255
%16 = trunc i64 %15 to i8
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = call i32 @write_raw_byte(i8 signext %16, i8* %17, i32 %18)
store i32 %19, i32* %6
%20 = load i64, i64* %4
%21 = lshr i64 %20, 16
%22 = and i64 %21, 255
%23 = trunc i64 %22 to i8
%24 = load i8*, i8** %5
%25 = load i32, i32* %6
%26 = call i32 @write_raw_byte(i8 signext %23, i8* %24, i32 %25)
store i32 %26, i32* %6
%27 = load i64, i64* %4
%28 = lshr i64 %27, 24
%29 = and i64 %28, 255
%30 = trunc i64 %29 to i8
%31 = load i8*, i8** %5
%32 = load i32, i32* %6
%33 = call i32 @write_raw_byte(i8 signext %30, i8* %31, i32 %32)
store i32 %33, i32* %6
%34 = load i64, i64* %4
%35 = lshr i64 %34, 32
%36 = and i64 %35, 255
%37 = trunc i64 %36 to i8
%38 = load i8*, i8** %5
%39 = load i32, i32* %6
%40 = call i32 @write_raw_byte(i8 signext %37, i8* %38, i32 %39)
store i32 %40, i32* %6
%41 = load i64, i64* %4
%42 = lshr i64 %41, 40
%43 = and i64 %42, 255
%44 = trunc i64 %43 to i8
%45 = load i8*, i8** %5
%46 = load i32, i32* %6
%47 = call i32 @write_raw_byte(i8 signext %44, i8* %45, i32 %46)
store i32 %47, i32* %6
%48 = load i64, i64* %4
%49 = lshr i64 %48, 48
%50 = and i64 %49, 255
%51 = trunc i64 %50 to i8
%52 = load i8*, i8** %5
%53 = load i32, i32* %6
%54 = call i32 @write_raw_byte(i8 signext %51, i8* %52, i32 %53)
store i32 %54, i32* %6
%55 = load i64, i64* %4
%56 = lshr i64 %55, 56
%57 = and i64 %56, 255
%58 = trunc i64 %57 to i8
%59 = load i8*, i8** %5
%60 = load i32, i32* %6
%61 = call i32 @write_raw_byte(i8 signext %58, i8* %59, i32 %60)
store i32 %61, i32* %6
%62 = load i32, i32* %6
ret i32 %62
}

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