#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ fd_nrf8001_dtm_command_error(int);
int /*<<< orphan*/ fd_nrf8001_dtm_command_event_error();
int /*<<< orphan*/ fd_nrf8001_dtm_command_success(int);
int /*<<< orphan*/ fd_nrf8001_error();
void fd_nrf8001_dispatch_dtm_command_response(uint8_t status,
                                              uint8_t *response_data,
                                              uint32_t response_data_length) {
  if (status != 0x00) {
    fd_nrf8001_dtm_command_error(status);
    return;
  }
  if (response_data_length != 2) {
    fd_nrf8001_error();
    return;
  }
  uint16_t data = (response_data[0] << 8) | response_data[1];
  if (((data & 0x8000) == 0) && (data & 0x0001)) {
    fd_nrf8001_dtm_command_event_error();
    return;
  }
  fd_nrf8001_dtm_command_success(data);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1169 <fd_nrf8001_dispatch_dtm_command_response+0x29>
mov    -0x4(%rbp),%edi
call   1040 <fd_nrf8001_dtm_command_error@plt>
jmp    11c6 <fd_nrf8001_dispatch_dtm_command_response+0x86>
cmpl   $0x2,-0x14(%rbp)
je     117f <fd_nrf8001_dispatch_dtm_command_response+0x3f>
mov    $0x0,%al
call   1030 <fd_nrf8001_error@plt>
jmp    11c6 <fd_nrf8001_dispatch_dtm_command_response+0x86>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0x8,%eax
mov    -0x10(%rbp),%rcx
or     0x4(%rcx),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
jne    11be <fd_nrf8001_dispatch_dtm_command_response+0x7e>
mov    -0x18(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11be <fd_nrf8001_dispatch_dtm_command_response+0x7e>
mov    $0x0,%al
call   1050 <fd_nrf8001_dtm_command_event_error@plt>
jmp    11c6 <fd_nrf8001_dispatch_dtm_command_response+0x86>
mov    -0x18(%rbp),%edi
call   1060 <fd_nrf8001_dtm_command_success@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
test   %edi,%edi
je     1149 <fd_nrf8001_dispatch_dtm_command_response+0x9>
jmp    1040 <fd_nrf8001_dtm_command_error@plt>
cmp    $0x2,%edx
jne    116c <fd_nrf8001_dispatch_dtm_command_response+0x2c>
mov    (%rsi),%edi
mov    0x4(%rsi),%eax
shl    $0x8,%edi
or     %eax,%edi
test   $0x8000,%edi
jne    1173 <fd_nrf8001_dispatch_dtm_command_response+0x33>
and    $0x1,%eax
je     1173 <fd_nrf8001_dispatch_dtm_command_response+0x33>
xor    %eax,%eax
jmp    1050 <fd_nrf8001_dtm_command_event_error@plt>
xor    %eax,%eax
jmp    1030 <fd_nrf8001_error@plt>
jmp    1060 <fd_nrf8001_dtm_command_success@plt>

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

LLVM IR (-O2):
define void @fd_nrf8001_dispatch_dtm_command_response(i32 %0, i32* nocapture %1, i32 %2) {
%4 = icmp eq i32 %0, 0
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 @fd_nrf8001_dtm_command_error(i32 %0)
br label %26
7: ; preds = %3
%8 = icmp eq i32 %2, 2
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = tail call i32 (...) @fd_nrf8001_error()
br label %26
11: ; preds = %7
%12 = load i32, i32* %1
%13 = shl i32 %12, 8
%14 = getelementptr inbounds i32, i32* %1, i64 1
%15 = load i32, i32* %14
%16 = or i32 %13, %15
%17 = and i32 %16, 32768
%18 = icmp ne i32 %17, 0
%19 = and i32 %15, 1
%20 = icmp eq i32 %19, 0
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %24, label %22
22: ; preds = %11
%23 = tail call i32 (...) @fd_nrf8001_dtm_command_event_error()
br label %26
24: ; preds = %11
%25 = tail call i32 @fd_nrf8001_dtm_command_success(i32 %16)
br label %26
26: ; preds = %22, %24, %5, %9
ret void
}