#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 *, int);
void cc2400_fsctrl(unsigned short v) {
  char description[64];
  bits(15, 6, "-", "W0", "");
  sprintf(description, "periods=%d", 1 << (((v & 0x30) >> 4) + 6));
  bits(5, 4, "LOCK_THRESHOLD", "RW", description);
  bits(3, 3, "CAL_DONE", "RO", "");
  bits(2, 2, "CAL_RUNNING", "RO", "");
  sprintf(description, "periods=%d", 2 + (v & 0x2));
  bits(1, 1, "LOCK_LENGTH", "RW", description);
  bits(0, 0, "LOCK_STATUS", "RO", "");
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    $0xf,%edi
mov    $0x6,%esi
lea    0xec0(%rip),%rdx
lea    0xebb(%rip),%rcx
lea    0xeb3(%rip),%r8
call   1030 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%ecx
and    $0x30,%ecx
sar    $0x4,%ecx
add    $0x6,%ecx
mov    $0x1,%edx
shl    %cl,%edx
lea    0xe93(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x5,%edi
mov    $0x4,%esi
lea    0xe84(%rip),%rdx
lea    0xe8c(%rip),%rcx
call   1030 <bits@plt>
mov    $0x3,%esi
lea    0xe7e(%rip),%rdx
lea    0xe80(%rip),%rcx
lea    0xe4f(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
mov    $0x2,%esi
lea    0xe69(%rip),%rdx
lea    0xe5f(%rip),%rcx
lea    0xe2e(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%edx
and    $0x2,%edx
add    $0x2,%edx
lea    0xe16(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x1,%esi
lea    0xe36(%rip),%rdx
lea    0xe14(%rip),%rcx
mov    %esi,%edi
call   1030 <bits@plt>
xor    %esi,%esi
lea    0xe2b(%rip),%rdx
lea    0xe09(%rip),%rcx
lea    0xdd8(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebp
lea    0xec9(%rip),%rdx
lea    0xec4(%rip),%rcx
lea    0xebc(%rip),%r14
mov    $0xf,%edi
mov    $0x6,%esi
mov    %r14,%r8
call   1030 <bits@plt>
mov    %ebp,%ecx
shr    $0x4,%cl
and    $0x3,%cl
mov    $0x40,%edx
shl    %cl,%edx
lea    0xe98(%rip),%r12
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <sprintf@plt>
lea    0xe8e(%rip),%rdx
lea    0xe96(%rip),%r15
mov    $0x5,%edi
mov    $0x4,%esi
mov    %r15,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
lea    0xe7d(%rip),%rdx
lea    0xe7f(%rip),%r13
mov    $0x3,%edi
mov    $0x3,%esi
mov    %r13,%rcx
mov    %r14,%r8
call   1030 <bits@plt>
lea    0xe66(%rip),%rdx
mov    $0x2,%edi
mov    $0x2,%esi
mov    %r13,%rcx
mov    %r14,%r8
call   1030 <bits@plt>
and    $0x2,%ebp
add    $0x2,%ebp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1040 <sprintf@plt>
lea    0xe43(%rip),%rdx
mov    $0x1,%edi
mov    $0x1,%esi
mov    %r15,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
lea    0xe33(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    %r13,%rcx
mov    %r14,%r8
call   1030 <bits@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [3 x i8] c"W0\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"periods=%d\00"
@.str.4 = [15 x i8] c"LOCK_THRESHOLD\00"
@.str.5 = [3 x i8] c"RW\00"
@.str.6 = [9 x i8] c"CAL_DONE\00"
@.str.7 = [3 x i8] c"RO\00"
@.str.8 = [12 x i8] c"CAL_RUNNING\00"
@.str.9 = [12 x i8] c"LOCK_LENGTH\00"
@.str.10 = [12 x i8] c"LOCK_STATUS\00"
define void @cc2400_fsctrl(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [64 x i8]
store i16 %0, i16* %2
%4 = call i32 @bits(i32 15, i32 6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = load i16, i16* %2
%7 = zext i16 %6 to i32
%8 = and i32 %7, 48
%9 = ashr i32 %8, 4
%10 = add nsw i32 %9, 6
%11 = shl i32 1, %10
%12 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%14 = call i32 @bits(i32 5, i32 4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %13)
%15 = call i32 @bits(i32 3, i32 3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, 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.2, i64 0, i64 0))
%16 = call i32 @bits(i32 2, i32 2, i8* getelementptr inbounds ([12 x i8], [12 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.2, i64 0, i64 0))
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%18 = load i16, i16* %2
%19 = zext i16 %18 to i32
%20 = and i32 %19, 2
%21 = add nsw i32 2, %20
%22 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%24 = call i32 @bits(i32 1, i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %23)
%25 = call i32 @bits(i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, 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.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [3 x i8] c"W0\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"periods=%d\00"
@.str.4 = [15 x i8] c"LOCK_THRESHOLD\00"
@.str.5 = [3 x i8] c"RW\00"
@.str.6 = [9 x i8] c"CAL_DONE\00"
@.str.7 = [3 x i8] c"RO\00"
@.str.8 = [12 x i8] c"CAL_RUNNING\00"
@.str.9 = [12 x i8] c"LOCK_LENGTH\00"
@.str.10 = [12 x i8] c"LOCK_STATUS\00"
define void @cc2400_fsctrl(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 6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%5 = zext i16 %0 to i32
%6 = lshr i32 %5, 4
%7 = and i32 %6, 3
%8 = shl nuw nsw i32 64, %7
%9 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = call i32 @bits(i32 5, i32 4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%11 = call i32 @bits(i32 3, i32 3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, 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.2, i64 0, i64 0))
%12 = call i32 @bits(i32 2, i32 2, i8* getelementptr inbounds ([12 x i8], [12 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.2, i64 0, i64 0))
%13 = and i32 %5, 2
%14 = add nuw nsw i32 %13, 2
%15 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = call i32 @bits(i32 1, i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%17 = call i32 @bits(i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, 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.2, i64 0, i64 0))
ret void
}