#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*/ fd_nrf8001_error();
int /*<<< orphan*/ fd_nrf8001_pipe_error_event(int /*<<< orphan*/,
                                               int /*<<< orphan*/,
                                               int /*<<< orphan*/ *, int);
void fd_nrf8001_decode_pipe_error_event(uint8_t *buffer, uint32_t length) {
  if (length < 3) {
    fd_nrf8001_error();
    return;
  }
  uint8_t service_pipe_number = buffer[1];
  uint8_t error_code = buffer[2];
  uint8_t *error_data = &buffer[3];
  uint32_t error_data_length = length - 3;
  fd_nrf8001_pipe_error_event(service_pipe_number, error_code, error_data,
                              error_data_length);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    1145 <fd_nrf8001_decode_pipe_error_event+0x25>
mov    $0x0,%al
call   1030 <fd_nrf8001_error@plt>
jmp    1180 <fd_nrf8001_decode_pipe_error_event+0x60>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <fd_nrf8001_pipe_error_event@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
cmp    $0x2,%esi
jg     112c <fd_nrf8001_decode_pipe_error_event+0xc>
xor    %eax,%eax
jmp    1030 <fd_nrf8001_error@plt>
mov    %esi,%ecx
mov    %rdi,%rdx
mov    0x4(%rdi),%edi
mov    0x8(%rdx),%esi
add    $0xc,%rdx
add    $0xfffffffd,%ecx
jmp    1040 <fd_nrf8001_pipe_error_event@plt>

LLVM IR (-O0):
define void @fd_nrf8001_decode_pipe_error_event(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (...) @fd_nrf8001_error()
br label %29
13: ; preds = %2
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %15
store i32 %16, i32* %5
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
store i32 %19, i32* %6
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 3
store i32* %21, i32** %7
%22 = load i32, i32* %4
%23 = sub nsw i32 %22, 3
store i32 %23, i32* %8
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = load i32*, i32** %7
%27 = load i32, i32* %8
%28 = call i32 @fd_nrf8001_pipe_error_event(i32 %24, i32 %25, i32* %26, i32 %27)
br label %29
29: ; preds = %13, %11
ret void
}

LLVM IR (-O2):
define void @fd_nrf8001_decode_pipe_error_event(i32* %0, i32 %1) {
%3 = icmp slt i32 %1, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @fd_nrf8001_error()
br label %14
6: ; preds = %2
%7 = getelementptr inbounds i32, i32* %0, i64 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %0, i64 2
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %0, i64 3
%12 = add nsw i32 %1, -3
%13 = tail call i32 @fd_nrf8001_pipe_error_event(i32 %8, i32 %10, i32* %11, i32 %12)
br label %14
14: ; preds = %6, %4
ret void
}