#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);
int /*<<< orphan*/ strcpy(char *, char *);
void cc2400_agctst1(unsigned short v) {
  char description[64];
  bits(15, 15, "-", "W0", "");
  bits(14, 14, "AGC_VAR_GAIN_SAT", "RW", (v & 0x4000) ? "-3/-5" : "-1/-3");
  if (((v >> 11) & 7) == 0)
    strcpy(description, "Disabled");
  else
    sprintf(description, "%d * 8 MHz clock cycles", (v >> 11) & 7);
  bits(13, 11, "AGC_SETTLE_BLANK_UP", "RW", description);
  bits(10, 10, "PEAKDET_CUR_BOOST", "RW", "");
  sprintf(description, "%d", (v >> 6) & 7);
  bits(9, 6, "AGC_MULT_SLOW", "RW", description);
  sprintf(description, "%d", (v >> 2) & 7);
  bits(5, 2, "AGC_SETTLE_FIXED", "RW", description);
  sprintf(description, "%d", v & 3);
  bits(1, 0, "AGC_SETTLE_VAR", "RW", description);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    $0xf,%esi
lea    0xeb5(%rip),%rdx
lea    0xeb0(%rip),%rcx
lea    0xea8(%rip),%r8
mov    %esi,%edi
call   1040 <bits@plt>
movzwl -0x2(%rbp),%ecx
and    $0x4000,%ecx
lea    0xeae(%rip),%r8
lea    0xea1(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%r8
mov    $0xe,%esi
lea    0xe7a(%rip),%rdx
lea    0xe84(%rip),%rcx
mov    %esi,%edi
call   1040 <bits@plt>
movzwl -0x2(%rbp),%eax
sar    $0xb,%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    11c1 <cc2400_agctst1+0x91>
lea    -0x50(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11de <cc2400_agctst1+0xae>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
sar    $0xb,%eax
and    $0x7,%eax
lea    0xe58(%rip),%rsi
movzwl %ax,%edx
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0xd,%edi
mov    $0xb,%esi
lea    0xe53(%rip),%rdx
lea    0xe1c(%rip),%rcx
call   1040 <bits@plt>
mov    $0xa,%esi
lea    0xe4f(%rip),%rdx
lea    0xe04(%rip),%rcx
lea    0xde8(%rip),%r8
mov    %esi,%edi
call   1040 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
sar    $0x6,%eax
and    $0x7,%eax
lea    0xe37(%rip),%rsi
movzwl %ax,%edx
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x9,%edi
mov    $0x6,%esi
lea    0xe1d(%rip),%rdx
lea    0xdbd(%rip),%rcx
call   1040 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
sar    $0x2,%eax
and    $0x7,%eax
lea    0xdf9(%rip),%rsi
movzwl %ax,%edx
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x5,%edi
mov    $0x2,%esi
lea    0xded(%rip),%rdx
lea    0xd7f(%rip),%rcx
call   1040 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
and    $0x3,%eax
lea    0xdbe(%rip),%rsi
movzwl %ax,%edx
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x1,%edi
xor    %esi,%esi
lea    0xdc6(%rip),%rdx
lea    0xd47(%rip),%rcx
call   1040 <bits@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebx
lea    0xebc(%rip),%rdx
lea    0xeb7(%rip),%rcx
lea    0xeaf(%rip),%r8
mov    $0xf,%edi
mov    $0xf,%esi
call   1040 <bits@plt>
test   $0x4000,%ebx
lea    0xeb1(%rip),%rax
lea    0xea4(%rip),%r8
cmove  %rax,%r8
lea    0xe85(%rip),%rdx
lea    0xe8f(%rip),%rcx
mov    $0xe,%edi
mov    $0xe,%esi
call   1040 <bits@plt>
mov    %ebx,%eax
shr    $0xb,%eax
and    $0x7,%eax
je     11b4 <cc2400_agctst1+0x84>
movzwl %ax,%edx
lea    0xe84(%rip),%rsi
mov    %rsp,%rdi
call   1050 <sprintf@plt>
jmp    11c3 <cc2400_agctst1+0x93>
lea    0xe6a(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
lea    0xe7c(%rip),%rdx
lea    0xe45(%rip),%r14
mov    %rsp,%r15
mov    $0xd,%edi
mov    $0xb,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <bits@plt>
lea    0xe6a(%rip),%rdx
lea    0xe0a(%rip),%r8
mov    $0xa,%edi
mov    $0xa,%esi
mov    %r14,%rcx
call   1040 <bits@plt>
mov    %ebx,%edx
shr    $0x6,%edx
and    $0x7,%edx
lea    0xe54(%rip),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0xe45(%rip),%rdx
mov    $0x9,%edi
mov    $0x6,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <bits@plt>
mov    %ebx,%edx
shr    $0x2,%edx
and    $0x7,%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0xe24(%rip),%rdx
mov    $0x5,%edi
mov    $0x2,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <bits@plt>
and    $0x3,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1050 <sprintf@plt>
lea    0xe09(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <bits@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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 = [17 x i8] c"AGC_VAR_GAIN_SAT\00"
@.str.4 = [3 x i8] c"RW\00"
@.str.5 = [6 x i8] c"-3/-5\00"
@.str.6 = [6 x i8] c"-1/-3\00"
@.str.7 = [9 x i8] c"Disabled\00"
@.str.8 = [24 x i8] c"%d * 8 MHz clock cycles\00"
@.str.9 = [20 x i8] c"AGC_SETTLE_BLANK_UP\00"
@.str.10 = [18 x i8] c"PEAKDET_CUR_BOOST\00"
@.str.11 = [3 x i8] c"%d\00"
@.str.12 = [14 x i8] c"AGC_MULT_SLOW\00"
@.str.13 = [17 x i8] c"AGC_SETTLE_FIXED\00"
@.str.14 = [15 x i8] c"AGC_SETTLE_VAR\00"
define void @cc2400_agctst1(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [64 x i8]
store i16 %0, i16* %2
%4 = call i32 @bits(i32 15, i32 15, 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 = load i16, i16* %2
%6 = zext i16 %5 to i32
%7 = and i32 %6, 16384
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i64
%10 = select i1 %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0)
%11 = call i32 @bits(i32 14, i32 14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%12 = load i16, i16* %2
%13 = zext i16 %12 to i32
%14 = ashr i32 %13, 11
%15 = and i32 %14, 7
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %28
20: ; preds = %1
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%22 = load i16, i16* %2
%23 = zext i16 %22 to i32
%24 = ashr i32 %23, 11
%25 = and i32 %24, 7
%26 = trunc i32 %25 to i16
%27 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i16 zeroext %26)
br label %28
28: ; preds = %20, %17
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%30 = call i32 @bits(i32 13, i32 11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = call i32 @bits(i32 10, i32 10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%33 = load i16, i16* %2
%34 = zext i16 %33 to i32
%35 = ashr i32 %34, 6
%36 = and i32 %35, 7
%37 = trunc i32 %36 to i16
%38 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i16 zeroext %37)
%39 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%40 = call i32 @bits(i32 9, i32 6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%42 = load i16, i16* %2
%43 = zext i16 %42 to i32
%44 = ashr i32 %43, 2
%45 = and i32 %44, 7
%46 = trunc i32 %45 to i16
%47 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i16 zeroext %46)
%48 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%49 = call i32 @bits(i32 5, i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %48)
%50 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%51 = load i16, i16* %2
%52 = zext i16 %51 to i32
%53 = and i32 %52, 3
%54 = trunc i32 %53 to i16
%55 = call i32 @sprintf(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i16 zeroext %54)
%56 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%57 = call i32 @bits(i32 1, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %56)
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 = [17 x i8] c"AGC_VAR_GAIN_SAT\00"
@.str.4 = [3 x i8] c"RW\00"
@.str.5 = [6 x i8] c"-3/-5\00"
@.str.6 = [6 x i8] c"-1/-3\00"
@.str.7 = [9 x i8] c"Disabled\00"
@.str.8 = [24 x i8] c"%d * 8 MHz clock cycles\00"
@.str.9 = [20 x i8] c"AGC_SETTLE_BLANK_UP\00"
@.str.10 = [18 x i8] c"PEAKDET_CUR_BOOST\00"
@.str.11 = [3 x i8] c"%d\00"
@.str.12 = [14 x i8] c"AGC_MULT_SLOW\00"
@.str.13 = [17 x i8] c"AGC_SETTLE_FIXED\00"
@.str.14 = [15 x i8] c"AGC_SETTLE_VAR\00"
define void @cc2400_agctst1(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, 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 = and i32 %5, 16384
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
%9 = tail call i32 @bits(i32 14, i32 14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%10 = lshr i32 %5, 11
%11 = and i32 %10, 7
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %18
15: ; preds = %1
%16 = trunc i32 %11 to i16
%17 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i16 zeroext %16)
br label %18
18: ; preds = %15, %13
%19 = call i32 @bits(i32 13, i32 11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%20 = call i32 @bits(i32 10, i32 10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%21 = lshr i16 %0, 6
%22 = and i16 %21, 7
%23 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i16 zeroext %22)
%24 = call i32 @bits(i32 9, i32 6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%25 = lshr i16 %0, 2
%26 = and i16 %25, 7
%27 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i16 zeroext %26)
%28 = call i32 @bits(i32 5, i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%29 = and i16 %0, 3
%30 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i16 zeroext %29)
%31 = call i32 @bits(i32 1, i32 0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
ret void
}