#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_fstst2(unsigned short v) {
  char *speed[] = {"Normal", "Undefined", "Half Speed", "Undefined"};
  char description[64];
  bits(15, 15, "-", "W0", "");
  bits(14, 13, "VCO_CURCAL_SPEED", "RW", speed[(v >> 13) & 3]);
  bits(12, 12, "VCO_CURRENT_OE", "RW", "");
  sprintf(description, "%d", (v >> 6) & 0x3f);
  bits(11, 6, "VCO_CURRENT_O", "RW", description);
  sprintf(description, "%d", v & 0x3f);
  bits(5, 0, "VCO_CURRENT_RES", "RO", description);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    0x2cca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cc4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cc1(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0xf,%esi
lea    0xeb5(%rip),%rdx
lea    0xeb0(%rip),%rcx
lea    0xea8(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
movzwl -0x2(%rbp),%eax
sar    $0xd,%eax
and    $0x3,%eax
cltq
mov    -0x30(%rbp,%rax,8),%r8
mov    $0xe,%edi
mov    $0xd,%esi
lea    0xe83(%rip),%rdx
lea    0xe8d(%rip),%rcx
call   1030 <bits@plt>
mov    $0xc,%esi
lea    0xe7f(%rip),%rdx
lea    0xe75(%rip),%rcx
lea    0xe59(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
lea    -0x70(%rbp),%rdi
movzwl -0x2(%rbp),%eax
sar    $0x6,%eax
and    $0x3f,%eax
lea    0xe64(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%r8
mov    $0xb,%edi
mov    $0x6,%esi
lea    0xe4a(%rip),%rdx
lea    0xe2e(%rip),%rcx
call   1030 <bits@plt>
lea    -0x70(%rbp),%rdi
movzwl -0x2(%rbp),%eax
and    $0x3f,%eax
lea    0xe29(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%r8
mov    $0x5,%edi
xor    %esi,%esi
lea    0xe20(%rip),%rdx
lea    0xe29(%rip),%rcx
call   1030 <bits@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebx
lea    0xee8(%rip),%rdx
lea    0xee3(%rip),%rcx
lea    0xedb(%rip),%r15
mov    $0xf,%edi
mov    $0xf,%esi
mov    %r15,%r8
call   1030 <bits@plt>
mov    %ebx,%eax
shr    $0xd,%eax
and    $0x3,%eax
lea    0xf05(%rip),%rcx
movslq (%rcx,%rax,4),%r8
add    %rcx,%r8
lea    0xeb0(%rip),%rdx
lea    0xeba(%rip),%r14
mov    $0xe,%edi
mov    $0xd,%esi
mov    %r14,%rcx
call   1030 <bits@plt>
lea    0xea4(%rip),%rdx
mov    $0xc,%edi
mov    $0xc,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
mov    %ebx,%edx
shr    $0x6,%edx
and    $0x3f,%edx
lea    0xe8f(%rip),%r12
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <sprintf@plt>
lea    0xe7d(%rip),%rdx
mov    $0xb,%edi
mov    $0x6,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
and    $0x3f,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1040 <sprintf@plt>
lea    0xe5f(%rip),%rdx
lea    0xe68(%rip),%rcx
mov    $0x5,%edi
xor    %esi,%esi
mov    %r15,%r8
call   1030 <bits@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Normal\00"
@.str.1 = [10 x i8] c"Undefined\00"
@.str.2 = [11 x i8] c"Half Speed\00"
@__const.cc2400_fstst2.speed = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i32 0, i32 0)]
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [3 x i8] c"W0\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [17 x i8] c"VCO_CURCAL_SPEED\00"
@.str.7 = [3 x i8] c"RW\00"
@.str.8 = [15 x i8] c"VCO_CURRENT_OE\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [14 x i8] c"VCO_CURRENT_O\00"
@.str.11 = [16 x i8] c"VCO_CURRENT_RES\00"
@.str.12 = [3 x i8] c"RO\00"
define void @cc2400_fstst2(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [4 x i8*]
%4 = alloca [64 x i8]
store i16 %0, i16* %2
%5 = bitcast [4 x i8*]* %3 to i8*
%6 = call i32 @bits(i32 15, i32 15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%7 = load i16, i16* %2
%8 = zext i16 %7 to i32
%9 = ashr i32 %8, 13
%10 = and i32 %9, 3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = call i32 @bits(i32 14, i32 13, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %13)
%15 = call i32 @bits(i32 12, i32 12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%17 = load i16, i16* %2
%18 = zext i16 %17 to i32
%19 = ashr i32 %18, 6
%20 = and i32 %19, 63
%21 = trunc i32 %20 to i16
%22 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i16 zeroext %21)
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%24 = call i32 @bits(i32 11, i32 6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%26 = load i16, i16* %2
%27 = zext i16 %26 to i32
%28 = and i32 %27, 63
%29 = trunc i32 %28 to i16
%30 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i16 zeroext %29)
%31 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%32 = call i32 @bits(i32 5, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %31)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Normal\00"
@.str.1 = [10 x i8] c"Undefined\00"
@.str.2 = [11 x i8] c"Half Speed\00"
@reltable.cc2400_fstst2 = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_fstst2 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_fstst2 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_fstst2 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_fstst2 to i64)) to i32)]
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [3 x i8] c"W0\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [17 x i8] c"VCO_CURCAL_SPEED\00"
@.str.7 = [3 x i8] c"RW\00"
@.str.8 = [15 x i8] c"VCO_CURRENT_OE\00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [14 x i8] c"VCO_CURRENT_O\00"
@.str.11 = [16 x i8] c"VCO_CURRENT_RES\00"
@.str.12 = [3 x i8] c"RO\00"
define void @cc2400_fstst2(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 15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%5 = lshr i16 %0, 13
%6 = and i16 %5, 3
%7 = zext i16 %6 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.cc2400_fstst2 to i8*), i64 %8)
%10 = tail call i32 @bits(i32 14, i32 13, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %9)
%11 = tail call i32 @bits(i32 12, i32 12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%12 = lshr i16 %0, 6
%13 = and i16 %12, 63
%14 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i16 zeroext %13)
%15 = call i32 @bits(i32 11, i32 6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %3)
%16 = and i16 %0, 63
%17 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i16 zeroext %16)
%18 = call i32 @bits(i32 5, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %3)
ret void
}