#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*/ uint64_t;
struct nrf24l01 {
  int dummy;
};

/* Variables and functions */
int rf_reg_writelong(struct nrf24l01 *, int, int /*<<< orphan*/ *, int);
int rf_tx_addr(struct nrf24l01 *dev, uint64_t addr) {
  int ret;
  ret = rf_reg_writelong(dev, 0x10, &addr, 5);
  if (ret < 0)
    goto out;
  ret = rf_reg_writelong(dev, 0x0a, &addr, 5);
  if (ret < 0)
    goto out;
  ret = 0;
out:
  return ret;
}


x86 assembly (clang, -O0):
<rf_tx_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x10,%esi
lea    -0xc(%rbp),%rdx
mov    $0x5,%ecx
call   1030 <rf_reg_writelong@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1148 <rf_tx_addr+0x38>
jmp    1178 <rf_tx_addr+0x68>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
lea    -0xc(%rbp),%rdx
mov    $0x5,%ecx
call   1030 <rf_reg_writelong@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    1171 <rf_tx_addr+0x61>
jmp    1178 <rf_tx_addr+0x68>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rf_tx_addr>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %esi,0xc(%rsp)
lea    0xc(%rsp),%rdx
mov    $0x10,%esi
mov    $0x5,%ecx
call   1030 <rf_reg_writelong@plt>
test   %eax,%eax
js     1152 <rf_tx_addr+0x42>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x5,%ecx
call   1030 <rf_reg_writelong@plt>
mov    %eax,%ecx
sar    $0x1f,%eax
and    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.nrf24l01 = type { i32 }
define i32 @rf_tx_addr(%struct.nrf24l01* %0, i32 %1) {
%3 = alloca %struct.nrf24l01*
%4 = alloca i32
%5 = alloca i32
store %struct.nrf24l01* %0, %struct.nrf24l01** %3
store i32 %1, i32* %4
%6 = load %struct.nrf24l01*, %struct.nrf24l01** %3
%7 = call i32 @rf_reg_writelong(%struct.nrf24l01* %6, i32 16, i32* %4, i32 5)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
br label %18
11: ; preds = %2
%12 = load %struct.nrf24l01*, %struct.nrf24l01** %3
%13 = call i32 @rf_reg_writelong(%struct.nrf24l01* %12, i32 10, i32* %4, i32 5)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
br label %18
17: ; preds = %11
store i32 0, i32* %5
br label %18
18: ; preds = %17, %16, %10
%19 = load i32, i32* %5
ret i32 %19
}

LLVM IR (-O2):
%struct.nrf24l01 = type { i32 }
define i32 @rf_tx_addr(%struct.nrf24l01* %0, i32 %1) {
%3 = alloca i32
store i32 %1, i32* %3
%4 = call i32 @rf_reg_writelong(%struct.nrf24l01* %0, i32 16, i32* %3, i32 5)
%5 = icmp slt i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = call i32 @rf_reg_writelong(%struct.nrf24l01* %0, i32 10, i32* %3, i32 5)
%8 = icmp slt i32 %7, 0
%9 = select i1 %8, i32 %7, i32 0
br label %10
10: ; preds = %6, %2
%11 = phi i32 [ %4, %2 ], [ %9, %6 ]
ret i32 %11
}