#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 nRF24L01P_getRegister(int);
int /*<<< orphan*/ printf(char *, int);
int nRF24L01P_getAirDataRate(void) {
  int rfDataRate;
  rfDataRate = nRF24L01P_getRegister(0x06) & ((1 << 5) | (1 << 3));
  switch (rfDataRate) {
  case ((1 << 5)):
    return 250;
  case (0):
    return 1000;
  case ((1 << 3)):
    return 2000;
  default:
    printf("nRF24L01P: Unknown Air Data Rate value %d\r\n", rfDataRate);
    return 0;
  }
}


x86 assembly (clang, -O0):
<nRF24L01P_getAirDataRate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x6,%edi
call   1040 <nRF24L01P_getRegister@plt>
and    $0x28,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     1179 <nRF24L01P_getAirDataRate+0x59>
jmp    114b <nRF24L01P_getAirDataRate+0x2b>
mov    -0xc(%rbp),%eax
sub    $0x8,%eax
je     1185 <nRF24L01P_getAirDataRate+0x65>
jmp    115c <nRF24L01P_getAirDataRate+0x3c>
mov    -0xc(%rbp),%eax
sub    $0x20,%eax
jne    1191 <nRF24L01P_getAirDataRate+0x71>
jmp    116d <nRF24L01P_getAirDataRate+0x4d>
movl   $0xfa,-0x4(%rbp)
jmp    11a7 <nRF24L01P_getAirDataRate+0x87>
movl   $0x3e8,-0x4(%rbp)
jmp    11a7 <nRF24L01P_getAirDataRate+0x87>
movl   $0x7d0,-0x4(%rbp)
jmp    11a7 <nRF24L01P_getAirDataRate+0x87>
mov    -0x8(%rbp),%esi
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nRF24L01P_getAirDataRate>:
push   %rax
mov    $0x6,%edi
call   1040 <nRF24L01P_getRegister@plt>
and    $0x28,%eax
cmp    $0x20,%eax
je     1143 <nRF24L01P_getAirDataRate+0x23>
cmp    $0x8,%eax
je     114a <nRF24L01P_getAirDataRate+0x2a>
test   %eax,%eax
jne    1151 <nRF24L01P_getAirDataRate+0x31>
mov    $0x3e8,%eax
pop    %rcx
ret
mov    $0xfa,%eax
pop    %rcx
ret
mov    $0x7d0,%eax
pop    %rcx
ret
lea    0xea8(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"nRF24L01P: Unknown Air Data Rate value %d\0D\0A\00"
define i32 @nRF24L01P_getAirDataRate() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @nRF24L01P_getRegister(i32 6)
%4 = and i32 %3, 40
store i32 %4, i32* %2
%5 = load i32, i32* %2
switch i32 %5, label %9 [
i32 32, label %6
i32 0, label %7
i32 8, label %8
]
6: ; preds = %0
store i32 250, i32* %1
br label %12
7: ; preds = %0
store i32 1000, i32* %1
br label %12
8: ; preds = %0
store i32 2000, i32* %1
br label %12
9: ; preds = %0
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 0, i32* %1
br label %12
12: ; preds = %9, %8, %7, %6
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@.str = [44 x i8] c"nRF24L01P: Unknown Air Data Rate value %d\0D\0A\00"
define i32 @nRF24L01P_getAirDataRate() {
%1 = tail call i32 @nRF24L01P_getRegister(i32 6)
%2 = and i32 %1, 40
switch i32 %2, label %5 [
i32 32, label %7
i32 0, label %3
i32 8, label %4
]
3: ; preds = %0
br label %7
4: ; preds = %0
br label %7
5: ; preds = %0
%6 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %7
7: ; preds = %0, %5, %4, %3
%8 = phi i32 [ 0, %5 ], [ 2000, %4 ], [ 1000, %3 ], [ 250, %0 ]
ret i32 %8
}