#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 gen_rand();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int a, b;
  int i, t;
  int stat[50];
  printf("uniform range: n m\n");
  scanf("%d %d", &a, &b);
  if (a > b)
    return -1;
  for (i = 0; i < 50; i++)
    stat[i] = 0;
  for (i = 0; i < 50; i++) {
    t = (a + gen_rand() % (1 + b - a));
    if (t < 50 && t >= 0) {
      stat[t]++;
    } else {
      printf("Oops!\n");
    }
    printf("%d\n", t);
  }
  for (i = a; i <= b; i++) {
    printf("%d %f\n", i, (double)stat[i] / (double)50);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    117c <main+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    128e <main+0x15e>
movl   $0x0,-0x10(%rbp)
cmpl   $0x32,-0x10(%rbp)
jge    11aa <main+0x7a>
movslq -0x10(%rbp),%rax
movl   $0x0,-0xe0(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1183 <main+0x53>
movl   $0x0,-0x10(%rbp)
cmpl   $0x32,-0x10(%rbp)
jge    123d <main+0x10d>
mov    -0x8(%rbp),%eax
mov    %eax,-0xe4(%rbp)
mov    $0x0,%al
call   1040 <gen_rand@plt>
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
sub    -0x8(%rbp),%ecx
cltd
idiv   %ecx
mov    -0xe4(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jge    1210 <main+0xe0>
cmpl   $0x0,-0x14(%rbp)
jl     1210 <main+0xe0>
movslq -0x14(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xe0(%rbp,%rax,4)
jmp    121e <main+0xee>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b1 <main+0x81>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1287 <main+0x157>
mov    -0x10(%rbp),%esi
movslq -0x10(%rbp),%rax
cvtsi2sdl -0xe0(%rbp,%rax,4),%xmm0
ff ff
movsd  0xd99(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xdbb(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1243 <main+0x113>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
mov    0xc(%rsp),%r12d
mov    $0xffffffff,%r14d
cmp    0x8(%rsp),%r12d
jg     12a0 <main+0x160>
xorpd  %xmm0,%xmm0
movapd %xmm0,0xc0(%rsp)
movapd %xmm0,0xb0(%rsp)
movapd %xmm0,0xa0(%rsp)
movapd %xmm0,0x90(%rsp)
movapd %xmm0,0x80(%rsp)
movapd %xmm0,0x70(%rsp)
movapd %xmm0,0x60(%rsp)
movapd %xmm0,0x50(%rsp)
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x30(%rsp)
movapd %xmm0,0x20(%rsp)
movapd %xmm0,0x10(%rsp)
movq   $0x0,0xd0(%rsp)
mov    $0x32,%ebx
lea    0xe14(%rip),%r14
lea    0xe2b(%rip),%r15
jmp    122e <main+0xee>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%r12d
add    $0xffffffff,%ebx
je     1256 <main+0x116>
xor    %eax,%eax
call   1050 <gen_rand@plt>
mov    0x8(%rsp),%ecx
sub    0xc(%rsp),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,%ebp
add    %r12d,%ebp
cmp    $0x31,%ebp
ja     1210 <main+0xd0>
mov    %ebp,%eax
addl   $0x1,0x10(%rsp,%rax,4)
jmp    1218 <main+0xd8>
xor    %r14d,%r14d
cmp    0x8(%rsp),%r12d
jg     12a0 <main+0x160>
movslq %r12d,%rbx
add    $0xffffffffffffffff,%rbx
lea    0xda4(%rip),%rbp
xchg   %ax,%ax
xorps  %xmm0,%xmm0
cvtsi2sdl 0x14(%rsp,%rbx,4),%xmm0
divsd  0xd7f(%rip),%xmm0
mov    %rbp,%rdi
mov    %r12d,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movslq 0x8(%rsp),%rax
add    $0x1,%rbx
add    $0x1,%r12d
cmp    %rax,%rbx
jl     1270 <main+0x130>
mov    %r14d,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"uniform range: n m\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [7 x i8] c"Oops!\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [7 x i8] c"%d %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [50 x i32]
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = icmp sgt i32 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 -1, i32* %1
br label %75
13: ; preds = %0
store i32 0, i32* %4
br label %14
14: ; preds = %21, %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 50
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %19
store i32 0, i32* %20
br label %21
21: ; preds = %17
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %14
24: ; preds = %14
store i32 0, i32* %4
br label %25
25: ; preds = %53, %24
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 50
br i1 %27, label %28, label %56
28: ; preds = %25
%29 = load i32, i32* %2
%30 = call i32 (...) @gen_rand()
%31 = load i32, i32* %3
%32 = add nsw i32 1, %31
%33 = load i32, i32* %2
%34 = sub nsw i32 %32, %33
%35 = srem i32 %30, %34
%36 = add nsw i32 %29, %35
store i32 %36, i32* %5
%37 = load i32, i32* %5
%38 = icmp slt i32 %37, 50
br i1 %38, label %39, label %48
39: ; preds = %28
%40 = load i32, i32* %5
%41 = icmp sge i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = add nsw i32 %46, 1
store i32 %47, i32* %45
br label %50
48: ; preds = %39, %28
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48, %42
%51 = load i32, i32* %5
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %50
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %25
56: ; preds = %25
%57 = load i32, i32* %2
store i32 %57, i32* %4
br label %58
58: ; preds = %71, %56
%59 = load i32, i32* %4
%60 = load i32, i32* %3
%61 = icmp sle i32 %59, %60
br i1 %61, label %62, label %74
62: ; preds = %58
%63 = load i32, i32* %4
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 %65
%67 = load i32, i32* %66
%68 = sitofp i32 %67 to double
%69 = fdiv double %68, 5.000000e+01
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %63, double %69)
br label %71
71: ; preds = %62
%72 = load i32, i32* %4
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
br label %58
74: ; preds = %58
store i32 0, i32* %1
br label %75
75: ; preds = %74, %12
%76 = load i32, i32* %1
ret i32 %76
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [7 x i8] c"%d %f\0A\00"
@str = [19 x i8] c"uniform range: n m\00"
@str.5 = [6 x i8] c"Oops!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [50 x i32]
%4 = bitcast [50 x i32]* %3 to i8*
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %9, %10
br i1 %11, label %53, label %12
12: ; preds = %0
br label %13
13: ; preds = %31, %12
%14 = phi i32 [ %9, %12 ], [ %35, %31 ]
%15 = phi i32 [ 0, %12 ], [ %33, %31 ]
%16 = call i32 (...) @gen_rand()
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
%19 = load i32, i32* %1
%20 = sub i32 %18, %19
%21 = srem i32 %16, %20
%22 = add nsw i32 %21, %14
%23 = icmp ult i32 %22, 50
br i1 %23, label %24, label %29
24: ; preds = %13
%25 = zext i32 %22 to i64
%26 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1
store i32 %28, i32* %26
br label %31
29: ; preds = %13
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0))
br label %31
31: ; preds = %29, %24
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%33 = add nuw nsw i32 %15, 1
%34 = icmp eq i32 %33, 50
%35 = load i32, i32* %1
br i1 %34, label %36, label %13
36: ; preds = %31
%37 = load i32, i32* %2
%38 = icmp sgt i32 %35, %37
br i1 %38, label %53, label %39
39: ; preds = %36
%40 = sext i32 %35 to i64
br label %41
41: ; preds = %39, %41
%42 = phi i64 [ %40, %39 ], [ %49, %41 ]
%43 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = sitofp i32 %44 to double
%46 = fdiv double %45, 5.000000e+01
%47 = trunc i64 %42 to i32
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %47, double %46)
%49 = add nsw i64 %42, 1
%50 = load i32, i32* %2
%51 = sext i32 %50 to i64
%52 = icmp slt i64 %42, %51
br i1 %52, label %41, label %53
53: ; preds = %41, %36, %0
%54 = phi i32 [ -1, %0 ], [ 0, %36 ], [ 0, %41 ]
ret i32 %54
}