#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_res27(unsigned short v) {
  char description[64];
  sprintf(description, "%d", (v >> 8) & 0xFF);
  bits(15, 8, "-", "RO", description);
  sprintf(description, "%d", (v >> 3) & 0xF);
  bits(7, 3, "-", "RW", description);
  sprintf(description, "%d", v & 7);
  bits(2, 0, "-", "RW", 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    $0x8,%eax
and    $0xff,%eax
lea    0xeba(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0xf,%edi
mov    $0x8,%esi
lea    0xea0(%rip),%rdx
lea    0xe9b(%rip),%rcx
call   1030 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
sar    $0x3,%eax
and    $0xf,%eax
lea    0xe7c(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x7,%edi
mov    $0x3,%esi
lea    0xe62(%rip),%rdx
lea    0xe60(%rip),%rcx
call   1030 <bits@plt>
lea    -0x50(%rbp),%rdi
movzwl -0x2(%rbp),%eax
and    $0x7,%eax
lea    0xe41(%rip),%rsi
movzwl %ax,%edx
call   1040 <sprintf@plt>
lea    -0x50(%rbp),%r8
mov    $0x2,%edi
xor    %esi,%esi
lea    0xe2a(%rip),%rdx
lea    0xe28(%rip),%rcx
call   1030 <bits@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebp
mov    %edi,%edx
shr    $0x8,%edx
lea    0xec6(%rip),%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0xeb4(%rip),%r14
lea    0xeaf(%rip),%rcx
mov    $0xf,%edi
mov    $0x8,%esi
mov    %r14,%rdx
mov    %rbx,%r8
call   1030 <bits@plt>
mov    %ebp,%edx
shr    $0x3,%edx
and    $0xf,%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
lea    0xe83(%rip),%r12
mov    $0x7,%edi
mov    $0x3,%esi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
and    $0x7,%ebp
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <sprintf@plt>
mov    $0x2,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %rbx,%r8
call   1030 <bits@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"RO\00"
@.str.3 = [3 x i8] c"RW\00"
define void @cc2400_res27(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 = and i32 %7, 255
%9 = trunc i32 %8 to i16
%10 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 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 8, i8* getelementptr inbounds ([2 x i8], [2 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 = ashr i32 %15, 3
%17 = and i32 %16, 15
%18 = trunc i32 %17 to i16
%19 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i16 zeroext %18)
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%21 = call i32 @bits(i32 7, i32 3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, 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 = and i32 %24, 7
%26 = trunc i32 %25 to i16
%27 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i16 zeroext %26)
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%29 = call i32 @bits(i32 2, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %28)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"RO\00"
@.str.3 = [3 x i8] c"RW\00"
define void @cc2400_res27(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 ([2 x i8], [2 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 = lshr i16 %0, 3
%8 = and i16 %7, 15
%9 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i16 zeroext %8)
%10 = call i32 @bits(i32 7, i32 3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%11 = and i16 %0, 7
%12 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i16 zeroext %11)
%13 = call i32 @bits(i32 2, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
ret void
}