#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*/ getchar();
scalar_t__ printf(char *);
int sra(int, int);
int srl(int, int);
int main(void) {
  int shift_bits = 3;
  int test_hex_0 = 0x80000000;
  int logical_shift = (unsigned)test_hex_0 >> shift_bits;
  !(logical_shift ^ srl(test_hex_0, shift_bits)) &&
      (printf("Logical shifts simulate successful\n"));
  shift_bits = 7;
  int test_hex_1 = 0xFFFFFFF;
  int arithmetic_shift = (int)test_hex_1 >> shift_bits;
  !(arithmetic_shift ^ sra(test_hex_1, shift_bits)) &&
      (printf("Arithmetic shifts simulate successful\n"));
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x80000000,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <srl@plt>
mov    -0x20(%rbp),%ecx
xor    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    11a2 <main+0x62>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
movl   $0x7,-0x8(%rbp)
movl   $0xfffffff,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sar    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <sra@plt>
mov    -0x28(%rbp),%ecx
xor    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
jne    11f8 <main+0xb8>
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x80000000,%edi
mov    $0x3,%esi
call   1060 <srl@plt>
cmp    $0x10000000,%eax
jne    1163 <main+0x23>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffff,%edi
mov    $0x7,%esi
call   1040 <sra@plt>
cmp    $0x1fffff,%eax
jne    1185 <main+0x45>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Logical shifts simulate successful\0A\00"
@.str.1 = [39 x i8] c"Arithmetic shifts simulate successful\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 3, i32* %2
store i32 -2147483648, i32* %3
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = lshr i32 %7, %8
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = call i32 @srl(i32 %11, i32 %12)
%14 = xor i32 %10, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %0
%17 = call i64 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br label %19
19: ; preds = %16, %0
%20 = phi i1 [ false, %0 ], [ %18, %16 ]
%21 = zext i1 %20 to i32
store i32 7, i32* %2
store i32 268435455, i32* %5
%22 = load i32, i32* %5
%23 = load i32, i32* %2
%24 = ashr i32 %22, %23
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = load i32, i32* %5
%27 = load i32, i32* %2
%28 = call i32 @sra(i32 %26, i32 %27)
%29 = xor i32 %25, %28
%30 = icmp ne i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %19
%32 = call i64 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br label %34
34: ; preds = %31, %19
%35 = phi i1 [ false, %19 ], [ %33, %31 ]
%36 = zext i1 %35 to i32
%37 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@str = [35 x i8] c"Logical shifts simulate successful\00"
@str.2 = [38 x i8] c"Arithmetic shifts simulate successful\00"
define i32 @main() {
%1 = tail call i32 @srl(i32 -2147483648, i32 3)
%2 = icmp eq i32 %1, 268435456
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @sra(i32 268435455, i32 7)
%7 = icmp eq i32 %6, 2097151
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = tail call i32 (...) @getchar()
ret i32 0
}