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

/* Variables and functions */
int decode_unsigned24(uint8_t *apdu, uint32_t *value) {
  if (value) {
    *value = ((uint32_t)((((uint32_t)apdu[0]) << 16) & 0x00ff0000));
    *value |= (uint32_t)((((uint32_t)apdu[1]) << 8) & 0x0000ff00);
    *value |= ((uint32_t)(((uint32_t)apdu[2]) & 0x000000ff));
  }
  return 3;
}


x86 assembly (clang, -O0):
<decode_unsigned24>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1162 <decode_unsigned24+0x62>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%ecx
shl    $0x10,%ecx
and    $0xff0000,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%ecx
shl    $0x8,%ecx
and    $0xff00,%ecx
mov    -0x10(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    $0x3,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_unsigned24>:
test   %rsi,%rsi
je     1120 <decode_unsigned24+0x20>
mov    (%rdi),%eax
mov    0x8(%rdi),%ecx
movzbl %al,%eax
shl    $0x10,%eax
shl    $0x8,%ecx
movzwl %cx,%ecx
or     %eax,%ecx
movzbl 0x10(%rdi),%eax
or     %ecx,%eax
mov    %eax,(%rsi)
mov    $0x3,%eax
ret

LLVM IR (-O0):
define i32 @decode_unsigned24(i64* %0, i32* %1) {
%3 = alloca i64*
%4 = alloca i32*
store i64* %0, i64** %3
store i32* %1, i32** %4
%5 = load i32*, i32** %4
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %32
7: ; preds = %2
%8 = load i64*, i64** %3
%9 = getelementptr inbounds i64, i64* %8, i64 0
%10 = load i64, i64* %9
%11 = trunc i64 %10 to i32
%12 = shl i32 %11, 16
%13 = and i32 %12, 16711680
%14 = load i32*, i32** %4
store i32 %13, i32* %14
%15 = load i64*, i64** %3
%16 = getelementptr inbounds i64, i64* %15, i64 1
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = shl i32 %18, 8
%20 = and i32 %19, 65280
%21 = load i32*, i32** %4
%22 = load i32, i32* %21
%23 = or i32 %22, %20
store i32 %23, i32* %21
%24 = load i64*, i64** %3
%25 = getelementptr inbounds i64, i64* %24, i64 2
%26 = load i64, i64* %25
%27 = trunc i64 %26 to i32
%28 = and i32 %27, 255
%29 = load i32*, i32** %4
%30 = load i32, i32* %29
%31 = or i32 %30, %28
store i32 %31, i32* %29
br label %32
32: ; preds = %7, %2
ret i32 3
}

LLVM IR (-O2):
define i32 @decode_unsigned24(i64* nocapture %0, i32* writeonly %1) {
%3 = icmp eq i32* %1, null
br i1 %3, label %20, label %4
4: ; preds = %2
%5 = load i64, i64* %0
%6 = trunc i64 %5 to i32
%7 = shl i32 %6, 16
%8 = and i32 %7, 16711680
%9 = getelementptr inbounds i64, i64* %0, i64 1
%10 = load i64, i64* %9
%11 = trunc i64 %10 to i32
%12 = shl i32 %11, 8
%13 = and i32 %12, 65280
%14 = or i32 %13, %8
%15 = getelementptr inbounds i64, i64* %0, i64 2
%16 = load i64, i64* %15
%17 = trunc i64 %16 to i32
%18 = and i32 %17, 255
%19 = or i32 %14, %18
store i32 %19, i32* %1
br label %20
20: ; preds = %4, %2
ret i32 3
}