#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 dec_bin(unsigned long);
int /*<<< orphan*/ printf(char *, int, ...);
unsigned short rightrot(unsigned short, unsigned short);
void main() {
  unsigned short int n = 0;
  unsigned short int p = 0;
  unsigned short int setb = 0;
  unsigned short int inv = 0;
  unsigned short int rev = 0;
  unsigned short int x = 0;
  unsigned short int y = 0;
  unsigned long int len = 0;
  n = 2;
  p = 7;
  x = 466;
  y = 0245;
  printf("n = %d;\np = %d;\nx = %d;\ny = %d;\n", n, p, x, y);
  printf("n in binary = %46d;\np in binary = %46d;\nx in binary = %46d;\ny in "
         "binary = %46d;\n\n",
         dec_bin(n), dec_bin(p), dec_bin(x), dec_bin(y));
  rev = rightrot(x, n);
  printf("rezult to right = %lu; and in bin = %22lu;\n\n", rev, dec_bin(rev));
  len = 262143;
  printf("len = %lu; and in bin = %33lu;\n", len, dec_bin(len));
  printf("and size of unsigned long int = %d;\n", sizeof(unsigned long int));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movw   $0x0,-0x2(%rbp)
movw   $0x0,-0x4(%rbp)
movw   $0x0,-0x6(%rbp)
movw   $0x0,-0x8(%rbp)
movw   $0x0,-0xa(%rbp)
movw   $0x0,-0xc(%rbp)
movw   $0x0,-0xe(%rbp)
movq   $0x0,-0x18(%rbp)
movw   $0x2,-0x2(%rbp)
movw   $0x7,-0x4(%rbp)
movw   $0x1d2,-0xc(%rbp)
movw   $0xa5,-0xe(%rbp)
movzwl -0x2(%rbp),%esi
movzwl -0x4(%rbp),%edx
movzwl -0xc(%rbp),%ecx
movzwl -0xe(%rbp),%r8d
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzwl -0x2(%rbp),%eax
mov    %eax,%edi
call   1050 <dec_bin@plt>
mov    %eax,-0x2c(%rbp)
movzwl -0x4(%rbp),%eax
mov    %eax,%edi
call   1050 <dec_bin@plt>
mov    %eax,-0x28(%rbp)
movzwl -0xc(%rbp),%eax
mov    %eax,%edi
call   1050 <dec_bin@plt>
mov    %eax,-0x24(%rbp)
movzwl -0xe(%rbp),%eax
mov    %eax,%edi
call   1050 <dec_bin@plt>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    %eax,%r8d
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ax
movzwl %ax,%edi
movzwl -0x2(%rbp),%esi
call   1040 <rightrot@plt>
mov    %ax,-0xa(%rbp)
movzwl -0xa(%rbp),%eax
mov    %eax,-0x20(%rbp)
movzwl -0xa(%rbp),%eax
mov    %eax,%edi
call   1050 <dec_bin@plt>
mov    -0x20(%rbp),%esi
mov    %eax,%edx
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x3ffff,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <dec_bin@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe65(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
mov    $0x2,%esi
mov    $0x7,%edx
mov    $0x1d2,%ecx
mov    $0xa5,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <dec_bin@plt>
mov    %eax,%r14d
mov    $0x7,%edi
call   1050 <dec_bin@plt>
mov    %eax,%ebp
mov    $0x1d2,%edi
call   1050 <dec_bin@plt>
mov    %eax,%ebx
mov    $0xa5,%edi
call   1050 <dec_bin@plt>
lea    0xe94(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1d2,%edi
mov    $0x2,%esi
call   1040 <rightrot@plt>
movzwl %ax,%ebx
mov    %rbx,%rdi
call   1050 <dec_bin@plt>
lea    0xeb4(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3ffff,%edi
call   1050 <dec_bin@plt>
lea    0xec5(%rip),%rdi
mov    $0x3ffff,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"n = %d;\0Ap = %d;\0Ax = %d;\0Ay = %d;\0A\00"
@.str.1 = [82 x i8] c"n in binary = %46d;\0Ap in binary = %46d;\0Ax in binary = %46d;\0Ay in binary = %46d;\0A\0A\00"
@.str.2 = [45 x i8] c"rezult to right = %lu; and in bin = %22lu;\0A\0A\00"
@.str.3 = [32 x i8] c"len = %lu; and in bin = %33lu;\0A\00"
@.str.4 = [37 x i8] c"and size of unsigned long int = %d;\0A\00"
define void @main() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i64
store i16 0, i16* %1
store i16 0, i16* %2
store i16 0, i16* %3
store i16 0, i16* %4
store i16 0, i16* %5
store i16 0, i16* %6
store i16 0, i16* %7
store i64 0, i64* %8
store i16 2, i16* %1
store i16 7, i16* %2
store i16 466, i16* %6
store i16 165, i16* %7
%9 = load i16, i16* %1
%10 = zext i16 %9 to i32
%11 = load i16, i16* %2
%12 = zext i16 %11 to i32
%13 = load i16, i16* %6
%14 = zext i16 %13 to i32
%15 = load i16, i16* %7
%16 = zext i16 %15 to i32
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12, i32 %14, i32 %16)
%18 = load i16, i16* %1
%19 = zext i16 %18 to i64
%20 = call i32 @dec_bin(i64 %19)
%21 = load i16, i16* %2
%22 = zext i16 %21 to i64
%23 = call i32 @dec_bin(i64 %22)
%24 = load i16, i16* %6
%25 = zext i16 %24 to i64
%26 = call i32 @dec_bin(i64 %25)
%27 = load i16, i16* %7
%28 = zext i16 %27 to i64
%29 = call i32 @dec_bin(i64 %28)
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %23, i32 %26, i32 %29)
%31 = load i16, i16* %6
%32 = load i16, i16* %1
%33 = call zeroext i16 @rightrot(i16 zeroext %31, i16 zeroext %32)
store i16 %33, i16* %5
%34 = load i16, i16* %5
%35 = zext i16 %34 to i32
%36 = load i16, i16* %5
%37 = zext i16 %36 to i64
%38 = call i32 @dec_bin(i64 %37)
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %38)
store i64 262143, i64* %8
%40 = load i64, i64* %8
%41 = trunc i64 %40 to i32
%42 = load i64, i64* %8
%43 = call i32 @dec_bin(i64 %42)
%44 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %43)
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 8)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"n = %d;\0Ap = %d;\0Ax = %d;\0Ay = %d;\0A\00"
@.str.1 = [82 x i8] c"n in binary = %46d;\0Ap in binary = %46d;\0Ax in binary = %46d;\0Ay in binary = %46d;\0A\0A\00"
@.str.2 = [45 x i8] c"rezult to right = %lu; and in bin = %22lu;\0A\0A\00"
@.str.3 = [32 x i8] c"len = %lu; and in bin = %33lu;\0A\00"
@.str.4 = [37 x i8] c"and size of unsigned long int = %d;\0A\00"
define void @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 2, i32 7, i32 466, i32 165)
%2 = tail call i32 @dec_bin(i64 2)
%3 = tail call i32 @dec_bin(i64 7)
%4 = tail call i32 @dec_bin(i64 466)
%5 = tail call i32 @dec_bin(i64 165)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 %4, i32 %5)
%7 = tail call zeroext i16 @rightrot(i16 zeroext 466, i16 zeroext 2)
%8 = zext i16 %7 to i32
%9 = zext i16 %7 to i64
%10 = tail call i32 @dec_bin(i64 %9)
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %10)
%12 = tail call i32 @dec_bin(i64 262143)
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 262143, i32 %12)
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 8)
ret void
}