#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;
typedef int /*<<< orphan*/ int8_t;
typedef int int64_t;
typedef int /*<<< orphan*/ int32_t;
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
int INT16_MIN;
int INT32_MIN;
int INT8_MAX;
int INT8_MIN;
int UINT16_MAX;
int UINT32_MAX;
int /*<<< orphan*/ assert(int);
uint32_t mp_sizeof_int(int64_t num) {
  assert(num < 0);
  if (num >= -0x20) {
    return 1;
  } else if (num >= INT8_MIN && num <= INT8_MAX) {
    return 1 + sizeof(int8_t);
  } else if (num >= INT16_MIN && num <= UINT16_MAX) {
    return 1 + sizeof(int16_t);
  } else if (num >= INT32_MIN && num <= UINT32_MAX) {
    return 1 + sizeof(int32_t);
  } else {
    return 1 + sizeof(int64_t);
  }
}


x86 assembly (clang, -O0):
<mp_sizeof_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xffffffe0,-0x8(%rbp)
jl     1142 <mp_sizeof_int+0x32>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <mp_sizeof_int+0xc9>
mov    -0x8(%rbp),%eax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%eax
jl     1172 <mp_sizeof_int+0x62>
mov    -0x8(%rbp),%eax
mov    0x2e72(%rip),%rcx
cmp    (%rcx),%eax
jg     1172 <mp_sizeof_int+0x62>
movl   $0x5,-0x4(%rbp)
jmp    11d9 <mp_sizeof_int+0xc9>
mov    -0x8(%rbp),%eax
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%eax
jl     11a2 <mp_sizeof_int+0x92>
mov    -0x8(%rbp),%eax
mov    0x2e2a(%rip),%rcx
cmp    (%rcx),%eax
jg     11a2 <mp_sizeof_int+0x92>
movl   $0x5,-0x4(%rbp)
jmp    11d9 <mp_sizeof_int+0xc9>
mov    -0x8(%rbp),%eax
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%eax
jl     11d2 <mp_sizeof_int+0xc2>
mov    -0x8(%rbp),%eax
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%eax
jg     11d2 <mp_sizeof_int+0xc2>
movl   $0x5,-0x4(%rbp)
jmp    11d9 <mp_sizeof_int+0xc9>
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_sizeof_int>:
push   %rbx
mov    %edi,%ebx
shr    $0x1f,%edi
call   1030 <assert@plt>
xor    %eax,%eax
cmp    $0xffffffe0,%ebx
setl   %al
lea    0x1(,%rax,4),%eax
pop    %rbx
ret

LLVM IR (-O0):
@INT8_MIN = global i32 0
@INT8_MAX = global i32 0
@INT16_MIN = global i32 0
@UINT16_MAX = global i32 0
@INT32_MIN = global i32 0
@UINT32_MAX = global i32 0
define i32 @mp_sizeof_int(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i32, i32* %3
%9 = icmp sge i32 %8, -32
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %39
11: ; preds = %1
%12 = load i32, i32* %3
%13 = load i32, i32* @INT8_MIN
%14 = icmp sge i32 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* %3
%17 = load i32, i32* @INT8_MAX
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 5, i32* %2
br label %39
20: ; preds = %15, %11
%21 = load i32, i32* %3
%22 = load i32, i32* @INT16_MIN
%23 = icmp sge i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i32, i32* %3
%26 = load i32, i32* @UINT16_MAX
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 5, i32* %2
br label %39
29: ; preds = %24, %20
%30 = load i32, i32* %3
%31 = load i32, i32* @INT32_MIN
%32 = icmp sge i32 %30, %31
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i32, i32* %3
%35 = load i32, i32* @UINT32_MAX
%36 = icmp sle i32 %34, %35
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 5, i32* %2
br label %39
38: ; preds = %33, %29
store i32 5, i32* %2
br label %39
39: ; preds = %38, %37, %28, %19, %10
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@INT8_MIN = global i32 0
@INT8_MAX = global i32 0
@INT16_MIN = global i32 0
@UINT16_MAX = global i32 0
@INT32_MIN = global i32 0
@UINT32_MAX = global i32 0
define i32 @mp_sizeof_int(i32 %0) {
%2 = lshr i32 %0, 31
%3 = tail call i32 @assert(i32 %2)
%4 = icmp sgt i32 %0, -33
%5 = select i1 %4, i32 1, i32 5
ret i32 %5
}