#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 sqrt(double);
double solve_quadratic(double a, double b, double c) {
  double delta = sqrt(b * b - 4 * a * c);
  double r = (delta - b) / (2 * a);
  if (r < 0)
    r = (-delta - b) / (2 * a);
  return r;
}


x86 assembly (clang, -O0):
<solve_quadratic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xecf(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe82(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11d1 <solve_quadratic+0xc1>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe3d(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_quadratic>:
sub    $0x18,%rsp
movapd %xmm0,%xmm3
movsd  0xee0(%rip),%xmm4
mulsd  %xmm0,%xmm4
mulsd  %xmm2,%xmm4
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm4,%xmm0
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jb     1144 <solve_quadratic+0x34>
sqrtsd %xmm0,%xmm0
jmp    1165 <solve_quadratic+0x55>
movsd  %xmm3,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <sqrt@plt>
xorpd  %xmm4,%xmm4
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm3
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
addsd  %xmm3,%xmm3
divsd  %xmm3,%xmm2
ucomisd %xmm2,%xmm4
jbe    118f <solve_quadratic+0x7f>
xorpd  0xe8d(%rip),%xmm0
subsd  %xmm1,%xmm0
divsd  %xmm3,%xmm0
movapd %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @solve_quadratic(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %5
%10 = load double, double* %5
%11 = load double, double* %4
%12 = fmul double 4.000000e+00, %11
%13 = load double, double* %6
%14 = fmul double %12, %13
%15 = fneg double %14
%16 = call double @llvm.fmuladd.f64(double %9, double %10, double %15)
%17 = call double @sqrt(double %16)
store double %17, double* %7
%18 = load double, double* %7
%19 = load double, double* %5
%20 = fsub double %18, %19
%21 = load double, double* %4
%22 = fmul double 2.000000e+00, %21
%23 = fdiv double %20, %22
store double %23, double* %8
%24 = load double, double* %8
%25 = fcmp olt double %24, 0.000000e+00
br i1 %25, label %26, label %34
26: ; preds = %3
%27 = load double, double* %7
%28 = fneg double %27
%29 = load double, double* %5
%30 = fsub double %28, %29
%31 = load double, double* %4
%32 = fmul double 2.000000e+00, %31
%33 = fdiv double %30, %32
store double %33, double* %8
br label %34
34: ; preds = %26, %3
%35 = load double, double* %8
ret double %35
}

LLVM IR (-O2):
define double @solve_quadratic(double %0, double %1, double %2) {
%4 = fmul double %0, -4.000000e+00
%5 = fmul double %4, %2
%6 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %5)
%7 = tail call double @sqrt(double %6)
%8 = fsub double %7, %1
%9 = fmul double %0, 2.000000e+00
%10 = fdiv double %8, %9
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = fneg double %7
%14 = fsub double %13, %1
%15 = fdiv double %14, %9
br label %16
16: ; preds = %12, %3
%17 = phi double [ %15, %12 ], [ %10, %3 ]
ret double %17
}