#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_delay(int delay, char *retstatus) {
  int ret;
  char reg;
  ret = nrf_read_register(0x04, &reg, retstatus);
  if (ret < 0)
    return ret;
  reg &= 0x0F;
  reg |= (char)((delay & 0x0F) << 4);
  return nrf_write_register(0x04, reg, retstatus);
}


x86 assembly (clang, -O0):
<nrf_set_auto_retransmit_delay>:
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_delay+0x39>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118f <nrf_set_auto_retransmit_delay+0x6f>
movsbl -0x15(%rbp),%eax
and    $0xf,%eax
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf,%eax
shl    $0x4,%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_delay>:
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_delay+0x41>
mov    0x7(%rsp),%al
and    $0xf,%al
shl    $0x4,%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_delay(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 %31
14: ; preds = %2
%15 = load i8, i8* %7
%16 = sext i8 %15 to i32
%17 = and i32 %16, 15
%18 = trunc i32 %17 to i8
store i8 %18, i8* %7
%19 = load i32, i32* %4
%20 = and i32 %19, 15
%21 = shl i32 %20, 4
%22 = trunc i32 %21 to i8
%23 = sext i8 %22 to i32
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = or i32 %25, %23
%27 = trunc i32 %26 to i8
store i8 %27, i8* %7
%28 = load i8, i8* %7
%29 = load i8*, i8** %5
%30 = call i32 @nrf_write_register(i32 4, i8 signext %28, i8* %29)
store i32 %30, i32* %3
br label %31
31: ; preds = %14, %12
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @nrf_set_auto_retransmit_delay(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, 15
%9 = trunc i32 %0 to i8
%10 = shl i8 %9, 4
%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
}