#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 u_int8_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int *);
unsigned long little_endian_32(u_int8_t *buffer) {
  register unsigned long retval;
  assert(buffer);
  retval = buffer[0];
  retval += buffer[1] << 8;
  retval += buffer[2] << 16;
  retval += buffer[3] << 24;
  return retval;
}


x86 assembly (clang, -O0):
<little_endian_32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
movslq (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x8,%eax
cltq
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
shl    $0x10,%eax
cltq
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%eax
shl    $0x18,%eax
cltq
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<little_endian_32>:
push   %rbx
mov    %rdi,%rbx
call   1030 <assert@plt>
movslq (%rbx),%rax
mov    0x4(%rbx),%ecx
mov    0x8(%rbx),%edx
shl    $0x8,%ecx
movslq %ecx,%rcx
add    %rax,%rcx
shl    $0x10,%edx
movslq %edx,%rdx
add    %rcx,%rdx
mov    0xc(%rbx),%eax
shl    $0x18,%eax
cltq
add    %rdx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @little_endian_32(i32* %0) {
%2 = alloca i32*
%3 = alloca i64
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @assert(i32* %4)
%6 = load i32*, i32** %2
%7 = getelementptr inbounds i32, i32* %6, i64 0
%8 = load i32, i32* %7
%9 = sext i32 %8 to i64
store i64 %9, i64* %3
%10 = load i32*, i32** %2
%11 = getelementptr inbounds i32, i32* %10, i64 1
%12 = load i32, i32* %11
%13 = shl i32 %12, 8
%14 = sext i32 %13 to i64
%15 = load i64, i64* %3
%16 = add i64 %15, %14
store i64 %16, i64* %3
%17 = load i32*, i32** %2
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
%20 = shl i32 %19, 16
%21 = sext i32 %20 to i64
%22 = load i64, i64* %3
%23 = add i64 %22, %21
store i64 %23, i64* %3
%24 = load i32*, i32** %2
%25 = getelementptr inbounds i32, i32* %24, i64 3
%26 = load i32, i32* %25
%27 = shl i32 %26, 24
%28 = sext i32 %27 to i64
%29 = load i64, i64* %3
%30 = add i64 %29, %28
store i64 %30, i64* %3
%31 = load i64, i64* %3
ret i64 %31
}

LLVM IR (-O2):
define i64 @little_endian_32(i32* %0) {
%2 = tail call i32 @assert(i32* %0)
%3 = load i32, i32* %0
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i32, i32* %0, i64 1
%6 = load i32, i32* %5
%7 = shl i32 %6, 8
%8 = sext i32 %7 to i64
%9 = add nsw i64 %8, %4
%10 = getelementptr inbounds i32, i32* %0, i64 2
%11 = load i32, i32* %10
%12 = shl i32 %11, 16
%13 = sext i32 %12 to i64
%14 = add nsw i64 %9, %13
%15 = getelementptr inbounds i32, i32* %0, i64 3
%16 = load i32, i32* %15
%17 = shl i32 %16, 24
%18 = sext i32 %17 to i64
%19 = add nsw i64 %14, %18
ret i64 %19
}