#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*/ printbits(unsigned int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ putchar(char);
int rightrot(int, int);
int main(void) {
  int x;
  unsigned r;
  int xrot;
  x = 1212;
  r = 1;
  xrot = rightrot(x, r);
  printbits((unsigned)x);
  printf(" (%d) rotated %u to the right becomes\n", x, r);
  printbits((unsigned)xrot);
  printf(" (%d)\n\n", xrot);
  x = 3425;
  r = 5;
  xrot = rightrot(x, r);
  printbits((unsigned)x);
  printf(" (%d) rotated %u to the right becomes\n", x, r);
  printbits((unsigned)xrot);
  printf(" (%d)\n\n", xrot);
  x = -128;
  r = 2;
  xrot = rightrot(x, r);
  printbits((unsigned)x);
  printf(" (%d) rotated %u to the right becomes\n", x, r);
  printbits((unsigned)xrot);
  printf(" (%d)\n\n", xrot);
  x = 0xFA0A0A0A;
  r = 32;
  printbits((unsigned)x);
  printf(" (%d) rotated one time continuously for %u times to the right "
         "becomes:\n",
         x, r);
  while (r-- > 0) {
    xrot = rightrot(x, 1);
    printbits((unsigned)xrot);
    printf(" (%d)\n", xrot);
    x = xrot;
  }
  (void)putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4bc,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <rightrot@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <printbits@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%edi
call   1060 <printbits@plt>
mov    -0x10(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xd61,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <rightrot@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <printbits@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%edi
call   1060 <printbits@plt>
mov    -0x10(%rbp),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffff80,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <rightrot@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <printbits@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%edi
call   1060 <printbits@plt>
mov    -0x10(%rbp),%esi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xfa0a0a0a,-0x8(%rbp)
movl   $0x20,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <printbits@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jbe    12b4 <main+0x174>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1050 <rightrot@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1060 <printbits@plt>
mov    -0x10(%rbp),%esi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    126c <main+0x12c>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x4bc,%edi
mov    $0x1,%esi
call   1050 <rightrot@plt>
mov    %eax,%ebp
mov    $0x4bc,%edi
call   1060 <printbits@plt>
lea    0xe9a(%rip),%r14
mov    %r14,%rdi
mov    $0x4bc,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
call   1060 <printbits@plt>
lea    0xe9f(%rip),%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xd61,%edi
mov    $0x5,%esi
call   1050 <rightrot@plt>
mov    %eax,%ebp
mov    $0xd61,%edi
call   1060 <printbits@plt>
mov    %r14,%rdi
mov    $0xd61,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
call   1060 <printbits@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffff80,%edi
mov    $0x2,%esi
call   1050 <rightrot@plt>
mov    %eax,%ebp
mov    $0xffffff80,%edi
call   1060 <printbits@plt>
mov    %r14,%rdi
mov    $0xffffff80,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
call   1060 <printbits@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xfa0a0a0a,%ebx
mov    $0xfa0a0a0a,%edi
call   1060 <printbits@plt>
lea    0xe01(%rip),%rdi
mov    $0xfa0a0a0a,%esi
mov    $0x20,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffe0,%ebp
lea    0xe2c(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    $0x1,%esi
call   1050 <rightrot@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <printbits@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
inc    %ebp
jne    1250 <main+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c" (%d) rotated %u to the right becomes\0A\00"
@.str.1 = [8 x i8] c" (%d)\0A\0A\00"
@.str.2 = [72 x i8] c" (%d) rotated one time continuously for %u times to the right becomes:\0A\00"
@.str.3 = [7 x i8] c" (%d)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1212, i32* %2
store i32 1, i32* %3
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = call i32 @rightrot(i32 %5, i32 %6)
store i32 %7, i32* %4
%8 = load i32, i32* %2
%9 = call i32 @printbits(i32 %8)
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32, i32* %4
%14 = call i32 @printbits(i32 %13)
%15 = load i32, i32* %4
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 3425, i32* %2
store i32 5, i32* %3
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = call i32 @rightrot(i32 %17, i32 %18)
store i32 %19, i32* %4
%20 = load i32, i32* %2
%21 = call i32 @printbits(i32 %20)
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32, i32* %4
%26 = call i32 @printbits(i32 %25)
%27 = load i32, i32* %4
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %27)
store i32 -128, i32* %2
store i32 2, i32* %3
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = call i32 @rightrot(i32 %29, i32 %30)
store i32 %31, i32* %4
%32 = load i32, i32* %2
%33 = call i32 @printbits(i32 %32)
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %34, i32 %35)
%37 = load i32, i32* %4
%38 = call i32 @printbits(i32 %37)
%39 = load i32, i32* %4
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %39)
store i32 -100005366, i32* %2
store i32 32, i32* %3
%41 = load i32, i32* %2
%42 = call i32 @printbits(i32 %41)
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %44)
br label %46
46: ; preds = %50, %0
%47 = load i32, i32* %3
%48 = add i32 %47, -1
store i32 %48, i32* %3
%49 = icmp ugt i32 %47, 0
br i1 %49, label %50, label %58
50: ; preds = %46
%51 = load i32, i32* %2
%52 = call i32 @rightrot(i32 %51, i32 1)
store i32 %52, i32* %4
%53 = load i32, i32* %4
%54 = call i32 @printbits(i32 %53)
%55 = load i32, i32* %4
%56 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %4
store i32 %57, i32* %2
br label %46
58: ; preds = %46
%59 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c" (%d) rotated %u to the right becomes\0A\00"
@.str.1 = [8 x i8] c" (%d)\0A\0A\00"
@.str.2 = [72 x i8] c" (%d) rotated one time continuously for %u times to the right becomes:\0A\00"
@.str.3 = [7 x i8] c" (%d)\0A\00"
define i32 @main() {
%1 = tail call i32 @rightrot(i32 1212, i32 1)
%2 = tail call i32 @printbits(i32 1212)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 1212, i32 1)
%4 = tail call i32 @printbits(i32 %1)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%6 = tail call i32 @rightrot(i32 3425, i32 5)
%7 = tail call i32 @printbits(i32 3425)
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 3425, i32 5)
%9 = tail call i32 @printbits(i32 %6)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%11 = tail call i32 @rightrot(i32 -128, i32 2)
%12 = tail call i32 @printbits(i32 -128)
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 -128, i32 2)
%14 = tail call i32 @printbits(i32 %11)
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%16 = tail call i32 @printbits(i32 -100005366)
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0), i32 -100005366, i32 32)
br label %18
18: ; preds = %0, %18
%19 = phi i32 [ 32, %0 ], [ %21, %18 ]
%20 = phi i32 [ -100005366, %0 ], [ %22, %18 ]
%21 = add nsw i32 %19, -1
%22 = tail call i32 @rightrot(i32 %20, i32 1)
%23 = tail call i32 @printbits(i32 %22)
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%25 = icmp eq i32 %21, 0
br i1 %25, label %26, label %18
26: ; preds = %18
%27 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}