#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 *);
void cc2400_iocfg(unsigned short v) {
  char *description[] = {
      "Off",
      "Output AGC status",
      "Output ADC I and Q values",
      "Output I/Q after digital down-mixing and channel filtering",
      "Output RX signal magnitude / frequency unfiltered",
      "Output RX signal magnitude / frequency filtered",
      "Output RSSI / RX frequency offset estimation",
      "Input DAC values"};
  bits(15, 15, "-", "W0", "");
  bits(14, 9, "GPIO6_CFG", "RW", "");
  bits(8, 3, "GPIO1_CFG", "RW", "");
  bits(2, 0, "HSSD_SRC", "RW", description[v & 0x7]);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2ca6(%rip),%rsi
mov    $0x40,%edx
call   1030 <memcpy@plt>
mov    $0xf,%esi
lea    0xfbb(%rip),%rdx
lea    0xfb6(%rip),%rcx
lea    0xfae(%rip),%r8
mov    %esi,%edi
call   1040 <bits@plt>
mov    $0xe,%edi
mov    $0x9,%esi
lea    0xf9a(%rip),%rdx
lea    0xf9d(%rip),%rcx
lea    0xf88(%rip),%r8
call   1040 <bits@plt>
mov    $0x8,%edi
mov    $0x3,%esi
lea    0xf83(%rip),%rdx
lea    0xf79(%rip),%rcx
lea    0xf64(%rip),%r8
call   1040 <bits@plt>
movzwl -0x2(%rbp),%eax
and    $0x7,%eax
cltq
mov    -0x50(%rbp,%rax,8),%r8
mov    $0x2,%edi
xor    %esi,%esi
lea    0xf5e(%rip),%rdx
lea    0xf4a(%rip),%rcx
call   1040 <bits@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xfed(%rip),%rdx
lea    0xfe8(%rip),%rcx
lea    0xfe0(%rip),%r15
mov    $0xf,%edi
mov    $0xf,%esi
mov    %r15,%r8
call   1030 <bits@plt>
lea    0xfcb(%rip),%rdx
lea    0xfce(%rip),%r14
mov    $0xe,%edi
mov    $0x9,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
lea    0xfb5(%rip),%rdx
mov    $0x8,%edi
mov    $0x3,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <bits@plt>
and    $0x7,%ebx
lea    0xfa9(%rip),%rax
movslq (%rax,%rbx,4),%r8
add    %rax,%r8
lea    0xf92(%rip),%rdx
mov    $0x2,%edi
xor    %esi,%esi
mov    %r14,%rcx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <bits@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"Off\00"
@.str.1 = [18 x i8] c"Output AGC status\00"
@.str.2 = [26 x i8] c"Output ADC I and Q values\00"
@.str.3 = [59 x i8] c"Output I/Q after digital down-mixing and channel filtering\00"
@.str.4 = [50 x i8] c"Output RX signal magnitude / frequency unfiltered\00"
@.str.5 = [48 x i8] c"Output RX signal magnitude / frequency filtered\00"
@.str.6 = [45 x i8] c"Output RSSI / RX frequency offset estimation\00"
@.str.7 = [17 x i8] c"Input DAC values\00"
@__const.cc2400_iocfg.description = [8 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 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 = [10 x i8] c"GPIO6_CFG\00"
@.str.12 = [3 x i8] c"RW\00"
@.str.13 = [10 x i8] c"GPIO1_CFG\00"
@.str.14 = [9 x i8] c"HSSD_SRC\00"
define void @cc2400_iocfg(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [8 x i8*]
store i16 %0, i16* %2
%4 = bitcast [8 x i8*]* %3 to i8*
%5 = 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))
%6 = call i32 @bits(i32 14, i32 9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%7 = call i32 @bits(i32 8, i32 3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%8 = load i16, i16* %2
%9 = zext i16 %8 to i32
%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 2, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %13)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"Off\00"
@.str.1 = [18 x i8] c"Output AGC status\00"
@.str.2 = [26 x i8] c"Output ADC I and Q values\00"
@.str.3 = [59 x i8] c"Output I/Q after digital down-mixing and channel filtering\00"
@.str.4 = [50 x i8] c"Output RX signal magnitude / frequency unfiltered\00"
@.str.5 = [48 x i8] c"Output RX signal magnitude / frequency filtered\00"
@.str.6 = [45 x i8] c"Output RSSI / RX frequency offset estimation\00"
@.str.7 = [17 x i8] c"Input DAC values\00"
@reltable.cc2400_iocfg = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_iocfg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_iocfg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_iocfg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([59 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_iocfg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([50 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_iocfg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([48 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_iocfg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([45 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_iocfg to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.cc2400_iocfg 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 = [10 x i8] c"GPIO6_CFG\00"
@.str.12 = [3 x i8] c"RW\00"
@.str.13 = [10 x i8] c"GPIO1_CFG\00"
@.str.14 = [9 x i8] c"HSSD_SRC\00"
define void @cc2400_iocfg(i16 zeroext %0) {
%2 = 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))
%3 = tail call i32 @bits(i32 14, i32 9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%4 = tail call i32 @bits(i32 8, i32 3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%5 = and i16 %0, 7
%6 = zext i16 %5 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.cc2400_iocfg to i8*), i64 %7)
%9 = tail call i32 @bits(i32 2, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %8)
ret void
}