#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 */
unsigned int fnRightRot(unsigned int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  unsigned int iVal, iNewVal;
  int iNum, iChoice;
  printf("\n*********************************************************");
  printf("\n*\tPROGRAM TO IMPLEMENT CIRCULAR RIGHT SHIFT\t*\n");
  printf("*********************************************************");
  do {
    printf("\nEnter the value to be rotated\n");
    scanf("%u", &iVal);
    printf("\nEnter the number of positions by which the value has to be "
           "rotated\n");
    scanf("%d", &iNum);
    iNewVal = fnRightRot(iVal, iNum);
    printf("\nThe value %u after right rotation by %d bits = %u\n", iVal, iNum,
           iNewVal);
    printf("\nPress 1 to continue or any other key to exit....\n");
    scanf("%d", &iChoice);
  } while (1 == iChoice);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0d(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf35(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <fnRightRot@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xf0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    $0x1,%eax
cmp    -0x14(%rbp),%eax
je     1169 <main+0x39>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf12(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf46(%rip),%r13
lea    0xeba(%rip),%rbx
lea    0xc(%rsp),%rbp
lea    0xeb1(%rip),%r14
lea    0xf70(%rip),%r15
lea    0x14(%rsp),%r12
nopl   0x0(%rax)
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
lea    0xe88(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
call   1050 <fnRightRot@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x1,0x14(%rsp)
je     11a0 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [59 x i8] c"\0A*********************************************************\00"
@.str.1 = [48 x i8] c"\0A*\09PROGRAM TO IMPLEMENT CIRCULAR RIGHT SHIFT\09*\0A\00"
@.str.2 = [58 x i8] c"*********************************************************\00"
@.str.3 = [32 x i8] c"\0AEnter the value to be rotated\0A\00"
@.str.4 = [3 x i8] c"%u\00"
@.str.5 = [69 x i8] c"\0AEnter the number of positions by which the value has to be rotated\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [52 x i8] c"\0AThe value %u after right rotation by %d bits = %u\0A\00"
@.str.8 = [51 x i8] c"\0APress 1 to continue or any other key to exit....\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %23, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %2
%15 = load i32, i32* %4
%16 = call i32 @fnRightRot(i32 %14, i32 %15)
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.8, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
br label %23
23: ; preds = %9
%24 = load i32, i32* %5
%25 = icmp eq i32 1, %24
br i1 %25, label %9, label %26
26: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str = [59 x i8] c"\0A*********************************************************\00"
@.str.2 = [58 x i8] c"*********************************************************\00"
@.str.4 = [3 x i8] c"%u\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [52 x i8] c"\0AThe value %u after right rotation by %d bits = %u\0A\00"
@str = [47 x i8] c"\0A*\09PROGRAM TO IMPLEMENT CIRCULAR RIGHT SHIFT\09*\00"
@str.9 = [31 x i8] c"\0AEnter the value to be rotated\00"
@str.10 = [68 x i8] c"\0AEnter the number of positions by which the value has to be rotated\00"
@str.11 = [50 x i8] c"\0APress 1 to continue or any other key to exit....\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %10, %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str.10, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = call i32 @fnRightRot(i32 %15, i32 %16)
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %18, i32 %19, i32 %17)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.11, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 1
br i1 %24, label %10, label %25
25: ; preds = %10
ret i32 0
}