#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 /*<<< orphan*/ uint_least32_t;
typedef int /*<<< orphan*/ uint_least16_t;
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ endian_16hi8(int /*<<< orphan*/);
int /*<<< orphan*/ endian_16lo8(int /*<<< orphan*/);
int /*<<< orphan*/ endian_32hi16(int /*<<< orphan*/);
int /*<<< orphan*/ endian_32hi8(int /*<<< orphan*/);
int /*<<< orphan*/ endian_32lo8(int /*<<< orphan*/);
void endian_little32(uint8_t ptr[4], uint_least32_t dword) {
  uint_least16_t word = 0;
  ptr[0] = endian_32lo8(dword);
  ptr[1] = endian_32hi8(dword);
  word = endian_32hi16(dword);
  ptr[2] = endian_16lo8(word);
  ptr[3] = endian_16hi8(word);
}


x86 assembly (clang, -O0):
<endian_little32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <endian_32lo8@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%edi
call   1040 <endian_32hi8@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%edi
call   1070 <endian_32hi16@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <endian_16lo8@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%edi
call   1060 <endian_16hi8@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<endian_little32>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    %esi,%edi
call   1050 <endian_32lo8@plt>
mov    %eax,(%r14)
mov    %ebx,%edi
call   1040 <endian_32hi8@plt>
mov    %eax,0x4(%r14)
mov    %ebx,%edi
call   1070 <endian_32hi16@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <endian_16lo8@plt>
mov    %eax,0x8(%r14)
mov    %ebx,%edi
call   1060 <endian_16hi8@plt>
mov    %eax,0xc(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @endian_little32(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %4
%7 = call i32 @endian_32lo8(i32 %6)
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i64 0
store i32 %7, i32* %9
%10 = load i32, i32* %4
%11 = call i32 @endian_32hi8(i32 %10)
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32 %11, i32* %13
%14 = load i32, i32* %4
%15 = call i32 @endian_32hi16(i32 %14)
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = call i32 @endian_16lo8(i32 %16)
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 2
store i32 %17, i32* %19
%20 = load i32, i32* %5
%21 = call i32 @endian_16hi8(i32 %20)
%22 = load i32*, i32** %3
%23 = getelementptr inbounds i32, i32* %22, i64 3
store i32 %21, i32* %23
ret void
}

LLVM IR (-O2):
define void @endian_little32(i32* nocapture writeonly %0, i32 %1) {
%3 = tail call i32 @endian_32lo8(i32 %1)
store i32 %3, i32* %0
%4 = tail call i32 @endian_32hi8(i32 %1)
%5 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %4, i32* %5
%6 = tail call i32 @endian_32hi16(i32 %1)
%7 = tail call i32 @endian_16lo8(i32 %6)
%8 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %7, i32* %8
%9 = tail call i32 @endian_16hi8(i32 %6)
%10 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %9, i32* %10
ret void
}