#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 */
double myrandom(int);
int /*<<< orphan*/ printf(char *, int, int);
int rint(double);
int random_uniform_int(int sn, int a, int b) {
  double b2;
  if (a > b)
    printf("uniform-int argument error: a = %d > b = %d\n", a, b);
  b2 = (double)b - a + 1.0;
  b2 = (double)b2 * myrandom(sn) - 0.5;
  return (a + rint(b2));
}


x86 assembly (clang, -O0):
<random_uniform_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    115f <random_uniform_int+0x2f>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe93(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <myrandom@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe5c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <rint@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_uniform_int>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r14d
cmp    %edx,%esi
jle    1153 <random_uniform_int+0x23>
lea    0xec6(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
cvtsi2sd %ebp,%xmm1
cvtsi2sd %ebx,%xmm0
subsd  %xmm0,%xmm1
addsd  0xe99(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r14d,%edi
call   1050 <myrandom@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0xe85(%rip),%xmm0
call   1040 <rint@plt>
add    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"uniform-int argument error: a = %d > b = %d\0A\00"
define i32 @random_uniform_int(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = icmp sgt i32 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
br label %15
15: ; preds = %11, %3
%16 = load i32, i32* %6
%17 = sitofp i32 %16 to double
%18 = load i32, i32* %5
%19 = sitofp i32 %18 to double
%20 = fsub double %17, %19
%21 = fadd double %20, 1.000000e+00
store double %21, double* %7
%22 = load double, double* %7
%23 = load i32, i32* %4
%24 = call double @myrandom(i32 %23)
%25 = call double @llvm.fmuladd.f64(double %22, double %24, double -5.000000e-01)
store double %25, double* %7
%26 = load i32, i32* %5
%27 = load double, double* %7
%28 = call i32 @rint(double %27)
%29 = add nsw i32 %26, %28
ret i32 %29
}

LLVM IR (-O2):
@.str = [45 x i8] c"uniform-int argument error: a = %d > b = %d\0A\00"
define i32 @random_uniform_int(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, %2
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
br label %7
7: ; preds = %5, %3
%8 = sitofp i32 %2 to double
%9 = sitofp i32 %1 to double
%10 = fsub double %8, %9
%11 = fadd double %10, 1.000000e+00
%12 = tail call double @myrandom(i32 %0)
%13 = tail call double @llvm.fmuladd.f64(double %11, double %12, double -5.000000e-01)
%14 = tail call i32 @rint(double %13)
%15 = add nsw i32 %14, %1
ret i32 %15
}