#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
void sputl(long value, char *buffer) {
  uint8_t *p = (uint8_t *)buffer;
  uint32_t r = (uint32_t)value;
  *p++ = r;
  r <<= 8;
  *p++ = r;
  r <<= 8;
  *p++ = r;
  r <<= 8;
  *p = r;
}


x86 assembly (clang, -O0):
<sputl>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<sputl>:
mov    %edi,(%rsi)
mov    %edi,%eax
shl    $0x8,%eax
mov    %eax,0x4(%rsi)
mov    %edi,%eax
shl    $0x10,%eax
mov    %eax,0x8(%rsi)
shl    $0x18,%edi
mov    %edi,0xc(%rsi)
ret

LLVM IR (-O0):
define void @sputl(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i64 %0, i64* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = bitcast i8* %7 to i32*
store i32* %8, i32** %5
%9 = load i64, i64* %3
%10 = trunc i64 %9 to i32
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = load i32*, i32** %5
%13 = getelementptr inbounds i32, i32* %12, i32 1
store i32* %13, i32** %5
store i32 %11, i32* %12
%14 = load i32, i32* %6
%15 = shl i32 %14, 8
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = load i32*, i32** %5
%18 = getelementptr inbounds i32, i32* %17, i32 1
store i32* %18, i32** %5
store i32 %16, i32* %17
%19 = load i32, i32* %6
%20 = shl i32 %19, 8
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i32 1
store i32* %23, i32** %5
store i32 %21, i32* %22
%24 = load i32, i32* %6
%25 = shl i32 %24, 8
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = load i32*, i32** %5
store i32 %26, i32* %27
ret void
}

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