#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 big_endian_32(u_int8_t *buffer) {
  register unsigned long retval;
  assert(buffer);
  retval = buffer[0] << 24;
  retval += buffer[1] << 16;
  retval += buffer[2] << 8;
  retval += buffer[3];
  return retval;
}


x86 assembly (clang, -O0):
<big_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
mov    (%rax),%eax
shl    $0x18,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x10,%eax
cltq
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
shl    $0x8,%eax
cltq
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq 0xc(%rax),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i64 @big_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 = shl i32 %8, 24
%10 = sext i32 %9 to i64
store i64 %10, i64* %3
%11 = load i32*, i32** %2
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = load i32, i32* %12
%14 = shl i32 %13, 16
%15 = sext i32 %14 to i64
%16 = load i64, i64* %3
%17 = add i64 %16, %15
store i64 %17, i64* %3
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 2
%20 = load i32, i32* %19
%21 = shl i32 %20, 8
%22 = sext i32 %21 to i64
%23 = load i64, i64* %3
%24 = add i64 %23, %22
store i64 %24, i64* %3
%25 = load i32*, i32** %2
%26 = getelementptr inbounds i32, i32* %25, i64 3
%27 = load i32, i32* %26
%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 @big_endian_32(i32* %0) {
%2 = tail call i32 @assert(i32* %0)
%3 = load i32, i32* %0
%4 = shl i32 %3, 24
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 1
%7 = load i32, i32* %6
%8 = shl i32 %7, 16
%9 = sext i32 %8 to i64
%10 = add nsw i64 %9, %5
%11 = getelementptr inbounds i32, i32* %0, i64 2
%12 = load i32, i32* %11
%13 = shl i32 %12, 8
%14 = sext i32 %13 to i64
%15 = add nsw i64 %10, %14
%16 = getelementptr inbounds i32, i32* %0, i64 3
%17 = load i32, i32* %16
%18 = sext i32 %17 to i64
%19 = add nsw i64 %15, %18
ret i64 %19
}