#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 */
typedef int v;

/* Variables and functions */
int /*<<< orphan*/ bits(int, int, char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
void cc2400_agctst0(unsigned short v) {
  char description[64];
  if (((v >> 13) & 0x7) == 0)
    strcpy(description, "Disabled");
  else
    sprintf(description, "%d * 8 MHz clock cycles", (v >> 13) & 0x7);
  bits(15, 13, "AGC_SETTLE_BLANK_DN", "RW", description);
  sprintf(description, "%d", (v >> 11) & 0x3);
  bits(12, 11, "AGC_WIN_SIZE", "RW", description);
  sprintf(description, "%d", (v >> 7) & 0xF);
  bits(10, 7, "AGC_SETTLE_PEAK", "RW", description);
  sprintf(description, "%d", (v >> 3) & 0xF);
  bits(6, 3, "AGC_SETTLE_ADC", "RW", description);
  sprintf(description, "%d", (v)&0x3);
  bits(2, 0, "AGC_ATTEMPTS", "RW", description);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
sar    $0xd,%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    1167 <cc2400_agctst0+0x37>
lea    -0x50(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1181 <cc2400_agctst0+0x51>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%edx
sar    $0xd,%edx
and    $0x7,%edx
lea    0xe8d(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0xf,%edi
mov    $0xd,%esi
lea    0xe8b(%rip),%rdx
lea    0xe98(%rip),%rcx
call   1040 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%edx
sar    $0xb,%edx
and    $0x3,%edx
lea    0xe81(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0xc,%edi
mov    $0xb,%esi
lea    0xe6a(%rip),%rdx
lea    0xe5d(%rip),%rcx
call   1040 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%edx
sar    $0x7,%edx
and    $0xf,%edx
lea    0xe46(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0xa,%edi
mov    $0x7,%esi
lea    0xe3c(%rip),%rdx
lea    0xe22(%rip),%rcx
call   1040 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%edx
sar    $0x3,%edx
and    $0xf,%edx
lea    0xe0b(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x6,%edi
mov    $0x3,%esi
lea    0xe11(%rip),%rdx
lea    0xde7(%rip),%rcx
call   1040 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%edx
and    $0x3,%edx
lea    0xdd3(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x2,%edi
xor    %esi,%esi
lea    0xdeb(%rip),%rdx
lea    0xdb2(%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
cmp    $0x1fff,%edi
ja     1156 <cc2400_agctst0+0x26>
lea    0xeb4(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
jmp    116a <cc2400_agctst0+0x3a>
mov    %ebx,%edx
shr    $0xd,%edx
lea    0xea7(%rip),%rsi
mov    %rsp,%rdi
call   1050 <sprintf@plt>
lea    0xeb0(%rip),%rdx
lea    0xebd(%rip),%r14
mov    %rsp,%r15
mov    $0xf,%edi
mov    $0xd,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <bits@plt>
mov    %ebx,%edx
shr    $0xb,%edx
and    $0x3,%edx
lea    0xe99(%rip),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0xe8a(%rip),%rdx
mov    $0xc,%edi
mov    $0xb,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <bits@plt>
mov    %ebx,%edx
shr    $0x7,%edx
and    $0xf,%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0xe68(%rip),%rdx
mov    $0xa,%edi
mov    $0x7,%esi
mov    %r14,%rcx
mov    %r15,%r8
call   1040 <bits@plt>
mov    %ebx,%edx
shr    $0x3,%edx
and    $0xf,%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <sprintf@plt>
lea    0xe49(%rip),%rdx
mov    $0x6,%edi
mov    $0x3,%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    0xe2c(%rip),%rdx
mov    $0x2,%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 = [9 x i8] c"Disabled\00"
@.str.1 = [24 x i8] c"%d * 8 MHz clock cycles\00"
@.str.2 = [20 x i8] c"AGC_SETTLE_BLANK_DN\00"
@.str.3 = [3 x i8] c"RW\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [13 x i8] c"AGC_WIN_SIZE\00"
@.str.6 = [16 x i8] c"AGC_SETTLE_PEAK\00"
@.str.7 = [15 x i8] c"AGC_SETTLE_ADC\00"
@.str.8 = [13 x i8] c"AGC_ATTEMPTS\00"
define void @cc2400_agctst0(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [64 x i8]
store i16 %0, i16* %2
%4 = load i16, i16* %2
%5 = zext i16 %4 to i32
%6 = ashr i32 %5, 13
%7 = and i32 %6, 7
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %19
12: ; preds = %1
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%14 = load i16, i16* %2
%15 = zext i16 %14 to i32
%16 = ashr i32 %15, 13
%17 = and i32 %16, 7
%18 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %12, %9
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%21 = call i32 @bits(i32 15, i32 13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%23 = load i16, i16* %2
%24 = zext i16 %23 to i32
%25 = ashr i32 %24, 11
%26 = and i32 %25, 3
%27 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%29 = call i32 @bits(i32 12, i32 11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%31 = load i16, i16* %2
%32 = zext i16 %31 to i32
%33 = ashr i32 %32, 7
%34 = and i32 %33, 15
%35 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%37 = call i32 @bits(i32 10, i32 7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%39 = load i16, i16* %2
%40 = zext i16 %39 to i32
%41 = ashr i32 %40, 3
%42 = and i32 %41, 15
%43 = call i32 @sprintf(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%45 = call i32 @bits(i32 6, i32 3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%47 = load i16, i16* %2
%48 = zext i16 %47 to i32
%49 = and i32 %48, 3
%50 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%52 = call i32 @bits(i32 2, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %51)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"Disabled\00"
@.str.1 = [24 x i8] c"%d * 8 MHz clock cycles\00"
@.str.2 = [20 x i8] c"AGC_SETTLE_BLANK_DN\00"
@.str.3 = [3 x i8] c"RW\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [13 x i8] c"AGC_WIN_SIZE\00"
@.str.6 = [16 x i8] c"AGC_SETTLE_PEAK\00"
@.str.7 = [15 x i8] c"AGC_SETTLE_ADC\00"
@.str.8 = [13 x i8] c"AGC_ATTEMPTS\00"
define void @cc2400_agctst0(i16 zeroext %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = zext i16 %0 to i32
%5 = icmp ult i16 %0, 8192
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %11
8: ; preds = %1
%9 = lshr i32 %4, 13
%10 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %8, %6
%12 = call i32 @bits(i32 15, i32 13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%13 = lshr i32 %4, 11
%14 = and i32 %13, 3
%15 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = call i32 @bits(i32 12, i32 11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%17 = lshr i32 %4, 7
%18 = and i32 %17, 15
%19 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = call i32 @bits(i32 10, i32 7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%21 = lshr i32 %4, 3
%22 = and i32 %21, 15
%23 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = call i32 @bits(i32 6, i32 3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%25 = and i32 %4, 3
%26 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = call i32 @bits(i32 2, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
ret void
}