#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_manfidh(unsigned short v) {
  char description[64];
  sprintf(description, "0x%X", (v >> 12) & 0xF);
  bits(15, 12, "VERSION", "RO", description);
  sprintf(description, "0x%X", v & 0xFFF);
  bits(11, 0, "PARTNUM", "RO", description);
}


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    $0xc,%eax
and    $0xf,%eax
lea    0xebc(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0xf,%edi
mov    $0xc,%esi
lea    0xea4(%rip),%rdx
lea    0xea5(%rip),%rcx
call   1030 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
and    $0xfff,%eax
lea    0xe7f(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0xb,%edi
xor    %esi,%esi
lea    0xe75(%rip),%rdx
lea    0xe6b(%rip),%rcx
call   1030 <bits@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebp
mov    %edi,%edx
shr    $0xc,%edx
lea    0xec8(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <sprintf@plt>
lea    0xeb8(%rip),%rdx
lea    0xeb9(%rip),%r15
mov    $0xf,%edi
mov    $0xc,%esi
mov    %r15,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
and    $0xfff,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <sprintf@plt>
lea    0xe8d(%rip),%rdx
mov    $0xb,%edi
xor    %esi,%esi
mov    %r15,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0x%X\00"
@.str.1 = [8 x i8] c"VERSION\00"
@.str.2 = [3 x i8] c"RO\00"
@.str.3 = [8 x i8] c"PARTNUM\00"
define void @cc2400_manfidh(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, 12
%8 = and i32 %7, 15
%9 = trunc i32 %8 to i16
%10 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 zeroext %9)
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%12 = call i32 @bits(i32 15, i32 12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%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 = and i32 %15, 4095
%17 = trunc i32 %16 to i16
%18 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 zeroext %17)
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%20 = call i32 @bits(i32 11, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %19)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"0x%X\00"
@.str.1 = [8 x i8] c"VERSION\00"
@.str.2 = [3 x i8] c"RO\00"
@.str.3 = [8 x i8] c"PARTNUM\00"
define void @cc2400_manfidh(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, 12
%5 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 zeroext %4)
%6 = call i32 @bits(i32 15, i32 12, i8* getelementptr inbounds ([8 x i8], [8 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 = and i16 %0, 4095
%8 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i16 zeroext %7)
%9 = call i32 @bits(i32 11, i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret void
}