#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 */
typedef int uint32_t;

/* Variables and functions */
int checkint(uint32_t iy) {
  int e = iy >> 23 & 0xff;
  if (e < 0x7f)
    return 0;
  if (e > 0x7f + 23)
    return 2;
  if (iy & ((1 << (0x7f + 23 - e)) - 1))
    return 0;
  if (iy & (1 << (0x7f + 23 - e)))
    return 1;
  return 2;
}


x86 assembly (clang, -O0):
<checkint>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x17,%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x7f,-0xc(%rbp)
jge    112b <checkint+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <checkint+0xa4>
cmpl   $0x96,-0xc(%rbp)
jle    1144 <checkint+0x44>
movl   $0x2,-0x4(%rbp)
jmp    11a4 <checkint+0xa4>
mov    -0x8(%rbp),%eax
mov    $0x96,%ecx
sub    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
sub    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1172 <checkint+0x72>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <checkint+0xa4>
mov    -0x8(%rbp),%eax
mov    $0x96,%ecx
sub    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     119d <checkint+0x9d>
movl   $0x1,-0x4(%rbp)
jmp    11a4 <checkint+0xa4>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkint>:
mov    %edi,%edx
shr    $0x17,%edx
movzbl %dl,%ecx
xor    %eax,%eax
cmp    $0x7f,%ecx
jb     1138 <checkint+0x38>
mov    $0x2,%eax
cmp    $0x96,%ecx
ja     1138 <checkint+0x38>
mov    $0x96,%cl
sub    %dl,%cl
mov    $0x1,%edx
shl    %cl,%edx
mov    $0x1,%ecx
lea    -0x1(%rdx),%esi
mov    $0x0,%eax
test   %edi,%esi
je     1139 <checkint+0x39>
ret
and    %edi,%edx
cmp    $0x1,%edx
adc    $0x0,%ecx
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @checkint(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = ashr i32 %5, 23
%7 = and i32 %6, 255
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 127
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %33
11: ; preds = %1
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 150
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 2, i32* %2
br label %33
15: ; preds = %11
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = sub nsw i32 150, %17
%19 = shl i32 1, %18
%20 = sub nsw i32 %19, 1
%21 = and i32 %16, %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %15
store i32 0, i32* %2
br label %33
24: ; preds = %15
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = sub nsw i32 150, %26
%28 = shl i32 1, %27
%29 = and i32 %25, %28
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %24
store i32 1, i32* %2
br label %33
32: ; preds = %24
store i32 2, i32* %2
br label %33
33: ; preds = %32, %31, %23, %14, %10
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @checkint(i32 %0) {
%2 = lshr i32 %0, 23
%3 = and i32 %2, 255
%4 = icmp ult i32 %3, 127
br i1 %4, label %17, label %5
5: ; preds = %1
%6 = icmp ugt i32 %3, 150
br i1 %6, label %17, label %7
7: ; preds = %5
%8 = sub nuw nsw i32 150, %3
%9 = shl nuw nsw i32 1, %8
%10 = add nsw i32 %9, -1
%11 = and i32 %10, %0
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = and i32 %9, %0
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 2, i32 1
br label %17
17: ; preds = %13, %7, %5, %1
%18 = phi i32 [ 0, %1 ], [ 2, %5 ], [ 0, %7 ], [ %16, %13 ]
ret i32 %18
}