#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 */

/* Variables and functions */
int nrf_read_register(int, char *, char *);
int nrf_write_register(int, char, char *);
int nrf_set_auto_retransmit_count(int count, char *retstatus) {
  int ret;
  char reg;
  ret = nrf_read_register(0x04, &reg, retstatus);
  if (ret < 0)
    return ret;
  reg &= 0xF0;
  reg |= (char)(count & 0x0F);
  return nrf_write_register(0x04, reg, retstatus);
}


x86 assembly (clang, -O0):
<nrf_set_auto_retransmit_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
mov    $0x4,%edi
lea    -0x15(%rbp),%rsi
call   1040 <nrf_read_register@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1159 <nrf_set_auto_retransmit_count+0x39>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118e <nrf_set_auto_retransmit_count+0x6e>
movsbl -0x15(%rbp),%eax
and    $0xf0,%eax
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf,%eax
movsbl %al,%ecx
movsbl -0x15(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
mov    -0x10(%rbp),%rdx
mov    $0x4,%edi
movsbl %al,%esi
call   1030 <nrf_write_register@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nrf_set_auto_retransmit_count>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x7(%rsp),%rsi
mov    $0x4,%edi
mov    %rbx,%rdx
call   1040 <nrf_read_register@plt>
test   %eax,%eax
js     1161 <nrf_set_auto_retransmit_count+0x41>
mov    0x7(%rsp),%al
and    $0xf0,%al
and    $0xf,%bpl
or     %al,%bpl
mov    %bpl,0x7(%rsp)
movsbl %bpl,%esi
mov    $0x4,%edi
mov    %rbx,%rdx
call   1030 <nrf_write_register@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @nrf_set_auto_retransmit_count(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
store i32 %0, i32* %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @nrf_read_register(i32 4, i8* %7, i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32, i32* %6
store i32 %13, i32* %3
br label %30
14: ; preds = %2
%15 = load i8, i8* %7
%16 = sext i8 %15 to i32
%17 = and i32 %16, 240
%18 = trunc i32 %17 to i8
store i8 %18, i8* %7
%19 = load i32, i32* %4
%20 = and i32 %19, 15
%21 = trunc i32 %20 to i8
%22 = sext i8 %21 to i32
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
%25 = or i32 %24, %22
%26 = trunc i32 %25 to i8
store i8 %26, i8* %7
%27 = load i8, i8* %7
%28 = load i8*, i8** %5
%29 = call i32 @nrf_write_register(i32 4, i8 signext %27, i8* %28)
store i32 %29, i32* %3
br label %30
30: ; preds = %14, %12
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @nrf_set_auto_retransmit_count(i32 %0, i8* %1) {
%3 = alloca i8
%4 = call i32 @nrf_read_register(i32 4, i8* %3, i8* %1)
%5 = icmp slt i32 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = load i8, i8* %3
%8 = and i8 %7, -16
%9 = trunc i32 %0 to i8
%10 = and i8 %9, 15
%11 = or i8 %8, %10
store i8 %11, i8* %3
%12 = call i32 @nrf_write_register(i32 4, i8 signext %11, i8* %1)
br label %13
13: ; preds = %2, %6
%14 = phi i32 [ %12, %6 ], [ %4, %2 ]
ret i32 %14
}