#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*/);
int /*<<< orphan*/ endian_16lo8(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ endian_32hi16(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ endian_32hi8(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ endian_32lo8(int /*<<< orphan*/, int /*<<< orphan*/);
uint_least32_t endian_32(uint8_t hihi, uint8_t hilo, uint8_t hi, uint8_t lo) {
  uint_least32_t dword = 0;
  uint_least16_t word = 0;
  endian_32lo8(dword, lo);
  endian_32hi8(dword, hi);
  endian_16lo8(word, hilo);
  endian_16hi8(word, hihi);
  endian_32hi16(dword, word);
  return dword;
}


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

x86 assembly (clang, -O2):
<endian_32>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%ebp
mov    %edi,%r14d
xor    %edi,%edi
mov    %ecx,%esi
call   1050 <endian_32lo8@plt>
xor    %edi,%edi
mov    %ebx,%esi
call   1040 <endian_32hi8@plt>
xor    %edi,%edi
mov    %ebp,%esi
call   1030 <endian_16lo8@plt>
xor    %edi,%edi
mov    %r14d,%esi
call   1060 <endian_16hi8@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1070 <endian_32hi16@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @endian_32(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @endian_32lo8(i32 0, i32 %3)
%6 = tail call i32 @endian_32hi8(i32 0, i32 %2)
%7 = tail call i32 @endian_16lo8(i32 0, i32 %1)
%8 = tail call i32 @endian_16hi8(i32 0, i32 %0)
%9 = tail call i32 @endian_32hi16(i32 0, i32 0)
ret i32 0
}