#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 cputime();
double drand48();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
main() {
  int i;
  double temp1, temp2, rn;
  double temp_mult = 1000000 / 1.0e6;
  temp1 = cputime();
  for (i = 0; i < 1000000; i++)
    rn = drand48();
  temp2 = cputime();
  if (temp2 - temp1 < 1.0e-15) {
    printf("Timing Information not available/not accurate "
           "enough.\n\t...Exiting\n");
    exit(1);
  }
  fprintf(stderr, "Last random number generated\n", rn);
  printf("\nUser + System time Information (Note: MRS = Million Random Numbers "
         "Per Second)\n");
  printf("\tDRAND48:\t Time = %7.3f seconds => %8.4f MRS\n", temp2 - temp1,
         temp_mult / (temp2 - temp1));
  putchar('\n');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <cputime@plt>
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    11b6 <main+0x56>
mov    $0x0,%al
call   1080 <drand48@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118f <main+0x2f>
mov    $0x0,%al
call   1050 <cputime@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe34(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f6 <main+0x96>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
movsd  -0x20(%rbp),%xmm0
lea    0xe48(%rip),%rsi
call   1060 <fprintf@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
subsd  -0x10(%rbp),%xmm2
divsd  %xmm2,%xmm1
lea    0xe80(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1060 <cputime@plt>
movsd  %xmm0,(%rsp)
mov    $0xf4240,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <drand48@plt>
add    $0xffffffff,%ebx
jne    1190 <main+0x20>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <cputime@plt>
subsd  (%rsp),%xmm0
movsd  0xe4a(%rip),%xmm1
movsd  %xmm0,(%rsp)
ucomisd %xmm0,%xmm1
ja     1219 <main+0xa9>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
movsd  0x8(%rsp),%xmm0
call   1070 <fprintf@plt>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
movsd  0xe18(%rip),%xmm1
movsd  (%rsp),%xmm0
divsd  %xmm0,%xmm1
lea    0xe2e(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [67 x i8] c"Timing Information not available/not accurate enough.\0A\09...Exiting\0A\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Last random number generated\0A\00"
@.str.2 = [81 x i8] c"\0AUser + System time Information (Note: MRS = Million Random Numbers Per Second)\0A\00"
@.str.3 = [46 x i8] c"\09DRAND48:\09 Time = %7.3f seconds => %8.4f MRS\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %6
%7 = call double (...) @cputime()
store double %7, double* %3
store i32 0, i32* %2
br label %8
8: ; preds = %13, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1000000
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = call double (...) @drand48()
store double %12, double* %5
br label %13
13: ; preds = %11
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %8
16: ; preds = %8
%17 = call double (...) @cputime()
store double %17, double* %4
%18 = load double, double* %4
%19 = load double, double* %3
%20 = fsub double %18, %19
%21 = fcmp olt double %20, 1.000000e-15
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %16
%26 = load i32, i32* @stderr
%27 = load double, double* %5
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.2, i64 0, i64 0))
%30 = load double, double* %4
%31 = load double, double* %3
%32 = fsub double %30, %31
%33 = load double, double* %6
%34 = load double, double* %4
%35 = load double, double* %3
%36 = fsub double %34, %35
%37 = fdiv double %33, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), double %32, double %37)
%39 = call i32 @putchar(i8 signext 10)
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [30 x i8] c"Last random number generated\0A\00"
@.str.3 = [46 x i8] c"\09DRAND48:\09 Time = %7.3f seconds => %8.4f MRS\0A\00"
@str = [80 x i8] c"\0AUser + System time Information (Note: MRS = Million Random Numbers Per Second)\00"
@str.4 = [66 x i8] c"Timing Information not available/not accurate enough.\0A\09...Exiting\00"
define i32 @main() {
%1 = tail call double (...) @cputime()
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %5, %2 ]
%4 = tail call double (...) @drand48()
%5 = add nuw nsw i32 %3, 1
%6 = icmp eq i32 %5, 1000000
br i1 %6, label %7, label %2
7: ; preds = %2
%8 = tail call double (...) @cputime()
%9 = fsub double %8, %1
%10 = fcmp olt double %9, 1.000000e-15
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.4, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), double %4)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str, i64 0, i64 0))
%18 = fdiv double 1.000000e+00, %9
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), double %9, double %18)
%20 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}