#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 *, unsigned int, ...);
int main(void) {
  unsigned int w1 = 0177777u, w2 = 0444u;
  unsigned int shift(unsigned int value, int n);
  printf("%o\t%o\t\n", shift(w1, 5), w1 << 5);
  printf("%o\t%o\t\n", shift(w1, -6), w1 >> 6);
  printf("%o\t%o\t\n", shift(w2, 0), w2 >> 0);
  printf("%o\n", shift(shift(w1, -3), 3));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffff,-0x8(%rbp)
movl   $0x124,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x5,%esi
call   1040 <shift@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%edx
shl    $0x5,%edx
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0xfffffffa,%esi
call   1040 <shift@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%edx
shr    $0x6,%edx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1040 <shift@plt>
mov    %eax,%esi
mov    -0xc(%rbp),%edx
shr    $0x0,%edx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0xfffffffd,%esi
call   1040 <shift@plt>
mov    %eax,%edi
mov    $0x3,%esi
call   1040 <shift@plt>
mov    %eax,%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xffff,%edi
mov    $0x5,%esi
call   1040 <shift@plt>
lea    0xec9(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1fffe0,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffff,%edi
mov    $0xfffffffa,%esi
call   1040 <shift@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x3ff,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x124,%edi
xor    %esi,%esi
call   1040 <shift@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x124,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffff,%edi
mov    $0xfffffffd,%esi
call   1040 <shift@plt>
mov    %eax,%edi
mov    $0x3,%esi
call   1040 <shift@plt>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%o\09%o\09\0A\00"
@.str.1 = [4 x i8] c"%o\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 65535, i32* %2
store i32 292, i32* %3
%4 = load i32, i32* %2
%5 = call i32 @shift(i32 %4, i32 5)
%6 = load i32, i32* %2
%7 = shl i32 %6, 5
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7)
%9 = load i32, i32* %2
%10 = call i32 @shift(i32 %9, i32 -6)
%11 = load i32, i32* %2
%12 = lshr i32 %11, 6
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12)
%14 = load i32, i32* %3
%15 = call i32 @shift(i32 %14, i32 0)
%16 = load i32, i32* %3
%17 = lshr i32 %16, 0
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %17)
%19 = load i32, i32* %2
%20 = call i32 @shift(i32 %19, i32 -3)
%21 = call i32 @shift(i32 %20, i32 3)
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%o\09%o\09\0A\00"
@.str.1 = [4 x i8] c"%o\0A\00"
define i32 @main() {
%1 = tail call i32 @shift(i32 65535, i32 5)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %1, i32 2097120)
%3 = tail call i32 @shift(i32 65535, i32 -6)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 1023)
%5 = tail call i32 @shift(i32 292, i32 0)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5, i32 292)
%7 = tail call i32 @shift(i32 65535, i32 -3)
%8 = tail call i32 @shift(i32 %7, i32 3)
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
ret i32 0
}