#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*/ error(int /*<<< orphan*/, char *);
double ranf();
int irandom(int i, int n) {
  double num_alea;
  if (i > n)
    error(0, "random Argument Error: i > n");
  num_alea = ranf();
  if (num_alea == 1.) {
    return (n);
  }
  n -= i;
  n = (int)((n + 1.0) * num_alea);
  return (i + n);
}


x86 assembly (clang, -O0):
<irandom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1148 <irandom+0x28>
xor    %edi,%edi
lea    0xec5(%rip),%rsi
call   1040 <error@plt>
mov    $0x0,%al
call   1030 <ranf@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    117c <irandom+0x5c>
jp     117c <irandom+0x5c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ad <irandom+0x8d>
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xe6c(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<irandom>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
mov    %esi,%ebx
sub    %edi,%ebx
jge    113d <irandom+0x1d>
lea    0xed2(%rip),%rsi
xor    %edi,%edi
call   1040 <error@plt>
xor    %eax,%eax
call   1030 <ranf@plt>
ucomisd 0xeb4(%rip),%xmm0
jne    1150 <irandom+0x30>
jnp    1167 <irandom+0x47>
cvtsi2sd %ebx,%xmm1
addsd  0xea4(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%ebp
add    %r14d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"random Argument Error: i > n\00"
define i32 @irandom(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = icmp sgt i32 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @error(i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = call double (...) @ranf()
store double %13, double* %6
%14 = load double, double* %6
%15 = fcmp oeq double %14, 1.000000e+00
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = load i32, i32* %5
store i32 %17, i32* %3
br label %31
18: ; preds = %12
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = sub nsw i32 %20, %19
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = sitofp i32 %22 to double
%24 = fadd double %23, 1.000000e+00
%25 = load double, double* %6
%26 = fmul double %24, %25
%27 = fptosi double %26 to i32
store i32 %27, i32* %5
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = add nsw i32 %28, %29
store i32 %30, i32* %3
br label %31
31: ; preds = %18, %16
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [29 x i8] c"random Argument Error: i > n\00"
define i32 @irandom(i32 %0, i32 %1) {
%3 = icmp slt i32 %1, %0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @error(i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = tail call double (...) @ranf()
%8 = fcmp oeq double %7, 1.000000e+00
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = sub nsw i32 %1, %0
%11 = sitofp i32 %10 to double
%12 = fadd double %11, 1.000000e+00
%13 = fmul double %12, %7
%14 = fptosi double %13 to i32
%15 = add nsw i32 %14, %0
br label %16
16: ; preds = %6, %9
%17 = phi i32 [ %15, %9 ], [ %1, %6 ]
ret i32 %17
}