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

/* Variables and functions */
int load_u8(char const *, int, int);
uint32_t load_u32(const char *icc, int length, int offset) {
  return load_u8(icc, length, offset + 3) +
         (load_u8(icc, length, offset + 2) << 8) +
         (load_u8(icc, length, offset + 1) << 16) +
         (load_u8(icc, length, offset + 0) << 24);
}


x86 assembly (clang, -O0):
<load_u32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x3,%edx
call   1030 <load_u8@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x2,%edx
call   1030 <load_u8@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
shl    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1030 <load_u8@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
shl    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x0,%edx
call   1030 <load_u8@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
shl    $0x18,%ecx
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_u32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r12d
mov    %rdi,%r13
lea    0x3(%r14),%edx
call   1030 <load_u8@plt>
mov    %eax,%r15d
lea    0x2(%r14),%edx
mov    %r13,%rdi
mov    %r12d,%esi
call   1030 <load_u8@plt>
mov    %eax,%ebp
shl    $0x8,%ebp
add    %r15d,%ebp
lea    0x1(%r14),%edx
mov    %r13,%rdi
mov    %r12d,%esi
call   1030 <load_u8@plt>
mov    %eax,%ebx
shl    $0x10,%ebx
add    %ebp,%ebx
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1030 <load_u8@plt>
shl    $0x18,%eax
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @load_u32(i8* %0, i32 %1, i32 %2) {
%4 = add nsw i32 %2, 3
%5 = tail call i32 @load_u8(i8* %0, i32 %1, i32 %4)
%6 = add nsw i32 %2, 2
%7 = tail call i32 @load_u8(i8* %0, i32 %1, i32 %6)
%8 = shl i32 %7, 8
%9 = add nsw i32 %8, %5
%10 = add nsw i32 %2, 1
%11 = tail call i32 @load_u8(i8* %0, i32 %1, i32 %10)
%12 = shl i32 %11, 16
%13 = add nsw i32 %9, %12
%14 = tail call i32 @load_u8(i8* %0, i32 %1, i32 %2)
%15 = shl i32 %14, 24
%16 = add nsw i32 %13, %15
ret i32 %16
}