#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_pamtst(unsigned short v) {
  char description[64];
  char *testmode[] = {"Output IQ from RxMIX",
                      "Input IQ to BPF",
                      "Output IQ from VGA",
                      "Input IQ to ADC",
                      "Output IQ from LPF",
                      "Input IQ to TxMIX",
                      "Output PN from Prescaler",
                      "Connects TX IF to RX IF and simultaneously the ATEST1 "
                      "pin to the internal VC node"};
  char *current[] = {"1.72 mA", "1.88 mA", "2.05 mA", "2.21 mA"};
  bits(15, 13, "-", "W0", "");
  bits(12, 12, "VC_IN_TEST_EN", "RW", "");
  bits(11, 11, "ATESTMOD_PD", "WO", "");
  bits(10, 8, "ATESTMOD_MODE", "RW", testmode[(v >> 8) & 7]);
  bits(7, 7, "-", "W0", "");
  bits(6, 5, "TXMIX_CAP_ARRAY", "RW", "");
  bits(4, 3, "TXMIX_CURRENT", "RW", current[(v >> 3) & 3]);
  sprintf(description, "%+d", (v & 0x7) - 3);
  bits(2, 0, "PA_CURRENT", "RW", description);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
lea    -0x90(%rbp),%rdi
lea    0x2c70(%rip),%rsi
mov    $0x40,%edx
call   1030 <memcpy@plt>
mov    0x2c9f(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0x2c99(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0x2c93(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0x2c8d(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    $0xf,%edi
mov    $0xd,%esi
lea    0xf55(%rip),%rdx
lea    0xf50(%rip),%rcx
lea    0xf48(%rip),%r8
call   1040 <bits@plt>
mov    $0xc,%esi
lea    0xf3b(%rip),%rdx
lea    0xf42(%rip),%rcx
lea    0xf29(%rip),%r8
mov    %esi,%edi
call   1040 <bits@plt>
mov    $0xb,%esi
lea    0xf2b(%rip),%rdx
lea    0xf30(%rip),%rcx
lea    0xf08(%rip),%r8
mov    %esi,%edi
call   1040 <bits@plt>
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
and    $0x7,%eax
cltq
mov    -0x90(%rbp,%rax,8),%r8
ff
mov    $0xa,%edi
mov    $0x8,%esi
lea    0xf00(%rip),%rdx
lea    0xee7(%rip),%rcx
call   1040 <bits@plt>
mov    $0x7,%esi
lea    0xec3(%rip),%rdx
lea    0xebe(%rip),%rcx
lea    0xeb6(%rip),%r8
mov    %esi,%edi
call   1040 <bits@plt>
mov    $0x6,%edi
mov    $0x5,%esi
lea    0xed0(%rip),%rdx
lea    0xea9(%rip),%rcx
lea    0xe90(%rip),%r8
call   1040 <bits@plt>
movzwl -0x2(%rbp),%eax
sar    $0x3,%eax
and    $0x3,%eax
cltq
mov    -0xb0(%rbp,%rax,8),%r8
ff
mov    $0x4,%edi
mov    $0x3,%esi
lea    0xea8(%rip),%rdx
lea    0xe71(%rip),%rcx
call   1040 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
and    $0x7,%eax
sub    $0x3,%eax
lea    0xe95(%rip),%rsi
movzwl %ax,%edx
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x2,%edi
xor    %esi,%esi
lea    0xe7f(%rip),%rdx
lea    0xe36(%rip),%rcx
call   1040 <bits@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebx
lea    0xfc2(%rip),%r12
lea    0xfbd(%rip),%r13
lea    0xfb5(%rip),%r15
mov    $0xf,%edi
mov    $0xd,%esi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
lea    0xf9a(%rip),%rdx
lea    0xfa1(%rip),%r14
mov    $0xc,%edi
mov    $0xc,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
lea    0xf88(%rip),%rdx
lea    0xf8d(%rip),%rcx
mov    $0xb,%edi
mov    $0xb,%esi
mov    %r15,%r8
call   1030 <bits@plt>
mov    %ebx,%eax
shr    $0x8,%eax
and    $0x7,%eax
lea    0xfaa(%rip),%rcx
movslq (%rcx,%rax,4),%r8
add    %rcx,%r8
lea    0xf61(%rip),%rdx
mov    $0xa,%edi
mov    $0x8,%esi
mov    %r14,%rcx
call   1030 <bits@plt>
mov    $0x7,%edi
mov    $0x7,%esi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
lea    0xf3e(%rip),%rdx
mov    $0x6,%edi
mov    $0x5,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
mov    %ebx,%eax
shr    $0x3,%eax
and    $0x3,%eax
lea    0xf67(%rip),%rcx
movslq (%rcx,%rax,4),%r8
add    %rcx,%r8
lea    0xf1c(%rip),%rdx
mov    $0x4,%edi
mov    $0x3,%esi
mov    %r14,%rcx
call   1030 <bits@plt>
and    $0x7,%ebx
add    $0xfffffffd,%ebx
movzwl %bx,%edx
lea    0xf08(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
lea    0xefa(%rip),%rdx
mov    $0x2,%edi
xor    %esi,%esi
mov    %r14,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Output IQ from RxMIX\00"
@.str.1 = [16 x i8] c"Input IQ to BPF\00"
@.str.2 = [19 x i8] c"Output IQ from VGA\00"
@.str.3 = [16 x i8] c"Input IQ to ADC\00"
@.str.4 = [19 x i8] c"Output IQ from LPF\00"
@.str.5 = [18 x i8] c"Input IQ to TxMIX\00"
@.str.6 = [25 x i8] c"Output PN from Prescaler\00"
@.str.7 = [82 x i8] c"Connects TX IF to RX IF and simultaneously the ATEST1 pin to the internal VC node\00"
@__const.cc2400_pamtst.testmode = [8 x i8*] [i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.7, i32 0, i32 0)]
@.str.8 = [8 x i8] c"1.72 mA\00"
@.str.9 = [8 x i8] c"1.88 mA\00"
@.str.10 = [8 x i8] c"2.05 mA\00"
@.str.11 = [8 x i8] c"2.21 mA\00"
@__const.cc2400_pamtst.current = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i32 0, i32 0)]
@.str.12 = [2 x i8] c"-\00"
@.str.13 = [3 x i8] c"W0\00"
@.str.14 = [1 x i8] zeroinitializer
@.str.15 = [14 x i8] c"VC_IN_TEST_EN\00"
@.str.16 = [3 x i8] c"RW\00"
@.str.17 = [12 x i8] c"ATESTMOD_PD\00"
@.str.18 = [3 x i8] c"WO\00"
@.str.19 = [14 x i8] c"ATESTMOD_MODE\00"
@.str.20 = [16 x i8] c"TXMIX_CAP_ARRAY\00"
@.str.21 = [14 x i8] c"TXMIX_CURRENT\00"
@.str.22 = [4 x i8] c"%+d\00"
@.str.23 = [11 x i8] c"PA_CURRENT\00"
define void @cc2400_pamtst(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [64 x i8]
%4 = alloca [8 x i8*]
%5 = alloca [4 x i8*]
store i16 %0, i16* %2
%6 = bitcast [8 x i8*]* %4 to i8*
%7 = bitcast [4 x i8*]* %5 to i8*
%8 = call i32 @bits(i32 15, i32 13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%9 = call i32 @bits(i32 12, i32 12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%10 = call i32 @bits(i32 11, i32 11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%11 = load i16, i16* %2
%12 = zext i16 %11 to i32
%13 = ashr i32 %12, 8
%14 = and i32 %13, 7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [8 x i8*], [8 x i8*]* %4, i64 0, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @bits(i32 10, i32 8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* %17)
%19 = call i32 @bits(i32 7, i32 7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%20 = call i32 @bits(i32 6, i32 5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%21 = load i16, i16* %2
%22 = zext i16 %21 to i32
%23 = ashr i32 %22, 3
%24 = and i32 %23, 3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @bits(i32 4, i32 3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%30 = load i16, i16* %2
%31 = zext i16 %30 to i32
%32 = and i32 %31, 7
%33 = sub nsw i32 %32, 3
%34 = trunc i32 %33 to i16
%35 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0), i16 zeroext %34)
%36 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%37 = call i32 @bits(i32 2, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* %36)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"Output IQ from RxMIX\00"
@.str.1 = [16 x i8] c"Input IQ to BPF\00"
@.str.2 = [19 x i8] c"Output IQ from VGA\00"
@.str.3 = [16 x i8] c"Input IQ to ADC\00"
@.str.4 = [19 x i8] c"Output IQ from LPF\00"
@.str.5 = [18 x i8] c"Input IQ to TxMIX\00"
@.str.6 = [25 x i8] c"Output PN from Prescaler\00"
@.str.7 = [82 x i8] c"Connects TX IF to RX IF and simultaneously the ATEST1 pin to the internal VC node\00"
@reltable.cc2400_pamtst = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_pamtst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_pamtst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_pamtst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_pamtst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_pamtst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_pamtst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_pamtst to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([82 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_pamtst to i64)) to i32)]
@.str.8 = [8 x i8] c"1.72 mA\00"
@.str.9 = [8 x i8] c"1.88 mA\00"
@.str.10 = [8 x i8] c"2.05 mA\00"
@.str.11 = [8 x i8] c"2.21 mA\00"
@reltable.cc2400_pamtst.24 = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.8 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_pamtst.24 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.9 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_pamtst.24 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.10 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_pamtst.24 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.11 to i64), i64 ptrtoint ([4 x i32]* @reltable.cc2400_pamtst.24 to i64)) to i32)]
@.str.12 = [2 x i8] c"-\00"
@.str.13 = [3 x i8] c"W0\00"
@.str.14 = [1 x i8] zeroinitializer
@.str.15 = [14 x i8] c"VC_IN_TEST_EN\00"
@.str.16 = [3 x i8] c"RW\00"
@.str.17 = [12 x i8] c"ATESTMOD_PD\00"
@.str.18 = [3 x i8] c"WO\00"
@.str.19 = [14 x i8] c"ATESTMOD_MODE\00"
@.str.20 = [16 x i8] c"TXMIX_CAP_ARRAY\00"
@.str.21 = [14 x i8] c"TXMIX_CURRENT\00"
@.str.22 = [4 x i8] c"%+d\00"
@.str.23 = [11 x i8] c"PA_CURRENT\00"
define void @cc2400_pamtst(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.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%5 = tail call i32 @bits(i32 12, i32 12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%6 = tail call i32 @bits(i32 11, i32 11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%7 = zext i16 %0 to i32
%8 = lshr i32 %7, 8
%9 = and i32 %8, 7
%10 = zext i32 %9 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.cc2400_pamtst to i8*), i64 %11)
%13 = tail call i32 @bits(i32 10, i32 8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* %12)
%14 = tail call i32 @bits(i32 7, i32 7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%15 = tail call i32 @bits(i32 6, i32 5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.14, i64 0, i64 0))
%16 = lshr i32 %7, 3
%17 = and i32 %16, 3
%18 = zext i32 %17 to i64
%19 = shl i64 %18, 2
%20 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.cc2400_pamtst.24 to i8*), i64 %19)
%21 = tail call i32 @bits(i32 4, i32 3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* %20)
%22 = and i16 %0, 7
%23 = add nsw i16 %22, -3
%24 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.22, i64 0, i64 0), i16 zeroext %23)
%25 = call i32 @bits(i32 2, i32 0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.23, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* %3)
ret void
}