#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 _xte_random(int);
int /*<<< orphan*/ assert(int);
int _xte_resolve_ordinal(int in_total_items, int in_ordinal) {
  assert(((in_total_items >= 0) && (in_total_items <= 25000000)));
  assert(((in_ordinal >= -5) && (in_ordinal <= 1)));
  switch (in_ordinal) {
  case -1:
    return in_total_items;
  case -2:
    if (in_total_items < 2)
      return in_total_items;
    else
      return in_total_items / 2;
  case -3:
    return _xte_random(in_total_items);
  }
  return in_ordinal;
}


x86 assembly (clang, -O0):
<_xte_resolve_ordinal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0xd(%rbp)
jl     114a <_xte_resolve_ordinal+0x2a>
cmpl   $0x17d7840,-0x8(%rbp)
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmpl   $0xfffffffb,-0xc(%rbp)
mov    %al,-0xe(%rbp)
jl     1170 <_xte_resolve_ordinal+0x50>
cmpl   $0x1,-0xc(%rbp)
setle  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
movzbl %al,%edi
and    $0x1,%edi
call   1040 <assert@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0xfffffffd,%eax
je     11e7 <_xte_resolve_ordinal+0xc7>
jmp    1192 <_xte_resolve_ordinal+0x72>
mov    -0x14(%rbp),%eax
sub    $0xfffffffe,%eax
je     11bf <_xte_resolve_ordinal+0x9f>
jmp    11a3 <_xte_resolve_ordinal+0x83>
mov    -0x14(%rbp),%eax
sub    $0xffffffff,%eax
jne    11f7 <_xte_resolve_ordinal+0xd7>
jmp    11b4 <_xte_resolve_ordinal+0x94>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fd <_xte_resolve_ordinal+0xdd>
cmpl   $0x2,-0x8(%rbp)
jge    11d4 <_xte_resolve_ordinal+0xb4>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fd <_xte_resolve_ordinal+0xdd>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11fd <_xte_resolve_ordinal+0xdd>
mov    -0x8(%rbp),%edi
call   1030 <_xte_random@plt>
mov    %eax,-0x4(%rbp)
jmp    11fd <_xte_resolve_ordinal+0xdd>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_xte_resolve_ordinal>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x17d7841,%ebp
setb   %dil
call   1040 <assert@plt>
lea    0x5(%rbx),%eax
xor    %edi,%edi
cmp    $0x7,%eax
setb   %dil
call   1040 <assert@plt>
cmp    $0xfffffffd,%ebx
je     116b <_xte_resolve_ordinal+0x4b>
cmp    $0xffffffff,%ebx
je     1160 <_xte_resolve_ordinal+0x40>
cmp    $0xfffffffe,%ebx
jne    1162 <_xte_resolve_ordinal+0x42>
cmp    $0x2,%ebp
setge  %cl
shr    %cl,%ebp
mov    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <_xte_random@plt>

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

LLVM IR (-O2):
define i32 @_xte_resolve_ordinal(i32 %0, i32 %1) {
%3 = icmp ult i32 %0, 25000001
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = add i32 %1, 5
%7 = icmp ult i32 %6, 7
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
switch i32 %1, label %16 [
i32 -1, label %17
i32 -2, label %10
i32 -3, label %14
]
10: ; preds = %2
%11 = icmp sgt i32 %0, 1
%12 = zext i1 %11 to i32
%13 = lshr i32 %0, %12
br label %17
14: ; preds = %2
%15 = tail call i32 @_xte_random(i32 %0)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %10, %2, %16, %14
%18 = phi i32 [ %1, %16 ], [ %15, %14 ], [ %0, %2 ], [ %13, %10 ]
ret i32 %18
}