#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 fabs(float);
void peak(float *y, float *xp, float *yp) {
  register float a, c;
  a = (y[2] - y[1]) + (.5 * (y[0] - y[2]));
  if (fabs(a) > .000001) {
    *xp = c = (y[0] - y[2]) / (4.0 * a);
    *yp = y[1] - (a * c * c);
  } else {
    *xp = 0.0;
    *yp = y[1];
  }
}


x86 assembly (clang, -O0):
<peak>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x4(%rax),%xmm0
cvtss2sd %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x8(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb1(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  0xe86(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11fd <peak+0xed>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x8(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe66(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
movss  -0x1c(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  -0x20(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1219 <peak+0x109>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<peak>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  (%rdi),%xmm0
movss  0x8(%rdi),%xmm1
movaps %xmm1,%xmm2
subss  0x4(%rdi),%xmm2
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xebd(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
call   1030 <fabs@plt>
ucomisd 0xea3(%rip),%xmm0
jbe    11ac <peak+0x9c>
movss  (%rbx),%xmm0
subss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0xc(%rsp),%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
mulsd  0xe87(%rip),%xmm1
divsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
movss  %xmm1,(%r15)
movss  0x4(%rbx),%xmm0
mulss  %xmm1,%xmm2
mulss  %xmm1,%xmm2
subss  %xmm2,%xmm0
jmp    11b8 <peak+0xa8>
movl   $0x0,(%r15)
movss  0x4(%rbx),%xmm0
movss  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @peak(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca float
%8 = alloca float
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%9 = load float*, float** %4
%10 = getelementptr inbounds float, float* %9, i64 2
%11 = load float, float* %10
%12 = load float*, float** %4
%13 = getelementptr inbounds float, float* %12, i64 1
%14 = load float, float* %13
%15 = fsub float %11, %14
%16 = fpext float %15 to double
%17 = load float*, float** %4
%18 = getelementptr inbounds float, float* %17, i64 0
%19 = load float, float* %18
%20 = load float*, float** %4
%21 = getelementptr inbounds float, float* %20, i64 2
%22 = load float, float* %21
%23 = fsub float %19, %22
%24 = fpext float %23 to double
%25 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %24, double %16)
%26 = fptrunc double %25 to float
store float %26, float* %7
%27 = load float, float* %7
%28 = call double @fabs(float %27)
%29 = fcmp ogt double %28, 0x3EB0C6F7A0B5ED8D
br i1 %29, label %30, label %55
30: ; preds = %3
%31 = load float*, float** %4
%32 = getelementptr inbounds float, float* %31, i64 0
%33 = load float, float* %32
%34 = load float*, float** %4
%35 = getelementptr inbounds float, float* %34, i64 2
%36 = load float, float* %35
%37 = fsub float %33, %36
%38 = fpext float %37 to double
%39 = load float, float* %7
%40 = fpext float %39 to double
%41 = fmul double 4.000000e+00, %40
%42 = fdiv double %38, %41
%43 = fptrunc double %42 to float
store float %43, float* %8
%44 = load float*, float** %5
store float %43, float* %44
%45 = load float*, float** %4
%46 = getelementptr inbounds float, float* %45, i64 1
%47 = load float, float* %46
%48 = load float, float* %7
%49 = load float, float* %8
%50 = fmul float %48, %49
%51 = load float, float* %8
%52 = fneg float %50
%53 = call float @llvm.fmuladd.f32(float %52, float %51, float %47)
%54 = load float*, float** %6
store float %53, float* %54
br label %61
55: ; preds = %3
%56 = load float*, float** %5
store float 0.000000e+00, float* %56
%57 = load float*, float** %4
%58 = getelementptr inbounds float, float* %57, i64 1
%59 = load float, float* %58
%60 = load float*, float** %6
store float %59, float* %60
br label %61
61: ; preds = %55, %30
ret void
}

LLVM IR (-O2):
define void @peak(float* nocapture %0, float* nocapture writeonly %1, float* nocapture writeonly %2) {
%4 = getelementptr inbounds float, float* %0, i64 2
%5 = load float, float* %4
%6 = getelementptr inbounds float, float* %0, i64 1
%7 = load float, float* %6
%8 = fsub float %5, %7
%9 = fpext float %8 to double
%10 = load float, float* %0
%11 = fsub float %10, %5
%12 = fpext float %11 to double
%13 = tail call double @llvm.fmuladd.f64(double %12, double 5.000000e-01, double %9)
%14 = fptrunc double %13 to float
%15 = tail call double @fabs(float %14)
%16 = fcmp ogt double %15, 0x3EB0C6F7A0B5ED8D
br i1 %16, label %17, label %30
17: ; preds = %3
%18 = load float, float* %0
%19 = load float, float* %4
%20 = fsub float %18, %19
%21 = fpext float %20 to double
%22 = fpext float %14 to double
%23 = fmul double %22, 4.000000e+00
%24 = fdiv double %21, %23
%25 = fptrunc double %24 to float
store float %25, float* %1
%26 = load float, float* %6
%27 = fneg float %14
%28 = fmul float %27, %25
%29 = tail call float @llvm.fmuladd.f32(float %28, float %25, float %26)
br label %32
30: ; preds = %3
store float 0.000000e+00, float* %1
%31 = load float, float* %6
br label %32
32: ; preds = %30, %17
%33 = phi float [ %31, %30 ], [ %29, %17 ]
store float %33, float* %2
ret void
}