#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 number_mm();
int number_range(int from, int to) {
  int power;
  int number;
  if ((to = to - from + 1) <= 1)
    return from;
  for (power = 2; power < to; power <<= 1)
    ;
  while ((number = number_mm() & (power - 1)) >= to)
    ;
  return from + number;
}


x86 assembly (clang, -O0):
<number_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x1,%eax
jg     113e <number_range+0x2e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <number_range+0x82>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1164 <number_range+0x54>
jmp    1156 <number_range+0x46>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <number_range+0x35>
jmp    1169 <number_range+0x59>
mov    $0x0,%al
call   1030 <number_mm@plt>
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmp    -0xc(%rbp),%eax
jl     1189 <number_range+0x79>
jmp    1169 <number_range+0x59>
mov    -0x8(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_range>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
sub    %edi,%ebp
jle    1150 <number_range+0x40>
mov    $0x2,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%ebx
lea    (%rbx,%rbx,1),%eax
cmp    %ebp,%ebx
jle    1130 <number_range+0x20>
add    $0xffffffff,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <number_mm@plt>
and    %ebx,%eax
cmp    %ebp,%eax
jg     1140 <number_range+0x30>
add    %eax,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @number_range(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %8, %9
%11 = add nsw i32 %10, 1
store i32 %11, i32* %5
%12 = icmp sle i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i32, i32* %4
store i32 %14, i32* %3
br label %37
15: ; preds = %2
store i32 2, i32* %6
br label %16
16: ; preds = %21, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
br label %21
21: ; preds = %20
%22 = load i32, i32* %6
%23 = shl i32 %22, 1
store i32 %23, i32* %6
br label %16
24: ; preds = %16
br label %25
25: ; preds = %32, %24
%26 = call i32 (...) @number_mm()
%27 = load i32, i32* %6
%28 = sub nsw i32 %27, 1
%29 = and i32 %26, %28
store i32 %29, i32* %7
%30 = load i32, i32* %5
%31 = icmp sge i32 %29, %30
br i1 %31, label %32, label %33
32: ; preds = %25
br label %25
33: ; preds = %25
%34 = load i32, i32* %4
%35 = load i32, i32* %7
%36 = add nsw i32 %34, %35
store i32 %36, i32* %3
br label %37
37: ; preds = %33, %13
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
define i32 @number_range(i32 %0, i32 %1) {
%3 = sub nsw i32 %1, %0
%4 = icmp slt i32 %3, 1
br i1 %4, label %17, label %5
5: ; preds = %2, %5
%6 = phi i32 [ %8, %5 ], [ 2, %2 ]
%7 = icmp sgt i32 %6, %3
%8 = shl i32 %6, 1
br i1 %7, label %9, label %5
9: ; preds = %5
%10 = add nsw i32 %6, -1
br label %11
11: ; preds = %9, %11
%12 = tail call i32 (...) @number_mm()
%13 = and i32 %12, %10
%14 = icmp sgt i32 %13, %3
br i1 %14, label %11, label %15
15: ; preds = %11
%16 = add nsw i32 %13, %0
br label %17
17: ; preds = %2, %15
%18 = phi i32 [ %16, %15 ], [ %0, %2 ]
ret i32 %18
}