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

/* Variables and functions */
const uint8_t *read_u32(const uint8_t *p, size_t *s, uint32_t *v) {
  *v = 0;
  *v |= *p++ << 24;
  *v |= *p++ << 16;
  *v |= *p++ << 8;
  *v |= *p++ << 0;
  *s -= 4;
  return (p);
}


x86 assembly (clang, -O0):
<read_u32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%ecx
shl    $0x18,%ecx
mov    -0x18(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%ecx
shl    $0x10,%ecx
mov    -0x18(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%ecx
shl    $0x8,%ecx
mov    -0x18(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%ecx
shl    $0x0,%ecx
mov    -0x18(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
sub    $0x4,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_u32>:
movl   $0x0,(%rdx)
mov    (%rdi),%ecx
shl    $0x18,%ecx
mov    %ecx,(%rdx)
mov    0x4(%rdi),%eax
shl    $0x10,%eax
or     %ecx,%eax
mov    %eax,(%rdx)
mov    0x8(%rdi),%ecx
shl    $0x8,%ecx
or     %eax,%ecx
mov    %ecx,(%rdx)
or     0xc(%rdi),%ecx
lea    0x10(%rdi),%rax
mov    %ecx,(%rdx)
addq   $0xfffffffffffffffc,(%rsi)
ret

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

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