#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*/ external_observer(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
unsigned int random();
int main() {
  int i;
  printf("Random shifts:\n");
  for (i = 0; i != 200; ++i) {
    putchar('.');
    unsigned a = random();
    unsigned b = random();
    external_observer(a << b);
    external_observer(a >> b);
    external_observer((int)a >> b);
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xc8,-0x8(%rbp)
je     11c2 <main+0x82>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1060 <random@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <random@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%ecx
shl    %cl,%edi
call   1050 <external_observer@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%ecx
shr    %cl,%edi
call   1050 <external_observer@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%ecx
sar    %cl,%edi
call   1050 <external_observer@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <main+0x22>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
mov    $0xc8,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    $0x2e,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <random@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <random@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%ecx
shl    %cl,%edi
call   1050 <external_observer@plt>
mov    %ebx,%edi
mov    %ebp,%ecx
shr    %cl,%edi
call   1050 <external_observer@plt>
mov    %ebp,%ecx
sar    %cl,%ebx
mov    %ebx,%edi
call   1050 <external_observer@plt>
add    $0xffffffff,%r14d
jne    1160 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Random shifts:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %6
6: ; preds = %25, %0
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 200
br i1 %8, label %9, label %28
9: ; preds = %6
%10 = call i32 @putchar(i8 signext 46)
%11 = call i32 (...) @random()
store i32 %11, i32* %3
%12 = call i32 (...) @random()
store i32 %12, i32* %4
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = shl i32 %13, %14
%16 = call i32 @external_observer(i32 %15)
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = lshr i32 %17, %18
%20 = call i32 @external_observer(i32 %19)
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = ashr i32 %21, %22
%24 = call i32 @external_observer(i32 %23)
br label %25
25: ; preds = %9
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %6
28: ; preds = %6
%29 = call i32 @putchar(i8 signext 10)
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@str = [15 x i8] c"Random shifts:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %13, %2 ]
%4 = tail call i32 @putchar(i8 signext 46)
%5 = tail call i32 (...) @random()
%6 = tail call i32 (...) @random()
%7 = shl i32 %5, %6
%8 = tail call i32 @external_observer(i32 %7)
%9 = lshr i32 %5, %6
%10 = tail call i32 @external_observer(i32 %9)
%11 = ashr i32 %5, %6
%12 = tail call i32 @external_observer(i32 %11)
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 200
br i1 %14, label %15, label %2
15: ; preds = %2
%16 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}