#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 */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int const, int const, int const, int const,
                          int);
uint32_t ReadUint32BE(const uint8_t *data) {
  assert(data != NULL);
  uint32_t be = data[3] << 0 | data[2] << 8 | data[1] << 16 | data[0] << 24;
  printf("R32  BE: \"0x%02x%02x%02x%02x\" -> 0x%08x\n", data[0], data[1],
         data[2], data[3], be);
  return be;
}


x86 assembly (clang, -O0):
<ReadUint32BE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%eax
shl    $0x0,%eax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0x4(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0xc(%rbp),%r9d
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadUint32BE>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
mov    0xc(%rbx),%r8d
mov    0x8(%rbx),%ecx
mov    %ecx,%eax
shl    $0x8,%eax
or     %r8d,%eax
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    %edx,%edi
shl    $0x10,%edi
mov    %esi,%ebx
shl    $0x18,%ebx
or     %edi,%ebx
or     %eax,%ebx
lea    0xea5(%rip),%rdi
mov    %ebx,%r9d
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"R32 BE: \220x%02x%02x%02x%02x\22 -> 0x%08x\0A\00"
define i32 @ReadUint32BE(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = icmp ne i32* %4, null
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i64 3
%10 = load i32, i32* %9
%11 = shl i32 %10, 0
%12 = load i32*, i32** %2
%13 = getelementptr inbounds i32, i32* %12, i64 2
%14 = load i32, i32* %13
%15 = shl i32 %14, 8
%16 = or i32 %11, %15
%17 = load i32*, i32** %2
%18 = getelementptr inbounds i32, i32* %17, i64 1
%19 = load i32, i32* %18
%20 = shl i32 %19, 16
%21 = or i32 %16, %20
%22 = load i32*, i32** %2
%23 = getelementptr inbounds i32, i32* %22, i64 0
%24 = load i32, i32* %23
%25 = shl i32 %24, 24
%26 = or i32 %21, %25
store i32 %26, i32* %3
%27 = load i32*, i32** %2
%28 = getelementptr inbounds i32, i32* %27, i64 0
%29 = load i32, i32* %28
%30 = load i32*, i32** %2
%31 = getelementptr inbounds i32, i32* %30, i64 1
%32 = load i32, i32* %31
%33 = load i32*, i32** %2
%34 = getelementptr inbounds i32, i32* %33, i64 2
%35 = load i32, i32* %34
%36 = load i32*, i32** %2
%37 = getelementptr inbounds i32, i32* %36, i64 3
%38 = load i32, i32* %37
%39 = load i32, i32* %3
%40 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %32, i32 %35, i32 %38, i32 %39)
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [41 x i8] c"R32 BE: \220x%02x%02x%02x%02x\22 -> 0x%08x\0A\00"
define i32 @ReadUint32BE(i32* %0) {
%2 = icmp ne i32* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = getelementptr inbounds i32, i32* %0, i64 3
%6 = load i32, i32* %5
%7 = getelementptr inbounds i32, i32* %0, i64 2
%8 = load i32, i32* %7
%9 = shl i32 %8, 8
%10 = or i32 %9, %6
%11 = getelementptr inbounds i32, i32* %0, i64 1
%12 = load i32, i32* %11
%13 = shl i32 %12, 16
%14 = or i32 %10, %13
%15 = load i32, i32* %0
%16 = shl i32 %15, 24
%17 = or i32 %14, %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %12, i32 %8, i32 %6, i32 %17)
ret i32 %17
}