#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 */
long INT16_MAX;
long INT16_MIN;
long INT8_MAX;
long INT8_MIN;
int bcf_enc_inttype(long x) {
  if (x <= INT8_MAX && x > INT8_MIN)
    return 1;
  if (x <= INT16_MAX && x > INT16_MIN)
    return 2;
  return 3;
}


x86 assembly (clang, -O0):
<bcf_enc_inttype>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2ec5(%rip),%rcx
cmp    (%rcx),%rax
jg     113c <bcf_enc_inttype+0x3c>
mov    -0x10(%rbp),%rax
mov    0x2ec1(%rip),%rcx
cmp    (%rcx),%rax
jle    113c <bcf_enc_inttype+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    1177 <bcf_enc_inttype+0x77>
mov    -0x10(%rbp),%rax
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%rax
jg     1170 <bcf_enc_inttype+0x70>
mov    -0x10(%rbp),%rax
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%rax
jle    1170 <bcf_enc_inttype+0x70>
movl   $0x2,-0x4(%rbp)
jmp    1177 <bcf_enc_inttype+0x77>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bcf_enc_inttype>:
mov    0x2ed1(%rip),%rax
cmp    %rdi,(%rax)
jl     111e <bcf_enc_inttype+0x1e>
mov    0x2ed5(%rip),%rcx
mov    $0x1,%eax
cmp    %rdi,(%rcx)
jge    111e <bcf_enc_inttype+0x1e>
ret
mov    0x2eab(%rip),%rax
cmp    %rdi,(%rax)
setge  %al
mov    0x2e96(%rip),%rcx
cmp    %rdi,(%rcx)
setl   %cl
and    %al,%cl
movzbl %cl,%eax
xor    $0x3,%eax
ret

LLVM IR (-O0):
@INT8_MAX = global i64 0
@INT8_MIN = global i64 0
@INT16_MAX = global i64 0
@INT16_MIN = global i64 0
define i32 @bcf_enc_inttype(i64 %0) {
%2 = alloca i32
%3 = alloca i64
store i64 %0, i64* %3
%4 = load i64, i64* %3
%5 = load i64, i64* @INT8_MAX
%6 = icmp sle i64 %4, %5
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i64, i64* %3
%9 = load i64, i64* @INT8_MIN
%10 = icmp sgt i64 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 1, i32* %2
br label %22
12: ; preds = %7, %1
%13 = load i64, i64* %3
%14 = load i64, i64* @INT16_MAX
%15 = icmp sle i64 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i64, i64* %3
%18 = load i64, i64* @INT16_MIN
%19 = icmp sgt i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 2, i32* %2
br label %22
21: ; preds = %16, %12
store i32 3, i32* %2
br label %22
22: ; preds = %21, %20, %11
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@INT8_MAX = global i64 0
@INT8_MIN = global i64 0
@INT16_MAX = global i64 0
@INT16_MIN = global i64 0
define i32 @bcf_enc_inttype(i64 %0) {
%2 = load i64, i64* @INT8_MAX
%3 = icmp sge i64 %2, %0
%4 = load i64, i64* @INT8_MIN
%5 = icmp slt i64 %4, %0
%6 = select i1 %3, i1 %5, i1 false
br i1 %6, label %14, label %7
7: ; preds = %1
%8 = load i64, i64* @INT16_MAX
%9 = icmp sge i64 %8, %0
%10 = load i64, i64* @INT16_MIN
%11 = icmp slt i64 %10, %0
%12 = select i1 %9, i1 %11, i1 false
%13 = select i1 %12, i32 2, i32 3
br label %14
14: ; preds = %7, %1
%15 = phi i32 [ 1, %1 ], [ %13, %7 ]
ret i32 %15
}