#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*/ w;
typedef scalar_t__ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int *, scalar_t__ const *, int);
uint32_t load32(const uint8_t *src) {
  const union {
    long one;
    char little;
  } is_endian = {1};
  if (is_endian.little) {
    uint32_t w;
    memcpy(&w, src, sizeof(w));
    return w;
  } else {
    uint32_t w = ((uint32_t)src[0]) | ((uint32_t)src[1] << 8) |
                 ((uint32_t)src[2] << 16) | ((uint32_t)src[3] << 24);
    return w;
  }
}


x86 assembly (clang, -O0):
<load32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpb   $0x0,-0x18(%rbp)
je     114e <load32+0x3e>
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rdi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1185 <load32+0x75>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x10(%rcx),%rcx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x10(%rbp),%rcx
mov    0x18(%rcx),%rcx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load32>:
push   %rax
mov    %rdi,%rsi
lea    0x4(%rsp),%rdi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
%union.anon = type { i64 }
@__const.load32.is_endian = %union.anon { i64 1 }
define i32 @load32(i64* %0) {
%2 = alloca i32
%3 = alloca i64*
%4 = alloca %union.anon
%5 = alloca i32
%6 = alloca i32
store i64* %0, i64** %3
%7 = bitcast %union.anon* %4 to i8*
%8 = bitcast %union.anon* %4 to i8*
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = load i64*, i64** %3
%13 = call i32 @memcpy(i32* %5, i64* %12, i32 4)
%14 = load i32, i32* %5
store i32 %14, i32* %2
br label %39
15: ; preds = %1
%16 = load i64*, i64** %3
%17 = getelementptr inbounds i64, i64* %16, i64 0
%18 = load i64, i64* %17
%19 = trunc i64 %18 to i32
%20 = load i64*, i64** %3
%21 = getelementptr inbounds i64, i64* %20, i64 1
%22 = load i64, i64* %21
%23 = trunc i64 %22 to i32
%24 = shl i32 %23, 8
%25 = or i32 %19, %24
%26 = load i64*, i64** %3
%27 = getelementptr inbounds i64, i64* %26, i64 2
%28 = load i64, i64* %27
%29 = trunc i64 %28 to i32
%30 = shl i32 %29, 16
%31 = or i32 %25, %30
%32 = load i64*, i64** %3
%33 = getelementptr inbounds i64, i64* %32, i64 3
%34 = load i64, i64* %33
%35 = trunc i64 %34 to i32
%36 = shl i32 %35, 24
%37 = or i32 %31, %36
store i32 %37, i32* %6
%38 = load i32, i32* %6
store i32 %38, i32* %2
br label %39
39: ; preds = %15, %11
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
define i32 @load32(i64* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @memcpy(i32* %2, i64* %0, i32 4)
%5 = load i32, i32* %2
ret i32 %5
}