#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 */
unsigned int be32get(void *p, uint32_t *v) {
  uint8_t *a;
  a = p;
  *v = a[0] << 24;
  *v |= a[1] << 16;
  *v |= a[2] << 8;
  *v |= a[3];
  return 4;
}


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

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

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

LLVM IR (-O2):
define i32 @be32get(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = shl i32 %4, 24
store i32 %5, i32* %1
%6 = getelementptr inbounds i8, i8* %0, i64 4
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
%9 = shl i32 %8, 16
%10 = or i32 %9, %5
store i32 %10, i32* %1
%11 = getelementptr inbounds i8, i8* %0, i64 8
%12 = bitcast i8* %11 to i32*
%13 = load i32, i32* %12
%14 = shl i32 %13, 8
%15 = or i32 %14, %10
store i32 %15, i32* %1
%16 = getelementptr inbounds i8, i8* %0, i64 12
%17 = bitcast i8* %16 to i32*
%18 = load i32, i32* %17
%19 = or i32 %15, %18
store i32 %19, i32* %1
ret i32 4
}