#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 */
struct BasePRNGObject {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
double stdlib_base_prng_normalized_min(struct BasePRNGObject *);
struct BasePRNGObject *stdlib_base_random_randu_allocate(int /*<<< orphan*/);
int /*<<< orphan*/ stdlib_base_random_randu_free(struct BasePRNGObject *);
double tic();
double benchmark1() {
  double elapsed;
  double t;
  int i;
  struct BasePRNGObject *obj;
  t = tic();
  for (i = 0; i < 1000000; i++) {
    obj = stdlib_base_random_randu_allocate(0);
    if (obj == NULL || stdlib_base_prng_normalized_min(obj) != 0.0) {
      printf("unexpected result\n");
      break;
    }
    if (i < 1000000 - 1) {
      stdlib_base_random_randu_free(obj);
    }
  }
  elapsed = tic() - t;
  if (obj == NULL || stdlib_base_prng_normalized_min(obj) != 0.0) {
    printf("unexpected result\n");
  }
  stdlib_base_random_randu_free(obj);
  return elapsed;
}


x86 assembly (clang, -O0):
<benchmark1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <tic@plt>
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xf4240,-0x14(%rbp)
jge    11e9 <benchmark1+0x99>
xor    %edi,%edi
call   1060 <stdlib_base_random_randu_allocate@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11af <benchmark1+0x5f>
mov    -0x20(%rbp),%rdi
call   1030 <stdlib_base_prng_normalized_min@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11af <benchmark1+0x5f>
jp     11af <benchmark1+0x5f>
jmp    11c0 <benchmark1+0x70>
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
jmp    11e9 <benchmark1+0x99>
cmpl   $0xf423f,-0x14(%rbp)
jge    11d6 <benchmark1+0x86>
mov    -0x20(%rbp),%rdi
call   1070 <stdlib_base_random_randu_free@plt>
jmp    11db <benchmark1+0x8b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116b <benchmark1+0x1b>
mov    $0x0,%al
call   1050 <tic@plt>
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1226 <benchmark1+0xd6>
mov    -0x20(%rbp),%rdi
call   1030 <stdlib_base_prng_normalized_min@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1226 <benchmark1+0xd6>
jp     1226 <benchmark1+0xd6>
jmp    1232 <benchmark1+0xe2>
lea    0xdd3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <stdlib_base_random_randu_free@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark1>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <tic@plt>
movsd  %xmm0,0x10(%rsp)
jmp    117b <benchmark1+0x2b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0xf4240,%ebp
je     11d2 <benchmark1+0x82>
xor    %edi,%edi
call   1060 <stdlib_base_random_randu_allocate@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11b0 <benchmark1+0x60>
mov    %rbx,%rdi
call   1040 <stdlib_base_prng_normalized_min@plt>
ucomisd 0xe66(%rip),%xmm0
jne    11b0 <benchmark1+0x60>
jp     11b0 <benchmark1+0x60>
cmp    $0xf423e,%ebp
ja     1170 <benchmark1+0x20>
mov    %rbx,%rdi
call   1070 <stdlib_base_random_randu_free@plt>
jmp    1170 <benchmark1+0x20>
lea    0xe51(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <tic@plt>
movsd  %xmm0,0x8(%rsp)
test   %rbx,%rbx
jne    11df <benchmark1+0x8f>
xor    %ebx,%ebx
jmp    11f3 <benchmark1+0xa3>
xor    %eax,%eax
call   1050 <tic@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <stdlib_base_prng_normalized_min@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11f3 <benchmark1+0xa3>
jnp    11ff <benchmark1+0xaf>
lea    0xe0e(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1070 <stdlib_base_random_randu_free@plt>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.BasePRNGObject = type { i32 }
@.str = [19 x i8] c"unexpected result\0A\00"
define double @benchmark1() {
%1 = alloca double
%2 = alloca double
%3 = alloca i32
%4 = alloca %struct.BasePRNGObject*
%5 = call double (...) @tic()
store double %5, double* %2
store i32 0, i32* %3
br label %6
6: ; preds = %26, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 1000000
br i1 %8, label %9, label %29
9: ; preds = %6
%10 = call %struct.BasePRNGObject* @stdlib_base_random_randu_allocate(i32 0)
store %struct.BasePRNGObject* %10, %struct.BasePRNGObject** %4
%11 = load %struct.BasePRNGObject*, %struct.BasePRNGObject** %4
%12 = icmp eq %struct.BasePRNGObject* %11, null
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = load %struct.BasePRNGObject*, %struct.BasePRNGObject** %4
%15 = call double @stdlib_base_prng_normalized_min(%struct.BasePRNGObject* %14)
%16 = fcmp une double %15, 0.000000e+00
br i1 %16, label %17, label %19
17: ; preds = %13, %9
%18 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %29
19: ; preds = %13
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 999999
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load %struct.BasePRNGObject*, %struct.BasePRNGObject** %4
%24 = call i32 @stdlib_base_random_randu_free(%struct.BasePRNGObject* %23)
br label %25
25: ; preds = %22, %19
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %6
29: ; preds = %17, %6
%30 = call double (...) @tic()
%31 = load double, double* %2
%32 = fsub double %30, %31
store double %32, double* %1
%33 = load %struct.BasePRNGObject*, %struct.BasePRNGObject** %4
%34 = icmp eq %struct.BasePRNGObject* %33, null
br i1 %34, label %39, label %35
35: ; preds = %29
%36 = load %struct.BasePRNGObject*, %struct.BasePRNGObject** %4
%37 = call double @stdlib_base_prng_normalized_min(%struct.BasePRNGObject* %36)
%38 = fcmp une double %37, 0.000000e+00
br i1 %38, label %39, label %41
39: ; preds = %35, %29
%40 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %41
41: ; preds = %39, %35
%42 = load %struct.BasePRNGObject*, %struct.BasePRNGObject** %4
%43 = call i32 @stdlib_base_random_randu_free(%struct.BasePRNGObject* %42)
%44 = load double, double* %1
ret double %44
}

LLVM IR (-O2):
%struct.BasePRNGObject = type { i32 }
@str.1 = [18 x i8] c"unexpected result\00"
define double @benchmark1() {
%1 = tail call double (...) @tic()
br label %2
2: ; preds = %0, %13
%3 = phi i32 [ 0, %0 ], [ %14, %13 ]
%4 = tail call %struct.BasePRNGObject* @stdlib_base_random_randu_allocate(i32 0)
%5 = icmp eq %struct.BasePRNGObject* %4, null
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = tail call double @stdlib_base_prng_normalized_min(%struct.BasePRNGObject* %4)
%8 = fcmp une double %7, 0.000000e+00
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = icmp ult i32 %3, 999999
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 @stdlib_base_random_randu_free(%struct.BasePRNGObject* %4)
br label %13
13: ; preds = %9, %11
%14 = add nuw nsw i32 %3, 1
%15 = icmp eq i32 %14, 1000000
br i1 %15, label %16, label %2
16: ; preds = %13
%17 = tail call double (...) @tic()
br label %22
18: ; preds = %2, %6
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.1, i64 0, i64 0))
%20 = tail call double (...) @tic()
%21 = icmp eq %struct.BasePRNGObject* %4, null
br i1 %21, label %26, label %22
22: ; preds = %16, %18
%23 = phi double [ %17, %16 ], [ %20, %18 ]
%24 = tail call double @stdlib_base_prng_normalized_min(%struct.BasePRNGObject* %4)
%25 = fcmp une double %24, 0.000000e+00
br i1 %25, label %26, label %30
26: ; preds = %22, %18
%27 = phi double [ %23, %22 ], [ %20, %18 ]
%28 = phi %struct.BasePRNGObject* [ %4, %22 ], [ null, %18 ]
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.1, i64 0, i64 0))
br label %30
30: ; preds = %26, %22
%31 = phi double [ %27, %26 ], [ %23, %22 ]
%32 = phi %struct.BasePRNGObject* [ %28, %26 ], [ %4, %22 ]
%33 = fsub double %31, %1
%34 = tail call i32 @stdlib_base_random_randu_free(%struct.BasePRNGObject* %32)
ret double %33
}