#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_grdec(unsigned short v) {
  char *decshift[] = {"0", "1", "-2", "-1"};
  char *channeldec[] = {"1MHz", "500kHz", "250kHz", "125kHz"};
  char description[64];
  bits(15, 13, "-", "W0", "");
  bits(12, 12, "IND_SATURATION", "RO", "");
  bits(11, 10, "DEC_SHIFT", "RW", decshift[(v >> 10) & 3]);
  bits(9, 8, "CHANNEL_DEC", "RW", channeldec[(v >> 8) & 3]);
  sprintf(description, "%d", v & 0xFF);
  bits(7, 0, "DEC_VAL", "RW", description);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    0x2ca7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2ca4(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2ca1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c9e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c9b(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0x2c98(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0x2c95(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c92(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    $0xf,%edi
mov    $0xd,%esi
lea    0xe85(%rip),%rdx
lea    0xe80(%rip),%rcx
lea    0xe78(%rip),%r8
call   1030 <bits@plt>
mov    $0xc,%esi
lea    0xe6b(%rip),%rdx
lea    0xe73(%rip),%rcx
lea    0xe59(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
movzwl -0x2(%rbp),%eax
sar    $0xa,%eax
and    $0x3,%eax
cltq
mov    -0x30(%rbp,%rax,8),%r8
mov    $0xb,%edi
mov    $0xa,%esi
lea    0xe46(%rip),%rdx
lea    0xe49(%rip),%rcx
call   1030 <bits@plt>
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
and    $0x3,%eax
cltq
mov    -0x50(%rbp,%rax,8),%r8
mov    $0x9,%edi
mov    $0x8,%esi
lea    0xe25(%rip),%rdx
lea    0xe1b(%rip),%rcx
call   1030 <bits@plt>
lea    -0x90(%rbp),%rdi
movzwl -0x2(%rbp),%eax
and    $0xff,%eax
lea    0xe0e(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x90(%rbp),%r8
mov    $0x7,%edi
xor    %esi,%esi
lea    0xdf4(%rip),%rdx
lea    0xddb(%rip),%rcx
call   1030 <bits@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebx
lea    0xef0(%rip),%rdx
lea    0xeeb(%rip),%rcx
lea    0xee3(%rip),%r14
mov    $0xf,%edi
mov    $0xd,%esi
mov    %r14,%r8
call   1030 <bits@plt>
lea    0xece(%rip),%rdx
lea    0xed6(%rip),%rcx
mov    $0xc,%edi
mov    $0xc,%esi
mov    %r14,%r8
call   1030 <bits@plt>
mov    %ebx,%eax
shr    $0xa,%eax
and    $0x3,%eax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%r8
add    %rcx,%r8
lea    0xeaa(%rip),%rdx
lea    0xead(%rip),%r14
mov    $0xb,%edi
mov    $0xa,%esi
mov    %r14,%rcx
call   1030 <bits@plt>
mov    %ebx,%eax
shr    $0x8,%eax
and    $0x3,%eax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%r8
add    %rcx,%r8
lea    0xe81(%rip),%rdx
mov    $0x9,%edi
mov    $0x8,%esi
mov    %r14,%rcx
call   1030 <bits@plt>
movzbl %bl,%edx
lea    0xe71(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
lea    0xe62(%rip),%rdx
mov    $0x7,%edi
xor    %esi,%esi
mov    %r14,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [3 x i8] c"-2\00"
@.str.3 = [3 x i8] c"-1\00"
@__const.cc2400_grdec.decshift = [4 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [5 x i8] c"1MHz\00"
@.str.5 = [7 x i8] c"500kHz\00"
@.str.6 = [7 x i8] c"250kHz\00"
@.str.7 = [7 x i8] c"125kHz\00"
@__const.cc2400_grdec.channeldec = [4 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0)]
@.str.8 = [2 x i8] c"-\00"
@.str.9 = [3 x i8] c"W0\00"
@.str.10 = [1 x i8] zeroinitializer
@.str.11 = [15 x i8] c"IND_SATURATION\00"
@.str.12 = [3 x i8] c"RO\00"
@.str.13 = [10 x i8] c"DEC_SHIFT\00"
@.str.14 = [3 x i8] c"RW\00"
@.str.15 = [12 x i8] c"CHANNEL_DEC\00"
@.str.16 = [3 x i8] c"%d\00"
@.str.17 = [8 x i8] c"DEC_VAL\00"
define void @cc2400_grdec(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [4 x i8*]
%4 = alloca [4 x i8*]
%5 = alloca [64 x i8]
store i16 %0, i16* %2
%6 = bitcast [4 x i8*]* %3 to i8*
%7 = bitcast [4 x i8*]* %4 to i8*
%8 = call i32 @bits(i32 15, i32 13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%9 = call i32 @bits(i32 12, i32 12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%10 = load i16, i16* %2
%11 = zext i16 %10 to i32
%12 = ashr i32 %11, 10
%13 = and i32 %12, 3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 @bits(i32 11, i32 10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* %16)
%18 = load i16, i16* %2
%19 = zext i16 %18 to i32
%20 = ashr i32 %19, 8
%21 = and i32 %20, 3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @bits(i32 9, i32 8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%27 = load i16, i16* %2
%28 = zext i16 %27 to i32
%29 = and i32 %28, 255
%30 = trunc i32 %29 to i16
%31 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i16 zeroext %30)
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%33 = call i32 @bits(i32 7, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [3 x i8] c"-2\00"
@.str.3 = [3 x i8] c"-1\00"
@reltable.cc2400_grdec = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_grdec to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_grdec to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_grdec to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_grdec to i64)) to i32)]
@.str.4 = [5 x i8] c"1MHz\00"
@.str.5 = [7 x i8] c"500kHz\00"
@.str.6 = [7 x i8] c"250kHz\00"
@.str.7 = [7 x i8] c"125kHz\00"
@reltable.cc2400_grdec.18 = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_grdec.18 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_grdec.18 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_grdec.18 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.7 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_grdec.18 to i64)) to i32)]
@.str.8 = [2 x i8] c"-\00"
@.str.9 = [3 x i8] c"W0\00"
@.str.10 = [1 x i8] zeroinitializer
@.str.11 = [15 x i8] c"IND_SATURATION\00"
@.str.12 = [3 x i8] c"RO\00"
@.str.13 = [10 x i8] c"DEC_SHIFT\00"
@.str.14 = [3 x i8] c"RW\00"
@.str.15 = [12 x i8] c"CHANNEL_DEC\00"
@.str.16 = [3 x i8] c"%d\00"
@.str.17 = [8 x i8] c"DEC_VAL\00"
define void @cc2400_grdec(i16 zeroext %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @bits(i32 15, i32 13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%5 = tail call i32 @bits(i32 12, i32 12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%6 = zext i16 %0 to i32
%7 = lshr i32 %6, 10
%8 = and i32 %7, 3
%9 = zext i32 %8 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.cc2400_grdec to i8*), i64 %10)
%12 = tail call i32 @bits(i32 11, i32 10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* %11)
%13 = lshr i32 %6, 8
%14 = and i32 %13, 3
%15 = zext i32 %14 to i64
%16 = shl i64 %15, 2
%17 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.cc2400_grdec.18 to i8*), i64 %16)
%18 = tail call i32 @bits(i32 9, i32 8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* %17)
%19 = and i16 %0, 255
%20 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i16 zeroext %19)
%21 = call i32 @bits(i32 7, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* %3)
ret void
}