#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 */
scalar_t__ INT_MAX;
scalar_t__ printf(char *);
int sra(int, int);
unsigned int srl(unsigned int, int);
int main(void) {
  unsigned ux = (unsigned)INT_MAX + 1;
  unsigned ux_rsl_3 = srl(ux, 3);
  (ux == ux_rsl_3 * 8) && printf("srl function correct.\n");
  int x = ~0;
  int x_sra_3 = sra(x, 3);
  (x == x_sra_3) && printf("sra function correct.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%rax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
call   1050 <srl@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%edx
shl    $0x3,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x15(%rbp)
jne    118b <main+0x5b>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
movl   $0xffffffff,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x3,%esi
call   1040 <sra@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x16(%rbp)
jne    11cc <main+0x9c>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2eb0(%rip),%rax
mov    (%rax),%ebx
add    $0x1,%ebx
mov    %ebx,%edi
mov    $0x3,%esi
call   1050 <srl@plt>
shl    $0x3,%eax
cmp    %eax,%ebx
jne    115c <main+0x2c>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
mov    $0x3,%esi
call   1040 <sra@plt>
cmp    $0xffffffff,%eax
jne    117c <main+0x4c>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@INT_MAX = global i64 0
@.str = [23 x i8] c"srl function correct.\0A\00"
@.str.1 = [23 x i8] c"sra function correct.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i64, i64* @INT_MAX
%7 = trunc i64 %6 to i32
%8 = add i32 %7, 1
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = call i32 @srl(i32 %9, i32 3)
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = mul i32 %12, 8
%14 = icmp eq i32 %11, %13
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = call i64 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br label %18
18: ; preds = %15, %0
%19 = phi i1 [ false, %0 ], [ %17, %15 ]
%20 = zext i1 %19 to i32
store i32 -1, i32* %4
%21 = load i32, i32* %4
%22 = call i32 @sra(i32 %21, i32 3)
store i32 %22, i32* %5
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %18
%27 = call i64 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br label %29
29: ; preds = %26, %18
%30 = phi i1 [ false, %18 ], [ %28, %26 ]
%31 = zext i1 %30 to i32
ret i32 0
}

LLVM IR (-O2):
@INT_MAX = global i64 0
@str = [22 x i8] c"sra function correct.\00"
@str.2 = [22 x i8] c"srl function correct.\00"
define i32 @main() {
%1 = load i64, i64* @INT_MAX
%2 = trunc i64 %1 to i32
%3 = add i32 %2, 1
%4 = tail call i32 @srl(i32 %3, i32 3)
%5 = shl i32 %4, 3
%6 = icmp eq i32 %3, %5
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = tail call i32 @sra(i32 -1, i32 3)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
ret i32 0
}