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

/* Variables and functions */
int /*<<< orphan*/ fd_binary_unpack_uint16(int /*<<< orphan*/ *);
int /*<<< orphan*/
fd_nrf8001_connected_event(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fd_nrf8001_error();
void fd_nrf8001_decode_connected_event(uint8_t *buffer, uint32_t length) {
  if (length != 15) {
    fd_nrf8001_error();
    return;
  }
  uint8_t address_type = buffer[1];
  uint8_t *peer_address = &buffer[2];
  uint16_t connection_interval = fd_binary_unpack_uint16(&buffer[8]);
  uint16_t slave_latency = fd_binary_unpack_uint16(&buffer[10]);
  uint16_t supervision_timeout = fd_binary_unpack_uint16(&buffer[12]);
  uint8_t masterClockAccuracy = buffer[14];
  fd_nrf8001_connected_event(address_type, peer_address, connection_interval,
                             slave_latency, supervision_timeout,
                             masterClockAccuracy);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xf,-0xc(%rbp)
je     1155 <fd_nrf8001_decode_connected_event+0x25>
mov    $0x0,%al
call   1040 <fd_nrf8001_error@plt>
jmp    11bf <fd_nrf8001_decode_connected_event+0x8f>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1030 <fd_binary_unpack_uint16@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x28,%rdi
call   1030 <fd_binary_unpack_uint16@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x30,%rdi
call   1030 <fd_binary_unpack_uint16@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    0x38(%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
call   1050 <fd_nrf8001_connected_event@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
cmp    $0xf,%esi
jne    1187 <fd_nrf8001_decode_connected_event+0x57>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
mov    0x4(%rdi),%r15d
lea    0x8(%rdi),%r14
add    $0x20,%rdi
call   1030 <fd_binary_unpack_uint16@plt>
mov    %eax,%r12d
lea    0x28(%rbx),%rdi
call   1030 <fd_binary_unpack_uint16@plt>
mov    %eax,%ebp
lea    0x30(%rbx),%rdi
call   1030 <fd_binary_unpack_uint16@plt>
mov    0x38(%rbx),%r9d
mov    %r15d,%edi
mov    %r14,%rsi
mov    %r12d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fd_nrf8001_connected_event@plt>
xor    %eax,%eax
jmp    1040 <fd_nrf8001_error@plt>

LLVM IR (-O0):
define void @fd_nrf8001_decode_connected_event(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 15
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (...) @fd_nrf8001_error()
br label %40
15: ; preds = %2
%16 = load i32*, i32** %3
%17 = getelementptr inbounds i32, i32* %16, i64 1
%18 = load i32, i32* %17
store i32 %18, i32* %5
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 2
store i32* %20, i32** %6
%21 = load i32*, i32** %3
%22 = getelementptr inbounds i32, i32* %21, i64 8
%23 = call i32 @fd_binary_unpack_uint16(i32* %22)
store i32 %23, i32* %7
%24 = load i32*, i32** %3
%25 = getelementptr inbounds i32, i32* %24, i64 10
%26 = call i32 @fd_binary_unpack_uint16(i32* %25)
store i32 %26, i32* %8
%27 = load i32*, i32** %3
%28 = getelementptr inbounds i32, i32* %27, i64 12
%29 = call i32 @fd_binary_unpack_uint16(i32* %28)
store i32 %29, i32* %9
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 14
%32 = load i32, i32* %31
store i32 %32, i32* %10
%33 = load i32, i32* %5
%34 = load i32*, i32** %6
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = load i32, i32* %10
%39 = call i32 @fd_nrf8001_connected_event(i32 %33, i32* %34, i32 %35, i32 %36, i32 %37, i32 %38)
br label %40
40: ; preds = %15, %13
ret void
}

LLVM IR (-O2):
define void @fd_nrf8001_decode_connected_event(i32* %0, i32 %1) {
%3 = icmp eq i32 %1, 15
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @fd_nrf8001_error()
br label %19
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 = getelementptr inbounds i32, i32* %0, i64 8
%11 = tail call i32 @fd_binary_unpack_uint16(i32* %10)
%12 = getelementptr inbounds i32, i32* %0, i64 10
%13 = tail call i32 @fd_binary_unpack_uint16(i32* %12)
%14 = getelementptr inbounds i32, i32* %0, i64 12
%15 = tail call i32 @fd_binary_unpack_uint16(i32* %14)
%16 = getelementptr inbounds i32, i32* %0, i64 14
%17 = load i32, i32* %16
%18 = tail call i32 @fd_nrf8001_connected_event(i32 %8, i32* %9, i32 %11, i32 %13, i32 %15, i32 %17)
br label %19
19: ; preds = %6, %4
ret void
}