#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_dactst(unsigned short v) {
  char *src[] = {"Normal",
                 "Override",
                 "From ADC",
                 "I/Q after digital down-mixing and channel filtering",
                 "Full-spectrum White Noise",
                 "RX signal magnitude/frequency",
                 "RSSI/RX frequency offset estimation",
                 "HSSD Module"};
  char description[64];
  bits(15, 15, "-", "W0", "");
  bits(14, 12, "DAC_SRC", "RW", src[(v >> 12) & 0x7]);
  sprintf(description, "%d", (v >> 6) & 0x3F);
  bits(11, 6, "DAC_I_O", "RW", description);
  sprintf(description, "%d", v & 0x3F);
  bits(5, 0, "DAC_Q_O", "RW", description);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c93(%rip),%rsi
mov    $0x40,%edx
call   1030 <memcpy@plt>
mov    $0xf,%esi
lea    0xf52(%rip),%rdx
lea    0xf4d(%rip),%rcx
lea    0xf45(%rip),%r8
mov    %esi,%edi
call   1040 <bits@plt>
movzwl -0x2(%rbp),%eax
sar    $0xc,%eax
and    $0x7,%eax
cltq
mov    -0x50(%rbp,%rax,8),%r8
mov    $0xe,%edi
mov    $0xc,%esi
lea    0xf20(%rip),%rdx
lea    0xf21(%rip),%rcx
call   1040 <bits@plt>
lea    -0x90(%rbp),%rdi
movzwl -0x2(%rbp),%eax
sar    $0x6,%eax
and    $0x3f,%eax
lea    0xf07(%rip),%rsi
movzwl %ax,%edx
call   1050 <sprintf@plt>
lea    -0x90(%rbp),%r8
mov    $0xb,%edi
mov    $0x6,%esi
lea    0xeea(%rip),%rdx
lea    0xedd(%rip),%rcx
call   1040 <bits@plt>
lea    -0x90(%rbp),%rdi
movzwl -0x2(%rbp),%eax
and    $0x3f,%eax
lea    0xec6(%rip),%rsi
movzwl %ax,%edx
call   1050 <sprintf@plt>
lea    -0x90(%rbp),%r8
mov    $0x5,%edi
xor    %esi,%esi
lea    0xeb4(%rip),%rdx
lea    0xe9f(%rip),%rcx
call   1040 <bits@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebx
lea    0xf81(%rip),%rdx
lea    0xf7c(%rip),%rcx
lea    0xf74(%rip),%r8
mov    $0xf,%edi
mov    $0xf,%esi
call   1030 <bits@plt>
mov    %ebx,%eax
shr    $0xc,%eax
and    $0x7,%eax
lea    0xf78(%rip),%rcx
movslq (%rcx,%rax,4),%r8
add    %rcx,%r8
lea    0xf4c(%rip),%rdx
lea    0xf4d(%rip),%r14
mov    $0xe,%edi
mov    $0xc,%esi
mov    %r14,%rcx
call   1030 <bits@plt>
mov    %ebx,%edx
shr    $0x6,%edx
and    $0x3f,%edx
lea    0xf2f(%rip),%r12
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <sprintf@plt>
lea    0xf1d(%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    0xef9(%rip),%rdx
mov    $0x5,%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"Normal\00"
@.str.1 = [9 x i8] c"Override\00"
@.str.2 = [9 x i8] c"From ADC\00"
@.str.3 = [52 x i8] c"I/Q after digital down-mixing and channel filtering\00"
@.str.4 = [26 x i8] c"Full-spectrum White Noise\00"
@.str.5 = [30 x i8] c"RX signal magnitude/frequency\00"
@.str.6 = [36 x i8] c"RSSI/RX frequency offset estimation\00"
@.str.7 = [12 x i8] c"HSSD Module\00"
@__const.cc2400_dactst.src = [8 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 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 = [8 x i8] c"DAC_SRC\00"
@.str.12 = [3 x i8] c"RW\00"
@.str.13 = [3 x i8] c"%d\00"
@.str.14 = [8 x i8] c"DAC_I_O\00"
@.str.15 = [8 x i8] c"DAC_Q_O\00"
define void @cc2400_dactst(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [8 x i8*]
%4 = alloca [64 x i8]
store i16 %0, i16* %2
%5 = bitcast [8 x i8*]* %3 to i8*
%6 = call i32 @bits(i32 15, i32 15, 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))
%7 = load i16, i16* %2
%8 = zext i16 %7 to i32
%9 = ashr i32 %8, 12
%10 = and i32 %9, 7
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [8 x i8*], [8 x i8*]* %3, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = call i32 @bits(i32 14, i32 12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%16 = load i16, i16* %2
%17 = zext i16 %16 to i32
%18 = ashr i32 %17, 6
%19 = and i32 %18, 63
%20 = trunc i32 %19 to i16
%21 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i16 zeroext %20)
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%23 = call i32 @bits(i32 11, i32 6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%25 = load i16, i16* %2
%26 = zext i16 %25 to i32
%27 = and i32 %26, 63
%28 = trunc i32 %27 to i16
%29 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i16 zeroext %28)
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%31 = call i32 @bits(i32 5, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %30)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Normal\00"
@.str.1 = [9 x i8] c"Override\00"
@.str.2 = [9 x i8] c"From ADC\00"
@.str.3 = [52 x i8] c"I/Q after digital down-mixing and channel filtering\00"
@.str.4 = [26 x i8] c"Full-spectrum White Noise\00"
@.str.5 = [30 x i8] c"RX signal magnitude/frequency\00"
@.str.6 = [36 x i8] c"RSSI/RX frequency offset estimation\00"
@.str.7 = [12 x i8] c"HSSD Module\00"
@reltable.cc2400_dactst = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_dactst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_dactst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_dactst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([52 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_dactst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_dactst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([30 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_dactst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([36 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_dactst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_dactst 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 = [8 x i8] c"DAC_SRC\00"
@.str.12 = [3 x i8] c"RW\00"
@.str.13 = [3 x i8] c"%d\00"
@.str.14 = [8 x i8] c"DAC_I_O\00"
@.str.15 = [8 x i8] c"DAC_Q_O\00"
define void @cc2400_dactst(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.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 = lshr i16 %0, 12
%6 = and i16 %5, 7
%7 = zext i16 %6 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.cc2400_dactst to i8*), i64 %8)
%10 = tail call i32 @bits(i32 14, i32 12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %9)
%11 = lshr i16 %0, 6
%12 = and i16 %11, 63
%13 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i16 zeroext %12)
%14 = call i32 @bits(i32 11, i32 6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %3)
%15 = and i16 %0, 63
%16 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i16 zeroext %15)
%17 = call i32 @bits(i32 5, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %3)
ret void
}