#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_fstst3(unsigned short v) {
  char *period[] = {"0.25us", "0.5us", "1us", "4us"};
  char description[64];
  bits(15, 14, "-", "W0", "");
  bits(13, 13, "CHP_TEST_UP", "RW", "");
  bits(12, 12, "CHP_TEST_DN", "RW", "");
  bits(11, 11, "CHP_DISABLE", "RW", "");
  bits(10, 10, "PD_DELAY", "RW", ((v >> 11) & 1) ? "Long" : "Short");
  bits(9, 8, "CHP_STEP_PERIOD", "RW", period[(v >> 8) & 3]);
  sprintf(description, "%d", (v >> 4) & 0xF);
  bits(7, 4, "STOP_CHP_CURRENT", "RW", description);
  sprintf(description, "%d", v & 0xF);
  bits(3, 0, "START_CHP_CURRENT", "RW", 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,%edi
mov    $0xe,%esi
lea    0xea9(%rip),%rdx
lea    0xea4(%rip),%rcx
lea    0xe9c(%rip),%r8
call   1030 <bits@plt>
mov    $0xd,%esi
lea    0xe8f(%rip),%rdx
lea    0xe94(%rip),%rcx
lea    0xe7d(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
mov    $0xc,%esi
lea    0xe7d(%rip),%rdx
lea    0xe73(%rip),%rcx
lea    0xe5c(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
mov    $0xb,%esi
lea    0xe68(%rip),%rdx
lea    0xe52(%rip),%rcx
lea    0xe3b(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
movzwl -0x2(%rbp),%ecx
sar    $0xb,%ecx
and    $0x1,%ecx
lea    0xe5c(%rip),%r8
lea    0xe50(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%r8
mov    $0xa,%esi
lea    0xe34(%rip),%rdx
lea    0xe12(%rip),%rcx
mov    %esi,%edi
call   1030 <bits@plt>
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
and    $0x3,%eax
cltq
mov    -0x30(%rbp,%rax,8),%r8
mov    $0x9,%edi
mov    $0x8,%esi
lea    0xe18(%rip),%rdx
lea    0xde2(%rip),%rcx
call   1030 <bits@plt>
lea    -0x70(%rbp),%rdi
movzwl -0x2(%rbp),%eax
sar    $0x4,%eax
and    $0xf,%eax
lea    0xe07(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%r8
mov    $0x7,%edi
mov    $0x4,%esi
lea    0xded(%rip),%rdx
lea    0xda4(%rip),%rcx
call   1030 <bits@plt>
lea    -0x70(%rbp),%rdi
movzwl -0x2(%rbp),%eax
and    $0xf,%eax
lea    0xdcc(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%r8
mov    $0x3,%edi
xor    %esi,%esi
lea    0xdc6(%rip),%rdx
lea    0xd6c(%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    0xee1(%rip),%rdx
lea    0xedc(%rip),%rcx
lea    0xed4(%rip),%r15
mov    $0xf,%edi
mov    $0xe,%esi
mov    %r15,%r8
call   1030 <bits@plt>
lea    0xebf(%rip),%rdx
lea    0xec4(%rip),%r14
mov    $0xd,%edi
mov    $0xd,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
lea    0xeab(%rip),%rdx
mov    $0xc,%edi
mov    $0xc,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
lea    0xe9b(%rip),%rdx
mov    $0xb,%edi
mov    $0xb,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
test   $0x800,%ebx
lea    0xe93(%rip),%rax
lea    0xe87(%rip),%r8
cmove  %rax,%r8
lea    0xe73(%rip),%rdx
mov    $0xa,%edi
mov    $0xa,%esi
mov    %r14,%rcx
call   1030 <bits@plt>
mov    %ebx,%eax
shr    $0x8,%eax
and    $0x3,%eax
lea    0xe9d(%rip),%rcx
movslq (%rcx,%rax,4),%r8
add    %rcx,%r8
lea    0xe58(%rip),%rdx
mov    $0x9,%edi
mov    $0x8,%esi
mov    %r14,%rcx
call   1030 <bits@plt>
mov    %ebx,%edx
shr    $0x4,%edx
and    $0xf,%edx
lea    0xe47(%rip),%r12
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <sprintf@plt>
lea    0xe35(%rip),%rdx
mov    $0x7,%edi
mov    $0x4,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
and    $0xf,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1040 <sprintf@plt>
lea    0xe1a(%rip),%rdx
mov    $0x3,%edi
xor    %esi,%esi
mov    %r14,%rcx
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"0.25us\00"
@.str.1 = [6 x i8] c"0.5us\00"
@.str.2 = [4 x i8] c"1us\00"
@.str.3 = [4 x i8] c"4us\00"
@__const.cc2400_fstst3.period = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [2 x i8] c"-\00"
@.str.5 = [3 x i8] c"W0\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [12 x i8] c"CHP_TEST_UP\00"
@.str.8 = [3 x i8] c"RW\00"
@.str.9 = [12 x i8] c"CHP_TEST_DN\00"
@.str.10 = [12 x i8] c"CHP_DISABLE\00"
@.str.11 = [9 x i8] c"PD_DELAY\00"
@.str.12 = [5 x i8] c"Long\00"
@.str.13 = [6 x i8] c"Short\00"
@.str.14 = [16 x i8] c"CHP_STEP_PERIOD\00"
@.str.15 = [3 x i8] c"%d\00"
@.str.16 = [17 x i8] c"STOP_CHP_CURRENT\00"
@.str.17 = [18 x i8] c"START_CHP_CURRENT\00"
define void @cc2400_fstst3(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 14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%7 = call i32 @bits(i32 13, i32 13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%8 = call i32 @bits(i32 12, i32 12, 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.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @bits(i32 11, i32 11, 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.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%10 = load i16, i16* %2
%11 = zext i16 %10 to i32
%12 = ashr i32 %11, 11
%13 = and i32 %12, 1
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0)
%17 = call i32 @bits(i32 10, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, 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*]* %3, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @bits(i32 9, i32 8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%27 = load i16, i16* %2
%28 = zext i16 %27 to i32
%29 = ashr i32 %28, 4
%30 = and i32 %29, 15
%31 = trunc i32 %30 to i16
%32 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i16 zeroext %31)
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%34 = call i32 @bits(i32 7, i32 4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%36 = load i16, i16* %2
%37 = zext i16 %36 to i32
%38 = and i32 %37, 15
%39 = trunc i32 %38 to i16
%40 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i16 zeroext %39)
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%42 = call i32 @bits(i32 3, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %41)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"0.25us\00"
@.str.1 = [6 x i8] c"0.5us\00"
@.str.2 = [4 x i8] c"1us\00"
@.str.3 = [4 x i8] c"4us\00"
@reltable.cc2400_fstst3 = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_fstst3 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_fstst3 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_fstst3 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_fstst3 to i64)) to i32)]
@.str.4 = [2 x i8] c"-\00"
@.str.5 = [3 x i8] c"W0\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [12 x i8] c"CHP_TEST_UP\00"
@.str.8 = [3 x i8] c"RW\00"
@.str.9 = [12 x i8] c"CHP_TEST_DN\00"
@.str.10 = [12 x i8] c"CHP_DISABLE\00"
@.str.11 = [9 x i8] c"PD_DELAY\00"
@.str.12 = [5 x i8] c"Long\00"
@.str.13 = [6 x i8] c"Short\00"
@.str.14 = [16 x i8] c"CHP_STEP_PERIOD\00"
@.str.15 = [3 x i8] c"%d\00"
@.str.16 = [17 x i8] c"STOP_CHP_CURRENT\00"
@.str.17 = [18 x i8] c"START_CHP_CURRENT\00"
define void @cc2400_fstst3(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 14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%5 = tail call i32 @bits(i32 13, i32 13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%6 = tail call i32 @bits(i32 12, i32 12, 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.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%7 = tail call i32 @bits(i32 11, i32 11, 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.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%8 = zext i16 %0 to i32
%9 = and i32 %8, 2048
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0)
%12 = tail call i32 @bits(i32 10, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %11)
%13 = lshr i32 %8, 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_fstst3 to i8*), i64 %16)
%18 = tail call i32 @bits(i32 9, i32 8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %17)
%19 = lshr i16 %0, 4
%20 = and i16 %19, 15
%21 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i16 zeroext %20)
%22 = call i32 @bits(i32 7, i32 4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %3)
%23 = and i16 %0, 15
%24 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i16 zeroext %23)
%25 = call i32 @bits(i32 3, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %3)
ret void
}