#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 */
struct BasePRNGObject *mock_prng_allocate(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdlib_base_prng_free(struct BasePRNGObject *);
double stdlib_base_prng_normalized(struct BasePRNGObject *);
double tic();
double benchmark2() {
  double elapsed;
  double t;
  double v;
  int i;
  struct BasePRNGObject *obj = mock_prng_allocate(1);
  t = tic();
  for (i = 0; i < 1000000; i++) {
    v = stdlib_base_prng_normalized(obj);
    if (v != v) {
      printf("unexpected result\n");
      break;
    }
  }
  elapsed = tic() - t;
  if (v != v) {
    printf("unexpected result\n");
  }
  stdlib_base_prng_free(obj);
  return elapsed;
}


x86 assembly (clang, -O0):
<benchmark2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x1,%edi
call   1050 <mock_prng_allocate@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <tic@plt>
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf4240,-0x1c(%rbp)
jge    11d3 <benchmark2+0x83>
mov    -0x28(%rbp),%rdi
call   1060 <stdlib_base_prng_normalized@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    11af <benchmark2+0x5f>
jp     11af <benchmark2+0x5f>
jmp    11c0 <benchmark2+0x70>
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <benchmark2+0x83>
jmp    11c5 <benchmark2+0x75>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1179 <benchmark2+0x29>
mov    $0x0,%al
call   1040 <tic@plt>
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    11ff <benchmark2+0xaf>
jp     11ff <benchmark2+0xaf>
jmp    120b <benchmark2+0xbb>
lea    0xdfa(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1070 <stdlib_base_prng_free@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark2>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%edi
call   1050 <mock_prng_allocate@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <tic@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xf4240,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <stdlib_base_prng_normalized@plt>
ucomisd %xmm0,%xmm0
jp     11a1 <benchmark2+0x51>
add    $0xffffffff,%ebp
jne    1180 <benchmark2+0x30>
xor    %eax,%eax
call   1040 <tic@plt>
movsd  %xmm0,(%rsp)
jmp    11c4 <benchmark2+0x74>
lea    0xe58(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <tic@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1070 <stdlib_base_prng_free@plt>
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.BasePRNGObject = type { i32 }
@str.1 = [18 x i8] c"unexpected result\00"
define double @benchmark2() {
%1 = tail call %struct.BasePRNGObject* @mock_prng_allocate(i32 1)
%2 = tail call double (...) @tic()
br label %6
3: ; preds = %6
%4 = add nuw nsw i32 %7, 1
%5 = icmp eq i32 %4, 1000000
br i1 %5, label %10, label %6
6: ; preds = %0, %3
%7 = phi i32 [ 0, %0 ], [ %4, %3 ]
%8 = tail call double @stdlib_base_prng_normalized(%struct.BasePRNGObject* %1)
%9 = fcmp uno double %8, 0.000000e+00
br i1 %9, label %12, label %3
10: ; preds = %3
%11 = tail call double (...) @tic()
br label %16
12: ; preds = %6
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.1, i64 0, i64 0))
%14 = tail call double (...) @tic()
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.1, i64 0, i64 0))
br label %16
16: ; preds = %10, %12
%17 = phi double [ %14, %12 ], [ %11, %10 ]
%18 = fsub double %17, %2
%19 = tail call i32 @stdlib_base_prng_free(%struct.BasePRNGObject* %1)
ret double %18
}