#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 /*<<< orphan*/ bits(int, int, char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned short);
void cc2400_rssi(unsigned short v) {
  char description[64];
  sprintf(description, "%d dB", ((signed short)v) >> 8);
  bits(15, 8, "RSSI_VAL", "RO", description);
  sprintf(description, "%d dB", 4 * (((signed char)v) >> 2));
  bits(7, 2, "RSSI_CS_THRES", "RW", description);
  sprintf(description, "%d bits", v & 0x3);
  bits(1, 0, "RSSI_FILT", "RW", description);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
lea    -0x50(%rbp),%rdi
movswl -0x2(%rbp),%eax
sar    $0x8,%eax
lea    0xebf(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0xf,%edi
mov    $0x8,%esi
lea    0xea8(%rip),%rdx
lea    0xeaa(%rip),%rcx
call   1030 <bits@plt>
lea    -0x50(%rbp),%rdi
mov    -0x2(%rbp),%ax
movsbl %al,%eax
sar    $0x2,%eax
shl    $0x2,%eax
lea    0xe7e(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x7,%edi
mov    $0x2,%esi
lea    0xe73(%rip),%rdx
lea    0xe7a(%rip),%rcx
call   1030 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
and    $0x3,%eax
lea    0xe66(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe54(%rip),%rdx
lea    0xe42(%rip),%rcx
call   1030 <bits@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebp
movswl %bp,%eax
shr    $0x8,%eax
movzwl %ax,%edx
lea    0xec6(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0xeb7(%rip),%rdx
lea    0xeb9(%rip),%rcx
mov    $0xf,%edi
mov    $0x8,%esi
mov    %rbx,%r8
call   1030 <bits@plt>
movsbl %bpl,%edx
and    $0xfffc,%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0xe8e(%rip),%rdx
lea    0xe95(%rip),%r14
mov    $0x7,%edi
mov    $0x2,%esi
mov    %r14,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
and    $0x3,%ebp
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1040 <sprintf@plt>
lea    0xe70(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
mov    %r14,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d dB\00"
@.str.1 = [9 x i8] c"RSSI_VAL\00"
@.str.2 = [3 x i8] c"RO\00"
@.str.3 = [14 x i8] c"RSSI_CS_THRES\00"
@.str.4 = [3 x i8] c"RW\00"
@.str.5 = [8 x i8] c"%d bits\00"
@.str.6 = [10 x i8] c"RSSI_FILT\00"
define void @cc2400_rssi(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [64 x i8]
store i16 %0, i16* %2
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = load i16, i16* %2
%6 = sext i16 %5 to i32
%7 = ashr i32 %6, 8
%8 = trunc i32 %7 to i16
%9 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i16 zeroext %8)
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = call i32 @bits(i32 15, i32 8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%13 = load i16, i16* %2
%14 = trunc i16 %13 to i8
%15 = sext i8 %14 to i32
%16 = ashr i32 %15, 2
%17 = mul nsw i32 4, %16
%18 = trunc i32 %17 to i16
%19 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i16 zeroext %18)
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%21 = call i32 @bits(i32 7, i32 2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%23 = load i16, i16* %2
%24 = zext i16 %23 to i32
%25 = and i32 %24, 3
%26 = trunc i32 %25 to i16
%27 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i16 zeroext %26)
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%29 = call i32 @bits(i32 1, i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %28)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d dB\00"
@.str.1 = [9 x i8] c"RSSI_VAL\00"
@.str.2 = [3 x i8] c"RO\00"
@.str.3 = [14 x i8] c"RSSI_CS_THRES\00"
@.str.4 = [3 x i8] c"RW\00"
@.str.5 = [8 x i8] c"%d bits\00"
@.str.6 = [10 x i8] c"RSSI_FILT\00"
define void @cc2400_rssi(i16 zeroext %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = ashr i16 %0, 8
%5 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i16 zeroext %4)
%6 = call i32 @bits(i32 15, i32 8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%7 = zext i16 %0 to i32
%8 = shl i32 %7, 24
%9 = ashr exact i32 %8, 24
%10 = trunc i32 %9 to i16
%11 = and i16 %10, -4
%12 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i16 zeroext %11)
%13 = call i32 @bits(i32 7, i32 2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%14 = and i16 %0, 3
%15 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i16 zeroext %14)
%16 = call i32 @bits(i32 1, i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
ret void
}