#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 uint16_t;
struct bladerf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ have_cap(struct bladerf *, int);
int nios_8x16_read(struct bladerf *, int, int, int *);
int nios_vctcxo_trim_dac_read(struct bladerf *dev, uint16_t *value) {
  int status;
  if (!have_cap(dev, (1 << 5))) {
    *value = 0x0000;
    do {
      do {
      } while (0);
    } while (0);
    return (-8);
  }
  status = nios_8x16_read(dev, 0x00, 0x98, value);
  if (status != 0) {
    *value = 0;
  } else {
    do {
      do {
      } while (0);
    } while (0);
  }
  return status;
}


x86 assembly (clang, -O0):
<nios_vctcxo_trim_dac_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1040 <have_cap@plt>
cmp    $0x0,%eax
jne    116c <nios_vctcxo_trim_dac_read+0x4c>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    1156 <nios_vctcxo_trim_dac_read+0x36>
jmp    115b <nios_vctcxo_trim_dac_read+0x3b>
jmp    1160 <nios_vctcxo_trim_dac_read+0x40>
movl   $0xfffffff8,-0x4(%rbp)
jmp    11bb <nios_vctcxo_trim_dac_read+0x9b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
xor    %esi,%esi
mov    $0x98,%edx
call   1030 <nios_8x16_read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     119c <nios_vctcxo_trim_dac_read+0x7c>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    11b5 <nios_vctcxo_trim_dac_read+0x95>
jmp    11a1 <nios_vctcxo_trim_dac_read+0x81>
jmp    11a6 <nios_vctcxo_trim_dac_read+0x86>
jmp    11ab <nios_vctcxo_trim_dac_read+0x8b>
jmp    11b0 <nios_vctcxo_trim_dac_read+0x90>
jmp    11b5 <nios_vctcxo_trim_dac_read+0x95>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nios_vctcxo_trim_dac_read>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x20,%esi
call   1040 <have_cap@plt>
test   %eax,%eax
je     1152 <nios_vctcxo_trim_dac_read+0x32>
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x98,%edx
mov    %r14,%rcx
call   1030 <nios_8x16_read@plt>
test   %eax,%eax
jne    1157 <nios_vctcxo_trim_dac_read+0x37>
jmp    1160 <nios_vctcxo_trim_dac_read+0x40>
mov    $0xfffffff8,%eax
movl   $0x0,(%r14)
mov    %eax,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.bladerf = type { i32 }
define i32 @nios_vctcxo_trim_dac_read(%struct.bladerf* %0, i32* %1) {
%3 = alloca i32
%4 = alloca %struct.bladerf*
%5 = alloca i32*
%6 = alloca i32
store %struct.bladerf* %0, %struct.bladerf** %4
store i32* %1, i32** %5
%7 = load %struct.bladerf*, %struct.bladerf** %4
%8 = call i32 @have_cap(%struct.bladerf* %7, i32 32)
%9 = icmp ne i32 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i32*, i32** %5
store i32 0, i32* %11
br label %12
12: ; preds = %10
br label %13
13: ; preds = %12
br label %14
14: ; preds = %13
br label %15
15: ; preds = %14
store i32 -8, i32* %3
br label %31
16: ; preds = %2
%17 = load %struct.bladerf*, %struct.bladerf** %4
%18 = load i32*, i32** %5
%19 = call i32 @nios_8x16_read(%struct.bladerf* %17, i32 0, i32 152, i32* %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = load i32*, i32** %5
store i32 0, i32* %23
br label %29
24: ; preds = %16
br label %25
25: ; preds = %24
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28, %22
%30 = load i32, i32* %6
store i32 %30, i32* %3
br label %31
31: ; preds = %29, %15
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
%struct.bladerf = type { i32 }
define i32 @nios_vctcxo_trim_dac_read(%struct.bladerf* %0, i32* %1) {
%3 = tail call i32 @have_cap(%struct.bladerf* %0, i32 32)
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @nios_8x16_read(%struct.bladerf* %0, i32 0, i32 152, i32* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5, %2
%9 = phi i32 [ -8, %2 ], [ %6, %5 ]
store i32 0, i32* %1
br label %10
10: ; preds = %8, %5
%11 = phi i32 [ 0, %5 ], [ %9, %8 ]
ret i32 %11
}