#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 unsigned char uint32_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ FifoProtocol_memcpy(unsigned char *,
                                       int /*<<< orphan*/ const *, int);
void inv_fifo_protocol_helper_decode_firmware(const void *in, uint16_t len,
                                              uint8_t *major, uint8_t *minor,
                                              uint8_t *patch,
                                              unsigned char *hash,
                                              uint32_t *checksum) {
  const uint8_t *buf = (const uint8_t *)in;
  *major = buf[0];
  *minor = buf[1];
  *patch = buf[2];
  FifoProtocol_memcpy((hash), (&buf[3]), (8));
  FifoProtocol_memcpy((checksum), (&buf[11]), (sizeof(*checksum)));
  *checksum = *checksum;
  (void)len;
}


x86 assembly (clang, -O0):
<inv_fifo_protocol_helper_decode_firmware>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
add    $0xc,%rsi
mov    $0x8,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
add    $0x2c,%rsi
mov    $0x1,%edx
call   1030 <FifoProtocol_memcpy@plt>
mov    0x10(%rbp),%rax
mov    (%rax),%cl
mov    0x10(%rbp),%rax
mov    %cl,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv_fifo_protocol_helper_decode_firmware>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x20(%rsp),%r14
mov    (%rdi),%eax
mov    %eax,(%rdx)
mov    0x4(%rdi),%eax
mov    %eax,(%rcx)
mov    0x8(%rdi),%eax
mov    %eax,(%r8)
lea    0xc(%rdi),%rsi
mov    %r9,%rdi
mov    $0x8,%edx
call   1030 <FifoProtocol_memcpy@plt>
add    $0x2c,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <FifoProtocol_memcpy@plt>

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

LLVM IR (-O2):
define void @inv_fifo_protocol_helper_decode_firmware(i8* %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i8* %5, i8* %6) {
%8 = bitcast i8* %0 to i32*
%9 = load i32, i32* %8
store i32 %9, i32* %2
%10 = getelementptr inbounds i8, i8* %0, i64 4
%11 = bitcast i8* %10 to i32*
%12 = load i32, i32* %11
store i32 %12, i32* %3
%13 = getelementptr inbounds i8, i8* %0, i64 8
%14 = bitcast i8* %13 to i32*
%15 = load i32, i32* %14
store i32 %15, i32* %4
%16 = getelementptr inbounds i8, i8* %0, i64 12
%17 = bitcast i8* %16 to i32*
%18 = tail call i32 @FifoProtocol_memcpy(i8* %5, i32* %17, i32 8)
%19 = getelementptr inbounds i8, i8* %0, i64 44
%20 = bitcast i8* %19 to i32*
%21 = tail call i32 @FifoProtocol_memcpy(i8* %6, i32* %20, i32 1)
ret void
}