#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*/ printf(char *, int, int);
int rotate_right(unsigned int, int);
int main() {
  unsigned x = 0x12345678;
  int s4 = 4;
  int s20 = 20;
  int s0 = 0;
  int s24 = 24;
  printf("N = %d and result is: %x\n", s4, rotate_right(x, s4));
  printf("N = %d and result is: %x\n", s20, rotate_right(x, s20));
  printf("N = %d and result is: %x\n", s0, rotate_right(x, s0));
  printf("N = %d and result is: %x\n", s24, rotate_right(x, s24));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x12345678,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
movl   $0x14,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x18,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <rotate_right@plt>
mov    -0x28(%rbp),%esi
mov    %eax,%edx
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <rotate_right@plt>
mov    -0x24(%rbp),%esi
mov    %eax,%edx
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <rotate_right@plt>
mov    -0x20(%rbp),%esi
mov    %eax,%edx
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <rotate_right@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x12345678,%edi
mov    $0x4,%esi
call   1040 <rotate_right@plt>
lea    0xec9(%rip),%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x12345678,%edi
mov    $0x14,%esi
call   1040 <rotate_right@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x12345678,%edi
xor    %esi,%esi
call   1040 <rotate_right@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x12345678,%edi
mov    $0x18,%esi
call   1040 <rotate_right@plt>
mov    %rbx,%rdi
mov    $0x18,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"N = %d and result is: %x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 305419896, i32* %2
store i32 4, i32* %3
store i32 20, i32* %4
store i32 0, i32* %5
store i32 24, i32* %6
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call i32 @rotate_right(i32 %8, i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10)
%12 = load i32, i32* %4
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = call i32 @rotate_right(i32 %13, i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %15)
%17 = load i32, i32* %5
%18 = load i32, i32* %2
%19 = load i32, i32* %5
%20 = call i32 @rotate_right(i32 %18, i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %20)
%22 = load i32, i32* %6
%23 = load i32, i32* %2
%24 = load i32, i32* %6
%25 = call i32 @rotate_right(i32 %23, i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"N = %d and result is: %x\0A\00"
define i32 @main() {
%1 = tail call i32 @rotate_right(i32 305419896, i32 4)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 4, i32 %1)
%3 = tail call i32 @rotate_right(i32 305419896, i32 20)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 20, i32 %3)
%5 = tail call i32 @rotate_right(i32 305419896, i32 0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 0, i32 %5)
%7 = tail call i32 @rotate_right(i32 305419896, i32 24)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 24, i32 %7)
ret i32 0
}