#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 calculate_discriminant(double, double, double);
double calculate_first_root(double, double, double);
double calculate_second_root(double, double, double);
int /*<<< orphan*/ printf(char *, ...);
void solveQuadraticEquation(double a, double b, double c) {
  double discriminant, root1, root2;
  discriminant = calculate_discriminant(a, b, c);
  if (discriminant < 0) {
    printf("No roots\n");
  } else if (discriminant == 0) {
    root1 = calculate_first_root(a, b, 0);
    printf("One root: %f\n", root1);
  } else {
    root1 = calculate_first_root(a, b, discriminant);
    root2 = calculate_second_root(a, b, discriminant);
    printf("Two roots: %f and %f\n", root1, root2);
  }
}


x86 assembly (clang, -O0):
<solveQuadraticEquation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1050 <calculate_discriminant@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1191 <solveQuadraticEquation+0x51>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1227 <solveQuadraticEquation+0xe7>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d8 <solveQuadraticEquation+0x98>
jp     11d8 <solveQuadraticEquation+0x98>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
xorps  %xmm2,%xmm2
call   1030 <calculate_first_root@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe3e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1222 <solveQuadraticEquation+0xe2>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1030 <calculate_first_root@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1060 <calculate_second_root@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xdfd(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    1227 <solveQuadraticEquation+0xe7>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solveQuadraticEquation>:
sub    $0x28,%rsp
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
call   1060 <calculate_discriminant@plt>
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jbe    1183 <solveQuadraticEquation+0x33>
lea    0xeaa(%rip),%rdi
add    $0x28,%rsp
jmp    1040 <puts@plt>
ucomisd %xmm0,%xmm2
jne    11b2 <solveQuadraticEquation+0x62>
jp     11b2 <solveQuadraticEquation+0x62>
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <calculate_first_root@plt>
lea    0xe59(%rip),%rdi
mov    $0x1,%al
add    $0x28,%rsp
jmp    1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  %xmm2,0x18(%rsp)
call   1030 <calculate_first_root@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1070 <calculate_second_root@plt>
movaps %xmm0,%xmm1
lea    0xe1e(%rip),%rdi
movsd  0x20(%rsp),%xmm0
mov    $0x2,%al
add    $0x28,%rsp
jmp    1050 <printf@plt>

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

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