#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 */
int /*<<< orphan*/ assert(int /*<<< orphan*/ **);
uint32_t read_u32_from_buf(uint8_t **ptr) {
  uint32_t val;
  assert(ptr);
  val = *(*ptr)++;
  val <<= 8;
  val |= *(*ptr)++;
  val <<= 8;
  val |= *(*ptr)++;
  val <<= 8;
  val |= *(*ptr)++;
  return val;
}


x86 assembly (clang, -O0):
<read_u32_from_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,(%rcx)
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,(%rcx)
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,(%rcx)
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,(%rcx)
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_u32_from_buf>:
push   %rbx
mov    %rdi,%rbx
call   1030 <assert@plt>
mov    (%rbx),%rcx
mov    (%rcx),%edx
mov    0x4(%rcx),%eax
shl    $0x10,%edx
shl    $0x8,%eax
or     %edx,%eax
or     0x8(%rcx),%eax
shl    $0x8,%eax
lea    0x10(%rcx),%rdx
mov    %rdx,(%rbx)
or     0xc(%rcx),%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @read_u32_from_buf(i32** %0) {
%2 = tail call i32 @assert(i32** %0)
%3 = load i32*, i32** %0
%4 = getelementptr inbounds i32, i32* %3, i64 1
%5 = load i32, i32* %3
%6 = getelementptr inbounds i32, i32* %3, i64 2
%7 = load i32, i32* %4
%8 = shl i32 %5, 16
%9 = shl i32 %7, 8
%10 = or i32 %9, %8
%11 = getelementptr inbounds i32, i32* %3, i64 3
%12 = load i32, i32* %6
%13 = or i32 %10, %12
%14 = shl i32 %13, 8
%15 = getelementptr inbounds i32, i32* %3, i64 4
store i32* %15, i32** %0
%16 = load i32, i32* %11
%17 = or i32 %14, %16
ret i32 %17
}