#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 */
typedef double uint32_t;

/* Variables and functions */
double M_PI;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
double get_time();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
double mesure(const char *msg, double tref, double (*function)(double x)) {
  uint32_t t1, t2;
  printf("%-40s: ", msg);
  fflush(stdout);
  t1 = get_time();
  for (double x = -M_PI / 2.0; x < M_PI / 2.0; x += M_PI / 10000000) {
    function(x);
  }
  t2 = get_time();
  const double t = (t2 - t1) / 1000000.0;
  if (tref > 0.0) {
    printf("%0.3f s (%0.2f)\n", t, tref / t);
  } else {
    printf("%0.3f s\n", t);
  }
  return t;
}


x86 assembly (clang, -O0):
<mesure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x0,%al
call   1040 <get_time@plt>
movsd  %xmm0,-0x20(%rbp)
mov    0x2e70(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe65(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
mov    0x2e38(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe44(%rip),%xmm2
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11fb <mesure+0xcb>
mov    -0x18(%rbp),%rax
movsd  -0x30(%rbp),%xmm0
call   *%rax
mov    0x2e0c(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe28(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11a4 <mesure+0x74>
mov    $0x0,%al
call   1040 <get_time@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xdef(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1256 <mesure+0x126>
movsd  -0x38(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
divsd  -0x38(%rbp),%xmm1
lea    0xdd6(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1269 <mesure+0x139>
movsd  -0x38(%rbp),%xmm0
lea    0xdcf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mesure>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rsi
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %eax,%eax
call   1040 <get_time@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x2e75(%rip),%r14
movsd  (%r14),%xmm1
movsd  0xe80(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xe7c(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11d9 <mesure+0xa9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
call   *%rbx
movsd  (%r14),%xmm2
movapd %xmm2,%xmm1
divsd  0xe58(%rip),%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xe35(%rip),%xmm2
ucomisd %xmm0,%xmm2
ja     11a0 <mesure+0x70>
xor    %eax,%eax
call   1040 <get_time@plt>
subsd  0x8(%rsp),%xmm0
divsd  0xe2a(%rip),%xmm0
xorpd  %xmm2,%xmm2
movsd  0x10(%rsp),%xmm1
ucomisd %xmm2,%xmm1
movsd  %xmm0,(%rsp)
jbe    1217 <mesure+0xe7>
divsd  %xmm0,%xmm1
lea    0xe1a(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1225 <mesure+0xf5>
lea    0xe1b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%-40s: \00"
@stdout = global i32 0
@M_PI = global double 0.000000e+00
@.str.1 = [17 x i8] c"%0.3f s (%0.2f)\0A\00"
@.str.2 = [9 x i8] c"%0.3f s\0A\00"
define double @mesure(i8* %0, double %1, double (double)* %2) {
%4 = alloca i8*
%5 = alloca double
%6 = alloca double (double)*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i8* %0, i8** %4
store double %1, double* %5
store double (double)* %2, double (double)** %6
%11 = load i8*, i8** %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @stdout
%14 = call i32 @fflush(i32 %13)
%15 = call double (...) @get_time()
store double %15, double* %7
%16 = load double, double* @M_PI
%17 = fneg double %16
%18 = fdiv double %17, 2.000000e+00
store double %18, double* %9
br label %19
19: ; preds = %28, %3
%20 = load double, double* %9
%21 = load double, double* @M_PI
%22 = fdiv double %21, 2.000000e+00
%23 = fcmp olt double %20, %22
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = load double (double)*, double (double)** %6
%26 = load double, double* %9
%27 = call double %25(double %26)
br label %28
28: ; preds = %24
%29 = load double, double* @M_PI
%30 = fdiv double %29, 1.000000e+07
%31 = load double, double* %9
%32 = fadd double %31, %30
store double %32, double* %9
br label %19
33: ; preds = %19
%34 = call double (...) @get_time()
store double %34, double* %8
%35 = load double, double* %8
%36 = load double, double* %7
%37 = fsub double %35, %36
%38 = fdiv double %37, 1.000000e+06
store double %38, double* %10
%39 = load double, double* %5
%40 = fcmp ogt double %39, 0.000000e+00
br i1 %40, label %41, label %47
41: ; preds = %33
%42 = load double, double* %10
%43 = load double, double* %5
%44 = load double, double* %10
%45 = fdiv double %43, %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), double %42, double %45)
br label %50
47: ; preds = %33
%48 = load double, double* %10
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %48)
br label %50
50: ; preds = %47, %41
%51 = load double, double* %10
ret double %51
}

LLVM IR (-O2):
@.str = [8 x i8] c"%-40s: \00"
@stdout = global i32 0
@M_PI = global double 0.000000e+00
@.str.1 = [17 x i8] c"%0.3f s (%0.2f)\0A\00"
@.str.2 = [9 x i8] c"%0.3f s\0A\00"
define double @mesure(i8* %0, double %1, double (double)* nocapture %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = load i32, i32* @stdout
%6 = tail call i32 @fflush(i32 %5)
%7 = tail call double (...) @get_time()
%8 = load double, double* @M_PI
%9 = fmul double %8, -5.000000e-01
%10 = fmul double %8, 5.000000e-01
%11 = fcmp olt double %9, %10
br i1 %11, label %17, label %12
12: ; preds = %17, %3
%13 = tail call double (...) @get_time()
%14 = fsub double %13, %7
%15 = fdiv double %14, 1.000000e+06
%16 = fcmp ogt double %1, 0.000000e+00
br i1 %16, label %25, label %28
17: ; preds = %3, %17
%18 = phi double [ %22, %17 ], [ %9, %3 ]
%19 = tail call double %2(double %18)
%20 = load double, double* @M_PI
%21 = fdiv double %20, 1.000000e+07
%22 = fadd double %18, %21
%23 = fmul double %20, 5.000000e-01
%24 = fcmp olt double %22, %23
br i1 %24, label %17, label %12
25: ; preds = %12
%26 = fdiv double %1, %15
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), double %15, double %26)
br label %30
28: ; preds = %12
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %15)
br label %30
30: ; preds = %28, %25
ret double %15
}