#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*/ put_unsigned(int);
int /*<<< orphan*/ putchar(char);
foo(unsigned n) {
  int i = n;
  put_unsigned(n >> 5);
  putchar('\n');
  put_unsigned(i >> 5);
  putchar('\n');
  put_unsigned(i << 5);
  putchar('\n');
  put_unsigned(n >> 31);
  putchar('\n');
  put_unsigned(i >> 31);
  putchar('\n');
  put_unsigned(i << 31);
  putchar('\n');
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
shr    $0x5,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%edi
sar    $0x5,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%edi
shl    $0x5,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%edi
shr    $0x1f,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%edi
sar    $0x1f,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%edi
shl    $0x1f,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
mov    %edi,%ebx
shr    $0x5,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
sar    $0x5,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shl    $0x5,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shr    $0x1f,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
sar    $0x1f,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
shl    $0x1f,%ebx
mov    %ebx,%edi
call   1040 <put_unsigned@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define i32 @foo(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
store i32 %5, i32* %4
%6 = load i32, i32* %3
%7 = lshr i32 %6, 5
%8 = call i32 @put_unsigned(i32 %7)
%9 = call i32 @putchar(i8 signext 10)
%10 = load i32, i32* %4
%11 = ashr i32 %10, 5
%12 = call i32 @put_unsigned(i32 %11)
%13 = call i32 @putchar(i8 signext 10)
%14 = load i32, i32* %4
%15 = shl i32 %14, 5
%16 = call i32 @put_unsigned(i32 %15)
%17 = call i32 @putchar(i8 signext 10)
%18 = load i32, i32* %3
%19 = lshr i32 %18, 31
%20 = call i32 @put_unsigned(i32 %19)
%21 = call i32 @putchar(i8 signext 10)
%22 = load i32, i32* %4
%23 = ashr i32 %22, 31
%24 = call i32 @put_unsigned(i32 %23)
%25 = call i32 @putchar(i8 signext 10)
%26 = load i32, i32* %4
%27 = shl i32 %26, 31
%28 = call i32 @put_unsigned(i32 %27)
%29 = call i32 @putchar(i8 signext 10)
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @foo(i32 %0) {
%2 = lshr i32 %0, 5
%3 = tail call i32 @put_unsigned(i32 %2)
%4 = tail call i32 @putchar(i8 signext 10)
%5 = ashr i32 %0, 5
%6 = tail call i32 @put_unsigned(i32 %5)
%7 = tail call i32 @putchar(i8 signext 10)
%8 = shl i32 %0, 5
%9 = tail call i32 @put_unsigned(i32 %8)
%10 = tail call i32 @putchar(i8 signext 10)
%11 = lshr i32 %0, 31
%12 = tail call i32 @put_unsigned(i32 %11)
%13 = tail call i32 @putchar(i8 signext 10)
%14 = ashr i32 %0, 31
%15 = tail call i32 @put_unsigned(i32 %14)
%16 = tail call i32 @putchar(i8 signext 10)
%17 = shl i32 %0, 31
%18 = tail call i32 @put_unsigned(i32 %17)
%19 = tail call i32 @putchar(i8 signext 10)
ret i32 undef
}