#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 get_seconds();
float my_random_double();
int /*<<< orphan*/ printf(char *, double);
float random_double();
int /*<<< orphan*/ srandom(int);
main(int argc, char *argv[]) {
  int i;
  float f;
  double t0, t1;
  int iters = 1000000000;
  int seed = 17;
  srandom(seed);
  t0 = get_seconds();
  for (i = 0; i < iters; i++) {
    f = my_random_double();
  }
  t1 = get_seconds();
  printf("mine \t %f ms\n", t1 - t0);
  srandom(seed);
  t0 = get_seconds();
  for (i = 0; i < iters; i++) {
    f = my_random_double();
  }
  t1 = get_seconds();
  printf("mine \t %f ms\n", t1 - t0);
  srandom(seed);
  t0 = get_seconds();
  for (i = 0; i < iters; i++) {
    f = random_double();
  }
  t1 = get_seconds();
  printf("theirs \t %f ms\n", t1 - t0);
  srandom(seed);
  t0 = get_seconds();
  for (i = 0; i < iters; i++) {
    f = random_double();
  }
  t1 = get_seconds();
  printf("theirs \t %f ms\n", t1 - t0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3b9aca00,-0x2c(%rbp)
movl   $0x11,-0x30(%rbp)
mov    -0x30(%rbp),%edi
call   1040 <srandom@plt>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11b5 <main+0x65>
mov    $0x0,%al
call   1060 <my_random_double@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <main+0x3f>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xe2e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%edi
call   1040 <srandom@plt>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1218 <main+0xc8>
mov    $0x0,%al
call   1060 <my_random_double@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f2 <main+0xa2>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xdcb(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%edi
call   1040 <srandom@plt>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    127b <main+0x12b>
mov    $0x0,%al
call   1070 <random_double@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1255 <main+0x105>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xd76(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%edi
call   1040 <srandom@plt>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12de <main+0x18e>
mov    $0x0,%al
call   1070 <random_double@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12b8 <main+0x168>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xd13(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x11,%edi
call   1040 <srandom@plt>
xor    %eax,%eax
call   1030 <get_seconds@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x3b9aca00,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <my_random_double@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x30>
xor    %eax,%eax
call   1030 <get_seconds@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
mov    $0x11,%edi
call   1040 <srandom@plt>
xor    %eax,%eax
call   1030 <get_seconds@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x3b9aca00,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <my_random_double@plt>
add    $0xffffffff,%ebx
jne    11d0 <main+0x80>
xor    %eax,%eax
call   1030 <get_seconds@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe10(%rip),%rdi
call   1050 <printf@plt>
mov    $0x11,%edi
call   1040 <srandom@plt>
xor    %eax,%eax
call   1030 <get_seconds@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x3b9aca00,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <random_double@plt>
add    $0xffffffff,%ebx
jne    1220 <main+0xd0>
xor    %eax,%eax
call   1030 <get_seconds@plt>
subsd  0x8(%rsp),%xmm0
lea    0xdce(%rip),%rdi
call   1050 <printf@plt>
mov    $0x11,%edi
call   1040 <srandom@plt>
xor    %eax,%eax
call   1030 <get_seconds@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x3b9aca00,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <random_double@plt>
add    $0xffffffff,%ebx
jne    1270 <main+0x120>
xor    %eax,%eax
call   1030 <get_seconds@plt>
subsd  0x8(%rsp),%xmm0
lea    0xd7e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"mine \09 %f ms\0A\00"
@.str.1 = [16 x i8] c"theirs \09 %f ms\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca float
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1000000000, i32* %10
store i32 17, i32* %11
%12 = load i32, i32* %11
%13 = call i32 @srandom(i32 %12)
%14 = call double (...) @get_seconds()
store double %14, double* %8
store i32 0, i32* %6
br label %15
15: ; preds = %21, %2
%16 = load i32, i32* %6
%17 = load i32, i32* %10
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = call float (...) @my_random_double()
store float %20, float* %7
br label %21
21: ; preds = %19
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %15
24: ; preds = %15
%25 = call double (...) @get_seconds()
store double %25, double* %9
%26 = load double, double* %9
%27 = load double, double* %8
%28 = fsub double %26, %27
%29 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %28)
%30 = load i32, i32* %11
%31 = call i32 @srandom(i32 %30)
%32 = call double (...) @get_seconds()
store double %32, double* %8
store i32 0, i32* %6
br label %33
33: ; preds = %39, %24
%34 = load i32, i32* %6
%35 = load i32, i32* %10
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = call float (...) @my_random_double()
store float %38, float* %7
br label %39
39: ; preds = %37
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %33
42: ; preds = %33
%43 = call double (...) @get_seconds()
store double %43, double* %9
%44 = load double, double* %9
%45 = load double, double* %8
%46 = fsub double %44, %45
%47 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %46)
%48 = load i32, i32* %11
%49 = call i32 @srandom(i32 %48)
%50 = call double (...) @get_seconds()
store double %50, double* %8
store i32 0, i32* %6
br label %51
51: ; preds = %57, %42
%52 = load i32, i32* %6
%53 = load i32, i32* %10
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = call float (...) @random_double()
store float %56, float* %7
br label %57
57: ; preds = %55
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %51
60: ; preds = %51
%61 = call double (...) @get_seconds()
store double %61, double* %9
%62 = load double, double* %9
%63 = load double, double* %8
%64 = fsub double %62, %63
%65 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %64)
%66 = load i32, i32* %11
%67 = call i32 @srandom(i32 %66)
%68 = call double (...) @get_seconds()
store double %68, double* %8
store i32 0, i32* %6
br label %69
69: ; preds = %75, %60
%70 = load i32, i32* %6
%71 = load i32, i32* %10
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %78
73: ; preds = %69
%74 = call float (...) @random_double()
store float %74, float* %7
br label %75
75: ; preds = %73
%76 = load i32, i32* %6
%77 = add nsw i32 %76, 1
store i32 %77, i32* %6
br label %69
78: ; preds = %69
%79 = call double (...) @get_seconds()
store double %79, double* %9
%80 = load double, double* %9
%81 = load double, double* %8
%82 = fsub double %80, %81
%83 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %82)
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@.str = [14 x i8] c"mine \09 %f ms\0A\00"
@.str.1 = [16 x i8] c"theirs \09 %f ms\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @srandom(i32 17)
%4 = tail call double (...) @get_seconds()
br label %5
5: ; preds = %2, %5
%6 = phi i32 [ 0, %2 ], [ %8, %5 ]
%7 = tail call float (...) @my_random_double()
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 1000000000
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = tail call double (...) @get_seconds()
%12 = fsub double %11, %4
%13 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %12)
%14 = tail call i32 @srandom(i32 17)
%15 = tail call double (...) @get_seconds()
br label %16
16: ; preds = %10, %16
%17 = phi i32 [ 0, %10 ], [ %19, %16 ]
%18 = tail call float (...) @my_random_double()
%19 = add nuw nsw i32 %17, 1
%20 = icmp eq i32 %19, 1000000000
br i1 %20, label %21, label %16
21: ; preds = %16
%22 = tail call double (...) @get_seconds()
%23 = fsub double %22, %15
%24 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), double %23)
%25 = tail call i32 @srandom(i32 17)
%26 = tail call double (...) @get_seconds()
br label %27
27: ; preds = %21, %27
%28 = phi i32 [ 0, %21 ], [ %30, %27 ]
%29 = tail call float (...) @random_double()
%30 = add nuw nsw i32 %28, 1
%31 = icmp eq i32 %30, 1000000000
br i1 %31, label %32, label %27
32: ; preds = %27
%33 = tail call double (...) @get_seconds()
%34 = fsub double %33, %26
%35 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %34)
%36 = tail call i32 @srandom(i32 17)
%37 = tail call double (...) @get_seconds()
br label %38
38: ; preds = %32, %38
%39 = phi i32 [ 0, %32 ], [ %41, %38 ]
%40 = tail call float (...) @random_double()
%41 = add nuw nsw i32 %39, 1
%42 = icmp eq i32 %41, 1000000000
br i1 %42, label %43, label %38
43: ; preds = %38
%44 = tail call double (...) @get_seconds()
%45 = fsub double %44, %37
%46 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %45)
ret i32 0
}