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

/* Variables and functions */
int rf_command(struct nrf24l01 *, int, int /*<<< orphan*/ *, int /*<<< orphan*/,
               int /*<<< orphan*/);
int rf_pinsetup(struct nrf24l01 *);
int rf_reg_write(struct nrf24l01 *, int, int);
int /*<<< orphan*/ usleep(int);
int rf_init(struct nrf24l01 *dev) {
  int ret;
  ret = rf_pinsetup(dev);
  if (ret < 0)
    goto out;
  usleep(5 * 1000);
  ret = rf_reg_write(dev, 0x00, 0b00001100);
  if (ret < 0)
    goto out;
  ret = rf_reg_write(dev, 0x04, 0b01011010);
  if (ret < 0)
    goto out;
  ret = rf_reg_write(dev, 0x06, 0b00001110);
  if (ret < 0)
    goto out;
  ret = rf_reg_write(dev, 0x1d, 0b00000000);
  if (ret < 0)
    goto out;
  ret = rf_reg_write(dev, 0x1c, 0b00000000);
  if (ret < 0)
    goto out;
  ret = rf_reg_write(dev, 0x07, 0b01110000);
  if (ret < 0)
    goto out;
  ret = rf_reg_write(dev, 0x05, 76);
  if (ret < 0)
    goto out;
  ret = rf_command(dev, 0b11100010, NULL, 0, 0);
  if (ret < 0)
    goto out;
  ret = rf_command(dev, 0b11100001, NULL, 0, 0);
  if (ret < 0)
    goto out;
  ret = rf_reg_write(dev, 0x00, 0b00001110);
  if (ret < 0)
    goto out;
  usleep(5 * 1000);
out:
  return ret;
}


x86 assembly (clang, -O0):
<rf_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <rf_pinsetup@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1167 <rf_init+0x27>
jmp    12eb <rf_init+0x1ab>
mov    $0x1388,%edi
call   1060 <usleep@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <rf_reg_write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1193 <rf_init+0x53>
jmp    12eb <rf_init+0x1ab>
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
mov    $0x5a,%edx
call   1030 <rf_reg_write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11b8 <rf_init+0x78>
jmp    12eb <rf_init+0x1ab>
mov    -0x8(%rbp),%rdi
mov    $0x6,%esi
mov    $0xe,%edx
call   1030 <rf_reg_write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11dd <rf_init+0x9d>
jmp    12eb <rf_init+0x1ab>
mov    -0x8(%rbp),%rdi
mov    $0x1d,%esi
xor    %edx,%edx
call   1030 <rf_reg_write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11ff <rf_init+0xbf>
jmp    12eb <rf_init+0x1ab>
mov    -0x8(%rbp),%rdi
mov    $0x1c,%esi
xor    %edx,%edx
call   1030 <rf_reg_write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1221 <rf_init+0xe1>
jmp    12eb <rf_init+0x1ab>
mov    -0x8(%rbp),%rdi
mov    $0x7,%esi
mov    $0x70,%edx
call   1030 <rf_reg_write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1246 <rf_init+0x106>
jmp    12eb <rf_init+0x1ab>
mov    -0x8(%rbp),%rdi
mov    $0x5,%esi
mov    $0x4c,%edx
call   1030 <rf_reg_write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    126b <rf_init+0x12b>
jmp    12eb <rf_init+0x1ab>
mov    -0x8(%rbp),%rdi
mov    $0xe2,%esi
xor    %eax,%eax
mov    %eax,%edx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1040 <rf_command@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1295 <rf_init+0x155>
jmp    12eb <rf_init+0x1ab>
mov    -0x8(%rbp),%rdi
mov    $0xe1,%esi
xor    %eax,%eax
mov    %eax,%edx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1040 <rf_command@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    12bf <rf_init+0x17f>
jmp    12eb <rf_init+0x1ab>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1030 <rf_reg_write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    12e1 <rf_init+0x1a1>
jmp    12eb <rf_init+0x1ab>
mov    $0x1388,%edi
call   1060 <usleep@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rf_init>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <rf_pinsetup@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    $0x1388,%edi
call   1060 <usleep@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <rf_reg_write@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x5a,%edx
call   1030 <rf_reg_write@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0xe,%edx
call   1030 <rf_reg_write@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    %rbx,%rdi
mov    $0x1d,%esi
xor    %edx,%edx
call   1030 <rf_reg_write@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    %rbx,%rdi
mov    $0x1c,%esi
xor    %edx,%edx
call   1030 <rf_reg_write@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x70,%edx
call   1030 <rf_reg_write@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x4c,%edx
call   1030 <rf_reg_write@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    %rbx,%rdi
mov    $0xe2,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <rf_command@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    %rbx,%rdi
mov    $0xe1,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <rf_command@plt>
test   %eax,%eax
js     124f <rf_init+0x10f>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1030 <rf_reg_write@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1251 <rf_init+0x111>
mov    $0x1388,%edi
call   1060 <usleep@plt>
jmp    1251 <rf_init+0x111>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.nrf24l01 = type { i32 }
define i32 @rf_init(%struct.nrf24l01* %0) {
%2 = alloca %struct.nrf24l01*
%3 = alloca i32
store %struct.nrf24l01* %0, %struct.nrf24l01** %2
%4 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%5 = call i32 @rf_pinsetup(%struct.nrf24l01* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
br label %72
9: ; preds = %1
%10 = call i32 @usleep(i32 5000)
%11 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%12 = call i32 @rf_reg_write(%struct.nrf24l01* %11, i32 0, i32 12)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %9
br label %72
16: ; preds = %9
%17 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%18 = call i32 @rf_reg_write(%struct.nrf24l01* %17, i32 4, i32 90)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
br label %72
22: ; preds = %16
%23 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%24 = call i32 @rf_reg_write(%struct.nrf24l01* %23, i32 6, i32 14)
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
br label %72
28: ; preds = %22
%29 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%30 = call i32 @rf_reg_write(%struct.nrf24l01* %29, i32 29, i32 0)
store i32 %30, i32* %3
%31 = load i32, i32* %3
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
br label %72
34: ; preds = %28
%35 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%36 = call i32 @rf_reg_write(%struct.nrf24l01* %35, i32 28, i32 0)
store i32 %36, i32* %3
%37 = load i32, i32* %3
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %34
br label %72
40: ; preds = %34
%41 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%42 = call i32 @rf_reg_write(%struct.nrf24l01* %41, i32 7, i32 112)
store i32 %42, i32* %3
%43 = load i32, i32* %3
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
br label %72
46: ; preds = %40
%47 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%48 = call i32 @rf_reg_write(%struct.nrf24l01* %47, i32 5, i32 76)
store i32 %48, i32* %3
%49 = load i32, i32* %3
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %46
br label %72
52: ; preds = %46
%53 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%54 = call i32 @rf_command(%struct.nrf24l01* %53, i32 226, i32* null, i32 0, i32 0)
store i32 %54, i32* %3
%55 = load i32, i32* %3
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %52
br label %72
58: ; preds = %52
%59 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%60 = call i32 @rf_command(%struct.nrf24l01* %59, i32 225, i32* null, i32 0, i32 0)
store i32 %60, i32* %3
%61 = load i32, i32* %3
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %58
br label %72
64: ; preds = %58
%65 = load %struct.nrf24l01*, %struct.nrf24l01** %2
%66 = call i32 @rf_reg_write(%struct.nrf24l01* %65, i32 0, i32 14)
store i32 %66, i32* %3
%67 = load i32, i32* %3
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %64
br label %72
70: ; preds = %64
%71 = call i32 @usleep(i32 5000)
br label %72
72: ; preds = %70, %69, %63, %57, %51, %45, %39, %33, %27, %21, %15, %8
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
%struct.nrf24l01 = type { i32 }
define i32 @rf_init(%struct.nrf24l01* %0) {
%2 = tail call i32 @rf_pinsetup(%struct.nrf24l01* %0)
%3 = icmp slt i32 %2, 0
br i1 %3, label %37, label %4
4: ; preds = %1
%5 = tail call i32 @usleep(i32 5000)
%6 = tail call i32 @rf_reg_write(%struct.nrf24l01* %0, i32 0, i32 12)
%7 = icmp slt i32 %6, 0
br i1 %7, label %37, label %8
8: ; preds = %4
%9 = tail call i32 @rf_reg_write(%struct.nrf24l01* %0, i32 4, i32 90)
%10 = icmp slt i32 %9, 0
br i1 %10, label %37, label %11
11: ; preds = %8
%12 = tail call i32 @rf_reg_write(%struct.nrf24l01* %0, i32 6, i32 14)
%13 = icmp slt i32 %12, 0
br i1 %13, label %37, label %14
14: ; preds = %11
%15 = tail call i32 @rf_reg_write(%struct.nrf24l01* %0, i32 29, i32 0)
%16 = icmp slt i32 %15, 0
br i1 %16, label %37, label %17
17: ; preds = %14
%18 = tail call i32 @rf_reg_write(%struct.nrf24l01* %0, i32 28, i32 0)
%19 = icmp slt i32 %18, 0
br i1 %19, label %37, label %20
20: ; preds = %17
%21 = tail call i32 @rf_reg_write(%struct.nrf24l01* %0, i32 7, i32 112)
%22 = icmp slt i32 %21, 0
br i1 %22, label %37, label %23
23: ; preds = %20
%24 = tail call i32 @rf_reg_write(%struct.nrf24l01* %0, i32 5, i32 76)
%25 = icmp slt i32 %24, 0
br i1 %25, label %37, label %26
26: ; preds = %23
%27 = tail call i32 @rf_command(%struct.nrf24l01* %0, i32 226, i32* null, i32 0, i32 0)
%28 = icmp slt i32 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %26
%30 = tail call i32 @rf_command(%struct.nrf24l01* %0, i32 225, i32* null, i32 0, i32 0)
%31 = icmp slt i32 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = tail call i32 @rf_reg_write(%struct.nrf24l01* %0, i32 0, i32 14)
%34 = icmp slt i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 @usleep(i32 5000)
br label %37
37: ; preds = %32, %29, %26, %23, %20, %17, %14, %11, %8, %4, %1, %35
%38 = phi i32 [ %2, %1 ], [ %6, %4 ], [ %9, %8 ], [ %12, %11 ], [ %15, %14 ], [ %18, %17 ], [ %21, %20 ], [ %24, %23 ], [ %27, %26 ], [ %30, %29 ], [ %33, %32 ], [ %33, %35 ]
ret i32 %38
}