#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_agcctrl(unsigned short v) {
  char description[64];
  sprintf(description, "%d", (v >> 8));
  bits(15, 8, "VGA_GAIN", "RW", description);
  bits(7, 4, "-", "W0", "");
  bits(3, 3, "AGC_LOCKED", "RO", "");
  bits(2, 2, "AGC_LOCK", "RW", "");
  bits(1, 1, "AGC_SYNC_LOCK", "RW", "");
  bits(0, 0, "VGA_GAIN_OE", "RW", "");
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
sar    $0x8,%eax
lea    0xebf(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0xf,%edi
mov    $0x8,%esi
lea    0xea5(%rip),%rdx
lea    0xea7(%rip),%rcx
call   1030 <bits@plt>
mov    $0x7,%edi
mov    $0x4,%esi
lea    0xe94(%rip),%rdx
lea    0xe8f(%rip),%rcx
lea    0xe87(%rip),%r8
call   1030 <bits@plt>
mov    $0x3,%esi
lea    0xe7a(%rip),%rdx
lea    0xe7e(%rip),%rcx
lea    0xe68(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
mov    $0x2,%esi
lea    0xe67(%rip),%rdx
lea    0xe4a(%rip),%rcx
lea    0xe47(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
mov    $0x1,%esi
lea    0xe4f(%rip),%rdx
lea    0xe29(%rip),%rcx
lea    0xe26(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
xor    %esi,%esi
lea    0xe3f(%rip),%rdx
lea    0xe0b(%rip),%rcx
lea    0xe08(%rip),%r8
mov    %esi,%edi
call   1030 <bits@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %edi,%edx
shr    $0x8,%edx
lea    0xecd(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
lea    0xebe(%rip),%rdx
lea    0xec0(%rip),%r14
mov    $0xf,%edi
mov    $0x8,%esi
mov    %r14,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
lea    0xea7(%rip),%rdx
lea    0xea2(%rip),%rcx
lea    0xe9a(%rip),%rbx
mov    $0x7,%edi
mov    $0x4,%esi
mov    %rbx,%r8
call   1030 <bits@plt>
lea    0xe85(%rip),%rdx
lea    0xe89(%rip),%rcx
mov    $0x3,%edi
mov    $0x3,%esi
mov    %rbx,%r8
call   1030 <bits@plt>
lea    0xe73(%rip),%rdx
mov    $0x2,%edi
mov    $0x2,%esi
mov    %r14,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
lea    0xe60(%rip),%rdx
mov    $0x1,%edi
mov    $0x1,%esi
mov    %r14,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
lea    0xe52(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"VGA_GAIN\00"
@.str.2 = [3 x i8] c"RW\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [3 x i8] c"W0\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [11 x i8] c"AGC_LOCKED\00"
@.str.7 = [3 x i8] c"RO\00"
@.str.8 = [9 x i8] c"AGC_LOCK\00"
@.str.9 = [14 x i8] c"AGC_SYNC_LOCK\00"
@.str.10 = [12 x i8] c"VGA_GAIN_OE\00"
define void @cc2400_agcctrl(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca [64 x i8]
store i16 %0, i16* %2
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = load i16, i16* %2
%6 = zext i16 %5 to i32
%7 = ashr i32 %6, 8
%8 = trunc i32 %7 to i16
%9 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i16 zeroext %8)
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = call i32 @bits(i32 15, i32 8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i32 @bits(i32 7, i32 4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, 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.5, i64 0, i64 0))
%13 = call i32 @bits(i32 3, i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @bits(i32 2, i32 2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @bits(i32 1, i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @bits(i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"VGA_GAIN\00"
@.str.2 = [3 x i8] c"RW\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [3 x i8] c"W0\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [11 x i8] c"AGC_LOCKED\00"
@.str.7 = [3 x i8] c"RO\00"
@.str.8 = [9 x i8] c"AGC_LOCK\00"
@.str.9 = [14 x i8] c"AGC_SYNC_LOCK\00"
@.str.10 = [12 x i8] c"VGA_GAIN_OE\00"
define void @cc2400_agcctrl(i16 zeroext %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = lshr i16 %0, 8
%5 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i16 zeroext %4)
%6 = call i32 @bits(i32 15, i32 8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%7 = call i32 @bits(i32 7, i32 4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, 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.5, i64 0, i64 0))
%8 = call i32 @bits(i32 3, i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @bits(i32 2, i32 2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @bits(i32 1, i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @bits(i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
ret void
}