#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;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int32_t ReadUint24Be(const void *in, uint32_t *value) {
  assert(in != NULL);
  assert(value != NULL);
  const uint8_t *buf = (const uint8_t *)in;
  uint32_t out = buf[0];
  out <<= 8;
  out |= buf[1];
  out <<= 8;
  out |= buf[2];
  *value = out;
  return 3;
}


x86 assembly (clang, -O0):
<ReadUint24Be>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x3,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadUint24Be>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
mov    (%rbx),%eax
mov    0x4(%rbx),%ecx
shl    $0x10,%eax
shl    $0x8,%ecx
or     %eax,%ecx
or     0x8(%rbx),%ecx
mov    %ecx,(%r14)
mov    $0x3,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @ReadUint24Be(i8* %0, i32* writeonly %1) {
%3 = icmp ne i8* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i32* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = bitcast i8* %0 to i32*
%10 = load i32, i32* %9
%11 = getelementptr inbounds i8, i8* %0, i64 4
%12 = bitcast i8* %11 to i32*
%13 = load i32, i32* %12
%14 = shl i32 %10, 16
%15 = shl i32 %13, 8
%16 = or i32 %15, %14
%17 = getelementptr inbounds i8, i8* %0, i64 8
%18 = bitcast i8* %17 to i32*
%19 = load i32, i32* %18
%20 = or i32 %16, %19
store i32 %20, i32* %1
ret i32 3
}