#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 omp_get_wtime();
int /*<<< orphan*/ printf(char *, ...);
void time_centroid(const char *name, void (*mean)(double *, double *, int),
                   double *xy, int N) {
  int i;
  int trials = 100;
  double tstart, tstop;
  double xymean[2] = {0, 0};
  double per_trial;
  double gflops;
  tstart = omp_get_wtime();
  for (i = 0; i < trials; ++i)
    mean(xymean, xy, N);
  tstop = omp_get_wtime();
  per_trial = (tstop - tstart) / trials;
  gflops = (2 * N) / per_trial / 1e9;
  printf("Result: %g %g\n", xymean[0], xymean[1]);
  printf("Version %s: %e (%g GFLop/s)\n", name, per_trial, gflops);
}


x86 assembly (clang, -O0):
<time_centroid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x64,-0x24(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    119c <time_centroid+0x6c>
mov    -0x10(%rbp),%rax
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   *%rax
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1171 <time_centroid+0x41>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  0xe29(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
lea    0xe17(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
lea    0xe0a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_centroid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r15d
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%r14
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x64,%ebx
lea    0x10(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   *%rbp
add    $0xffffffff,%ebx
jne    1160 <time_centroid+0x40>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
subsd  0x8(%rsp),%xmm0
divsd  0xe7b(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    %r15d,%r15d
cvtsi2sd %r15d,%xmm1
divsd  %xmm0,%xmm1
divsd  0xe69(%rip),%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
lea    0xe58(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
mov    %r14,%rsi
movsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Result: %g %g\0A\00"
@.str.1 = [29 x i8] c"Version %s: %e (%g GFLop/s)\0A\00"
define void @time_centroid(i8* %0, void (double*, double*, i32)* %1, double* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca void (double*, double*, i32)*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca [2 x double]
%14 = alloca double
%15 = alloca double
store i8* %0, i8** %5
store void (double*, double*, i32)* %1, void (double*, double*, i32)** %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 100, i32* %10
%16 = bitcast [2 x double]* %13 to i8*
%17 = call double (...) @omp_get_wtime()
store double %17, double* %11
store i32 0, i32* %9
br label %18
18: ; preds = %27, %4
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = load void (double*, double*, i32)*, void (double*, double*, i32)** %6
%24 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 0
%25 = load double*, double** %7
%26 = load i32, i32* %8
br label %27
27: ; preds = %22
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
br label %18
30: ; preds = %18
%31 = call double (...) @omp_get_wtime()
store double %31, double* %12
%32 = load double, double* %12
%33 = load double, double* %11
%34 = fsub double %32, %33
%35 = load i32, i32* %10
%36 = sitofp i32 %35 to double
%37 = fdiv double %34, %36
store double %37, double* %14
%38 = load i32, i32* %8
%39 = mul nsw i32 2, %38
%40 = sitofp i32 %39 to double
%41 = load double, double* %14
%42 = fdiv double %40, %41
%43 = fdiv double %42, 1.000000e+09
store double %43, double* %15
%44 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 0
%45 = load double, double* %44
%46 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 1
%47 = load double, double* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %45, double %47)
%49 = load i8*, i8** %5
%50 = load double, double* %14
%51 = load double, double* %15
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %49, double %50, double %51)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Result: %g %g\0A\00"
@.str.1 = [29 x i8] c"Version %s: %e (%g GFLop/s)\0A\00"
define void @time_centroid(i8* %0, void (double*, double*, i32)* nocapture %1, double* %2, i32 %3) {
%5 = alloca [2 x double]
%6 = bitcast [2 x double]* %5 to i8*
%7 = tail call double (...) @omp_get_wtime()
%8 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
br label %9
9: ; preds = %4, %9
%10 = phi i32 [ 0, %4 ], [ %11, %9 ]
%11 = add nuw nsw i32 %10, 1
%12 = icmp eq i32 %11, 100
br i1 %12, label %13, label %9
13: ; preds = %9
%14 = call double (...) @omp_get_wtime()
%15 = fsub double %14, %7
%16 = fdiv double %15, 1.000000e+02
%17 = shl nsw i32 %3, 1
%18 = sitofp i32 %17 to double
%19 = fdiv double %18, %16
%20 = fdiv double %19, 1.000000e+09
%21 = load double, double* %8
%22 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
%23 = load double, double* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %21, double %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %0, double %16, double %20)
ret void
}