#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 INT_MAX;
int INT_MIN;
int /*<<< orphan*/ assert(int);
int reverse_range_length(int /*<<< orphan*/);
int /*<<< orphan*/ reverse_range_make(int, int);
void reverse_range_length_test(void) {
  assert(0 == reverse_range_length(reverse_range_make(0, 0)));
  assert(0 == reverse_range_length(reverse_range_make(42, 42)));
  assert(1 == reverse_range_length(reverse_range_make(1, 0)));
  assert(1 == reverse_range_length(reverse_range_make(-1, -2)));
  assert(2 == reverse_range_length(reverse_range_make(12, 10)));
  assert(2 == reverse_range_length(reverse_range_make(1, -1)));
  assert(INT_MAX == reverse_range_length(reverse_range_make(-1, INT_MIN)));
  assert(INT_MAX == reverse_range_length(reverse_range_make(0, INT_MIN + 1)));
  assert(INT_MAX == reverse_range_length(reverse_range_make(1, INT_MIN + 2)));
  assert(INT_MAX == reverse_range_length(reverse_range_make(INT_MAX, 0)));
  assert(INT_MAX == reverse_range_length(reverse_range_make(INT_MAX - 1, -1)));
}


x86 assembly (clang, -O0):
<reverse_range_length_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %esi,%esi
mov    %esi,%edi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0x2a,%esi
mov    %esi,%edi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0xffffffff,%edi
mov    $0xfffffffe,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0xc,%edi
mov    $0xa,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
mov    $0xffffffff,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2d9f(%rip),%rax
mov    (%rax),%esi
mov    $0xffffffff,%edi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2d65(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
xor    %edi,%edi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
add    $0x2,%esi
mov    $0x1,%edi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    0x2ccb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
sub    $0x1,%edi
mov    $0xffffffff,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_range_length_test>:
push   %rbp
push   %r14
push   %rbx
xor    %edi,%edi
xor    %esi,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0x2a,%edi
mov    $0x2a,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0xffffffff,%edi
mov    $0xfffffffe,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0xc,%edi
mov    $0xa,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1030 <assert@plt>
mov    $0x1,%edi
mov    $0xffffffff,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1030 <assert@plt>
mov    0x2de0(%rip),%r14
mov    (%r14),%ebp
mov    0x2dce(%rip),%rbx
mov    (%rbx),%esi
mov    $0xffffffff,%edi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1030 <assert@plt>
mov    (%r14),%ebp
mov    (%rbx),%esi
add    $0x1,%esi
xor    %edi,%edi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1030 <assert@plt>
mov    (%r14),%ebp
mov    (%rbx),%esi
add    $0x2,%esi
mov    $0x1,%edi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1030 <assert@plt>
mov    (%r14),%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
call   1030 <assert@plt>
mov    (%r14),%ebx
lea    -0x1(%rbx),%edi
mov    $0xffffffff,%esi
call   1040 <reverse_range_make@plt>
mov    %eax,%edi
call   1050 <reverse_range_length@plt>
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <assert@plt>

LLVM IR (-O0):
@INT_MAX = global i32 0
@INT_MIN = global i32 0
define void @reverse_range_length_test() {
%1 = call i32 @reverse_range_make(i32 0, i32 0)
%2 = call i32 @reverse_range_length(i32 %1)
%3 = icmp eq i32 0, %2
%4 = zext i1 %3 to i32
%5 = call i32 @assert(i32 %4)
%6 = call i32 @reverse_range_make(i32 42, i32 42)
%7 = call i32 @reverse_range_length(i32 %6)
%8 = icmp eq i32 0, %7
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @reverse_range_make(i32 1, i32 0)
%12 = call i32 @reverse_range_length(i32 %11)
%13 = icmp eq i32 1, %12
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @reverse_range_make(i32 -1, i32 -2)
%17 = call i32 @reverse_range_length(i32 %16)
%18 = icmp eq i32 1, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @reverse_range_make(i32 12, i32 10)
%22 = call i32 @reverse_range_length(i32 %21)
%23 = icmp eq i32 2, %22
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @reverse_range_make(i32 1, i32 -1)
%27 = call i32 @reverse_range_length(i32 %26)
%28 = icmp eq i32 2, %27
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* @INT_MAX
%32 = load i32, i32* @INT_MIN
%33 = call i32 @reverse_range_make(i32 -1, i32 %32)
%34 = call i32 @reverse_range_length(i32 %33)
%35 = icmp eq i32 %31, %34
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* @INT_MAX
%39 = load i32, i32* @INT_MIN
%40 = add nsw i32 %39, 1
%41 = call i32 @reverse_range_make(i32 0, i32 %40)
%42 = call i32 @reverse_range_length(i32 %41)
%43 = icmp eq i32 %38, %42
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load i32, i32* @INT_MAX
%47 = load i32, i32* @INT_MIN
%48 = add nsw i32 %47, 2
%49 = call i32 @reverse_range_make(i32 1, i32 %48)
%50 = call i32 @reverse_range_length(i32 %49)
%51 = icmp eq i32 %46, %50
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load i32, i32* @INT_MAX
%55 = load i32, i32* @INT_MAX
%56 = call i32 @reverse_range_make(i32 %55, i32 0)
%57 = call i32 @reverse_range_length(i32 %56)
%58 = icmp eq i32 %54, %57
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
%61 = load i32, i32* @INT_MAX
%62 = load i32, i32* @INT_MAX
%63 = sub nsw i32 %62, 1
%64 = call i32 @reverse_range_make(i32 %63, i32 -1)
%65 = call i32 @reverse_range_length(i32 %64)
%66 = icmp eq i32 %61, %65
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
ret void
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@INT_MIN = global i32 0
define void @reverse_range_length_test() {
%1 = tail call i32 @reverse_range_make(i32 0, i32 0)
%2 = tail call i32 @reverse_range_length(i32 %1)
%3 = icmp eq i32 %2, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i32 @reverse_range_make(i32 42, i32 42)
%7 = tail call i32 @reverse_range_length(i32 %6)
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @reverse_range_make(i32 1, i32 0)
%12 = tail call i32 @reverse_range_length(i32 %11)
%13 = icmp eq i32 %12, 1
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 @reverse_range_make(i32 -1, i32 -2)
%17 = tail call i32 @reverse_range_length(i32 %16)
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @reverse_range_make(i32 12, i32 10)
%22 = tail call i32 @reverse_range_length(i32 %21)
%23 = icmp eq i32 %22, 2
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i32 @reverse_range_make(i32 1, i32 -1)
%27 = tail call i32 @reverse_range_length(i32 %26)
%28 = icmp eq i32 %27, 2
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = load i32, i32* @INT_MAX
%32 = load i32, i32* @INT_MIN
%33 = tail call i32 @reverse_range_make(i32 -1, i32 %32)
%34 = tail call i32 @reverse_range_length(i32 %33)
%35 = icmp eq i32 %31, %34
%36 = zext i1 %35 to i32
%37 = tail call i32 @assert(i32 %36)
%38 = load i32, i32* @INT_MAX
%39 = load i32, i32* @INT_MIN
%40 = add nsw i32 %39, 1
%41 = tail call i32 @reverse_range_make(i32 0, i32 %40)
%42 = tail call i32 @reverse_range_length(i32 %41)
%43 = icmp eq i32 %38, %42
%44 = zext i1 %43 to i32
%45 = tail call i32 @assert(i32 %44)
%46 = load i32, i32* @INT_MAX
%47 = load i32, i32* @INT_MIN
%48 = add nsw i32 %47, 2
%49 = tail call i32 @reverse_range_make(i32 1, i32 %48)
%50 = tail call i32 @reverse_range_length(i32 %49)
%51 = icmp eq i32 %46, %50
%52 = zext i1 %51 to i32
%53 = tail call i32 @assert(i32 %52)
%54 = load i32, i32* @INT_MAX
%55 = tail call i32 @reverse_range_make(i32 %54, i32 0)
%56 = tail call i32 @reverse_range_length(i32 %55)
%57 = icmp eq i32 %54, %56
%58 = zext i1 %57 to i32
%59 = tail call i32 @assert(i32 %58)
%60 = load i32, i32* @INT_MAX
%61 = add nsw i32 %60, -1
%62 = tail call i32 @reverse_range_make(i32 %61, i32 -1)
%63 = tail call i32 @reverse_range_length(i32 %62)
%64 = icmp eq i32 %60, %63
%65 = zext i1 %64 to i32
%66 = tail call i32 @assert(i32 %65)
ret void
}