#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 invert(unsigned int, int, int);
int /*<<< orphan*/ printf(char *, int);
int rightrot(unsigned int, int);
int setbits(unsigned int, int, int, unsigned int);
int main(void) {
  printf("setbits(x=73, p = 10, n = 3, y = 30)\nGot:\t%u\tExpected:\t841\n\n",
         setbits(73u, 10, 3, 30u));
  printf("invert(x=170, p=4, n=3)\nGot:\t%u\tExpected:\t164\n\n",
         invert(170u, 4, 3));
  printf("rightrot(x=15, n=2)\nGot:\t%u\tExpected:\t3221225475\n\n",
         rightrot(15u, 2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x49,%edi
mov    $0xa,%esi
mov    $0x3,%edx
mov    $0x1e,%ecx
call   1060 <setbits@plt>
mov    %eax,%esi
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
mov    $0xaa,%edi
mov    $0x4,%esi
mov    $0x3,%edx
call   1030 <invert@plt>
mov    %eax,%esi
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
mov    $0xf,%edi
mov    $0x2,%esi
call   1050 <rightrot@plt>
mov    %eax,%esi
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x49,%edi
mov    $0xa,%esi
mov    $0x3,%edx
mov    $0x1e,%ecx
call   1060 <setbits@plt>
lea    0xe9f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xaa,%edi
mov    $0x4,%esi
mov    $0x3,%edx
call   1030 <invert@plt>
lea    0xeba(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0xf,%edi
mov    $0x2,%esi
call   1050 <rightrot@plt>
lea    0xecd(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [61 x i8] c"setbits(x=73, p = 10, n = 3, y = 30)\0AGot:\09%u\09Expected:\09841\0A\0A\00"
@.str.1 = [48 x i8] c"invert(x=170, p=4, n=3)\0AGot:\09%u\09Expected:\09164\0A\0A\00"
@.str.2 = [51 x i8] c"rightrot(x=15, n=2)\0AGot:\09%u\09Expected:\093221225475\0A\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @setbits(i32 73, i32 10, i32 3, i32 30)
%3 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = call i32 @invert(i32 170, i32 4, i32 3)
%5 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = call i32 @rightrot(i32 15, i32 2)
%7 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %6)
ret i32 0
}

LLVM IR (-O2):
@.str = [61 x i8] c"setbits(x=73, p = 10, n = 3, y = 30)\0AGot:\09%u\09Expected:\09841\0A\0A\00"
@.str.1 = [48 x i8] c"invert(x=170, p=4, n=3)\0AGot:\09%u\09Expected:\09164\0A\0A\00"
@.str.2 = [51 x i8] c"rightrot(x=15, n=2)\0AGot:\09%u\09Expected:\093221225475\0A\0A\00"
define i32 @main() {
%1 = tail call i32 @setbits(i32 73, i32 10, i32 3, i32 30)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @invert(i32 170, i32 4, i32 3)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @rightrot(i32 15, i32 2)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %5)
ret i32 0
}