#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*/ assert(int /*<<< orphan*/);
int parsing_ulong_out_of_range(unsigned long, size_t);
bool parsing_long_out_of_range(long value, size_t size, bool is_signed) {
  if (!is_signed)
    return parsing_ulong_out_of_range((unsigned long)value, size);
  switch (size) {
  case 1:
    return value > 0x7Fll || value < -1 * 0x80ll;
  case 2:
    return value > 0x7FFFll || value < -1 * 0x8000ll;
  case 4:
    return value > 0x7FFFFFFFll || value < -1 * 0x80000000ll;
  case 8:
    return false;
  default:
    assert(0);
  }
}


x86 assembly (clang, -O0):
<parsing_long_out_of_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1152 <parsing_long_out_of_range+0x32>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <parsing_ulong_out_of_range@plt>
mov    %eax,-0x4(%rbp)
jmp    121c <parsing_long_out_of_range+0xfc>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
sub    $0x7,%rax
ja     1215 <parsing_long_out_of_range+0xf5>
mov    -0x28(%rbp),%rax
lea    0xe8d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%al
cmpq   $0x7f,-0x10(%rbp)
mov    %al,-0x29(%rbp)
jg     1197 <parsing_long_out_of_range+0x77>
cmpq   $0xffffffffffffff80,-0x10(%rbp)
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121c <parsing_long_out_of_range+0xfc>
mov    $0x1,%al
cmpq   $0x7fff,-0x10(%rbp)
mov    %al,-0x2a(%rbp)
jg     11c8 <parsing_long_out_of_range+0xa8>
cmpq   $0xffffffffffff8000,-0x10(%rbp)
ff
setl   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121c <parsing_long_out_of_range+0xfc>
mov    $0x1,%al
cmpq   $0x7fffffff,-0x10(%rbp)
7f
mov    %al,-0x2b(%rbp)
jg     11f9 <parsing_long_out_of_range+0xd9>
cmpq   $0xffffffff80000000,-0x10(%rbp)
80
setl   %al
mov    %al,-0x2b(%rbp)
mov    -0x2b(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121c <parsing_long_out_of_range+0xfc>
movl   $0x0,-0x4(%rbp)
jmp    121c <parsing_long_out_of_range+0xfc>
xor    %edi,%edi
call   1040 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsing_long_out_of_range>:
test   %edx,%edx
je     1147 <parsing_long_out_of_range+0x27>
push   %rax
add    $0xffffffffffffffff,%rsi
cmp    $0x7,%rsi
ja     1152 <parsing_long_out_of_range+0x32>
xor    %eax,%eax
lea    0xec8(%rip),%rcx
movslq (%rcx,%rsi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
movsbq %dil,%rcx
jmp    115e <parsing_long_out_of_range+0x3e>
jmp    1030 <parsing_ulong_out_of_range@plt>
movswq %di,%rcx
jmp    115e <parsing_long_out_of_range+0x3e>
xor    %edi,%edi
call   1040 <assert@plt>
pop    %rcx
ret
movslq %edi,%rcx
xor    %eax,%eax
cmp    %rdi,%rcx
setne  %al
pop    %rcx
ret

LLVM IR (-O0):
define i32 @parsing_long_out_of_range(i64 %0, i64 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp ne i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i64, i64* %5
%12 = load i64, i64* %6
%13 = call i32 @parsing_ulong_out_of_range(i64 %11, i64 %12)
store i32 %13, i32* %4
br label %46
14: ; preds = %3
%15 = load i64, i64* %6
switch i64 %15, label %44 [
i64 1, label %16
i64 2, label %25
i64 4, label %34
i64 8, label %43
]
16: ; preds = %14
%17 = load i64, i64* %5
%18 = icmp sgt i64 %17, 127
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i64, i64* %5
%21 = icmp slt i64 %20, -128
br label %22
22: ; preds = %19, %16
%23 = phi i1 [ true, %16 ], [ %21, %19 ]
%24 = zext i1 %23 to i32
store i32 %24, i32* %4
br label %46
25: ; preds = %14
%26 = load i64, i64* %5
%27 = icmp sgt i64 %26, 32767
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i64, i64* %5
%30 = icmp slt i64 %29, -32768
br label %31
31: ; preds = %28, %25
%32 = phi i1 [ true, %25 ], [ %30, %28 ]
%33 = zext i1 %32 to i32
store i32 %33, i32* %4
br label %46
34: ; preds = %14
%35 = load i64, i64* %5
%36 = icmp sgt i64 %35, 2147483647
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = load i64, i64* %5
%39 = icmp slt i64 %38, -2147483648
br label %40
40: ; preds = %37, %34
%41 = phi i1 [ true, %34 ], [ %39, %37 ]
%42 = zext i1 %41 to i32
store i32 %42, i32* %4
br label %46
43: ; preds = %14
store i32 0, i32* %4
br label %46
44: ; preds = %14
%45 = call i32 @assert(i32 0)
br label %46
46: ; preds = %10, %22, %31, %40, %43, %44
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
define i32 @parsing_long_out_of_range(i64 %0, i64 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @parsing_ulong_out_of_range(i64 %0, i64 %1)
br label %22
7: ; preds = %3
switch i64 %1, label %20 [
i64 1, label %8
i64 2, label %12
i64 4, label %16
i64 8, label %22
]
8: ; preds = %7
%9 = add i64 %0, -128
%10 = icmp ult i64 %9, -256
%11 = zext i1 %10 to i32
br label %22
12: ; preds = %7
%13 = add i64 %0, -32768
%14 = icmp ult i64 %13, -65536
%15 = zext i1 %14 to i32
br label %22
16: ; preds = %7
%17 = add i64 %0, -2147483648
%18 = icmp ult i64 %17, -4294967296
%19 = zext i1 %18 to i32
br label %22
20: ; preds = %7
%21 = tail call i32 @assert(i32 0)
br label %22
22: ; preds = %7, %5, %8, %12, %16, %20
%23 = phi i32 [ undef, %20 ], [ %19, %16 ], [ %15, %12 ], [ %11, %8 ], [ %6, %5 ], [ 0, %7 ]
ret i32 %23
}