#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 */
int /*<<< orphan*/ printf(char *, ...);
double solveRootOne(double, double);
double solveRootTwoNeg(double, double, double);
double solveRootTwoPos(double, double, double);
void solveQuadratic(double a, double b, double c, double discriminant) {
  if (discriminant < 0) {
    printf("No roots found\n");
  } else if (discriminant == 0) {
    printf("One root found: %.2f\n", solveRootOne(a, b));
  } else {
    printf("Two roots found: %.2f and %.2f\n", solveRootTwoPos(a, b, c),
           solveRootTwoNeg(a, b, c));
  }
}


x86 assembly (clang, -O0):
<solveQuadratic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    117d <solveQuadratic+0x3d>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ff <solveQuadratic+0xbf>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b7 <solveQuadratic+0x77>
jp     11b7 <solveQuadratic+0x77>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1050 <solveRootOne@plt>
lea    0xe65(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11fa <solveQuadratic+0xba>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1060 <solveRootTwoPos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <solveRootTwoNeg@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
lea    0xe33(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    11ff <solveQuadratic+0xbf>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solveQuadratic>:
sub    $0x28,%rsp
xorpd  %xmm4,%xmm4
ucomisd %xmm3,%xmm4
jbe    116e <solveQuadratic+0x1e>
lea    0xed1(%rip),%rdi
add    $0x28,%rsp
jmp    1030 <puts@plt>
ucomisd %xmm4,%xmm3
jne    118d <solveQuadratic+0x3d>
jp     118d <solveQuadratic+0x3d>
call   1060 <solveRootOne@plt>
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
add    $0x28,%rsp
jmp    1050 <printf@plt>
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1070 <solveRootTwoPos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1040 <solveRootTwoNeg@plt>
movaps %xmm0,%xmm1
lea    0xe4b(%rip),%rdi
movsd  0x20(%rsp),%xmm0
mov    $0x2,%al
add    $0x28,%rsp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"No roots found\0A\00"
@.str.1 = [22 x i8] c"One root found: %.2f\0A\00"
@.str.2 = [32 x i8] c"Two roots found: %.2f and %.2f\0A\00"
define void @solveQuadratic(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %8
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %32
13: ; preds = %4
%14 = load double, double* %8
%15 = fcmp oeq double %14, 0.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load double, double* %5
%18 = load double, double* %6
%19 = call double @solveRootOne(double %17, double %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %19)
br label %31
21: ; preds = %13
%22 = load double, double* %5
%23 = load double, double* %6
%24 = load double, double* %7
%25 = call double @solveRootTwoPos(double %22, double %23, double %24)
%26 = load double, double* %5
%27 = load double, double* %6
%28 = load double, double* %7
%29 = call double @solveRootTwoNeg(double %26, double %27, double %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %25, double %29)
br label %31
31: ; preds = %21, %16
br label %32
32: ; preds = %31, %11
ret void
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"One root found: %.2f\0A\00"
@.str.2 = [32 x i8] c"Two roots found: %.2f and %.2f\0A\00"
@str = [15 x i8] c"No roots found\00"
define void @solveQuadratic(double %0, double %1, double %2, double %3) {
%5 = fcmp olt double %3, 0.000000e+00
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %17
8: ; preds = %4
%9 = fcmp oeq double %3, 0.000000e+00
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = tail call double @solveRootOne(double %0, double %1)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %11)
br label %17
13: ; preds = %8
%14 = tail call double @solveRootTwoPos(double %0, double %1, double %2)
%15 = tail call double @solveRootTwoNeg(double %0, double %1, double %2)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %14, double %15)
br label %17
17: ; preds = %10, %13, %6
ret void
}