#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 *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *, float *);
float sqrt(float);
int main(void) {
  float a, b, c;
  float discriminant, first_root, second_root;
  printf("Enter a, b and c of quadratic equation: ");
  scanf("%f %f %f", &a, &b, &c);
  discriminant = (b * b) - (4 * a * c);
  if (discriminant < 0) {
    printf("Roots are complex number.\n");
    printf("Roots of quadratic equation are: ");
    printf("%.3f + %.3fi", -b / (2 * a), sqrt(-discriminant) / (2 * a));
    printf(", %.3f + %.3fi \n", -b / (2 * a), -sqrt(-discriminant) / (2 * a));
  } else if (discriminant == 0) {
    printf("Both roots are equal.\n");
    first_root = -b / (2 * a);
    printf("Root of quadratic equation is: %.3f \n", first_root);
  } else {
    printf("Roots are real numbers.\n");
    first_root = (-b + sqrt(discriminant)) / (2 * a);
    second_root = (-b - sqrt(discriminant)) / (2 * a);
    printf("Roots of quadratic equation are: %.3f , %.3f \n", first_root,
           second_root);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  0xe89(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    12b2 <main+0x182>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xe26(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movss  0xded(%rip),%xmm2
mulss  -0x8(%rbp),%xmm2
divss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe4c(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xdb8(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  0xd72(%rip),%xmm2
mulss  -0x8(%rbp),%xmm2
divss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdde(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    13d4 <main+0x2a4>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    131b <main+0x1eb>
jp     131b <main+0x1eb>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xd13(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd9d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    13cf <main+0x29f>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x38(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  0xca6(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  0xc63(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd23(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    13d4 <main+0x2a4>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef0(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x2c(%rsp),%rcx
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
mulss  0xe85(%rip),%xmm0
movss  0xc(%rsp),%xmm1
mulss  0x2c(%rsp),%xmm0
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jbe    11f7 <main+0xb7>
lea    0xf77(%rip),%rdi
movaps %xmm1,0x10(%rsp)
call   1030 <puts@plt>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0xe46(%rip),%xmm3
movss  0xc(%rsp),%xmm1
xorps  %xmm3,%xmm1
movss  0x8(%rsp),%xmm2
addss  %xmm2,%xmm2
divss  %xmm2,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm1,%xmm2
movaps 0x10(%rsp),%xmm1
movaps %xmm1,%xmm0
xorps  %xmm3,%xmm0
ucomiss %xmm1,%xmm3
movaps %xmm0,0x30(%rsp)
jb     1244 <main+0x104>
sqrtss %xmm0,%xmm0
jmp    1255 <main+0x115>
ucomiss %xmm0,%xmm1
jne    12ec <main+0x1ac>
jp     12ec <main+0x1ac>
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
xorps  0xdf1(%rip),%xmm0
movss  0x8(%rsp),%xmm1
addss  %xmm1,%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    13b5 <main+0x275>
movsd  %xmm2,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm2
movss  0x8(%rsp),%xmm1
addss  %xmm1,%xmm1
divss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
lea    0xe03(%rip),%rdi
movaps %xmm2,%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
xorps  0xd88(%rip),%xmm0
movss  0x8(%rsp),%xmm1
addss  %xmm1,%xmm1
divss  %xmm1,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
xorps  %xmm1,%xmm1
movaps 0x30(%rsp),%xmm0
ucomiss %xmm1,%xmm0
jb     12b0 <main+0x170>
sqrtss %xmm0,%xmm0
jmp    12c1 <main+0x181>
movsd  %xmm2,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm2
xorps  0xd48(%rip),%xmm0
movss  0x8(%rsp),%xmm1
addss  %xmm1,%xmm1
divss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
lea    0xd9d(%rip),%rdi
movaps %xmm2,%xmm0
jmp    13ae <main+0x26e>
lea    0xdf4(%rip),%rdi
movaps %xmm1,0x10(%rsp)
call   1030 <puts@plt>
movaps 0x10(%rsp),%xmm1
movss  0xc(%rsp),%xmm0
sqrtss %xmm1,%xmm3
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm1
movaps %xmm3,%xmm2
jae    1342 <main+0x202>
movss  %xmm0,0x28(%rsp)
movaps %xmm1,%xmm0
movss  %xmm3,0x30(%rsp)
call   1060 <sqrt@plt>
xorps  %xmm4,%xmm4
movss  0x30(%rsp),%xmm3
movaps 0x10(%rsp),%xmm1
movaps %xmm0,%xmm2
movss  0x28(%rsp),%xmm0
subss  %xmm0,%xmm2
movss  0x8(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm2
movss  0xc(%rsp),%xmm5
xorps  0xcaf(%rip),%xmm5
ucomiss %xmm4,%xmm1
jae    1387 <main+0x247>
movaps %xmm1,%xmm0
movss  %xmm2,0x10(%rsp)
movaps %xmm5,0x30(%rsp)
call   1060 <sqrt@plt>
movaps 0x30(%rsp),%xmm5
movss  0x10(%rsp),%xmm2
movaps %xmm0,%xmm3
subss  %xmm3,%xmm5
movss  0x8(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm5
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm5,%xmm1
lea    0xd0a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter a, b and c of quadratic equation: \00"
@.str.1 = [9 x i8] c"%f %f %f\00"
@.str.2 = [27 x i8] c"Roots are complex number.\0A\00"
@.str.3 = [34 x i8] c"Roots of quadratic equation are: \00"
@.str.4 = [13 x i8] c"%.3f + %.3fi\00"
@.str.5 = [17 x i8] c", %.3f + %.3fi \0A\00"
@.str.6 = [23 x i8] c"Both roots are equal.\0A\00"
@.str.7 = [38 x i8] c"Root of quadratic equation is: %.3f \0A\00"
@.str.8 = [25 x i8] c"Roots are real numbers.\0A\00"
@.str.9 = [47 x i8] c"Roots of quadratic equation are: %.3f , %.3f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %4)
%10 = load float, float* %3
%11 = load float, float* %3
%12 = load float, float* %2
%13 = fmul float 4.000000e+00, %12
%14 = load float, float* %4
%15 = fmul float %13, %14
%16 = fneg float %15
%17 = call float @llvm.fmuladd.f32(float %10, float %11, float %16)
store float %17, float* %5
%18 = load float, float* %5
%19 = fcmp olt float %18, 0.000000e+00
br i1 %19, label %20, label %52
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%23 = load float, float* %3
%24 = fneg float %23
%25 = load float, float* %2
%26 = fmul float 2.000000e+00, %25
%27 = fdiv float %24, %26
%28 = fpext float %27 to double
%29 = load float, float* %5
%30 = fneg float %29
%31 = call float @sqrt(float %30)
%32 = load float, float* %2
%33 = fmul float 2.000000e+00, %32
%34 = fdiv float %31, %33
%35 = fpext float %34 to double
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), double %28, double %35)
%37 = load float, float* %3
%38 = fneg float %37
%39 = load float, float* %2
%40 = fmul float 2.000000e+00, %39
%41 = fdiv float %38, %40
%42 = fpext float %41 to double
%43 = load float, float* %5
%44 = fneg float %43
%45 = call float @sqrt(float %44)
%46 = fneg float %45
%47 = load float, float* %2
%48 = fmul float 2.000000e+00, %47
%49 = fdiv float %46, %48
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %42, double %50)
br label %89
52: ; preds = %0
%53 = load float, float* %5
%54 = fcmp oeq float %53, 0.000000e+00
br i1 %54, label %55, label %65
55: ; preds = %52
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%57 = load float, float* %3
%58 = fneg float %57
%59 = load float, float* %2
%60 = fmul float 2.000000e+00, %59
%61 = fdiv float %58, %60
store float %61, float* %6
%62 = load float, float* %6
%63 = fpext float %62 to double
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), double %63)
br label %88
65: ; preds = %52
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%67 = load float, float* %3
%68 = fneg float %67
%69 = load float, float* %5
%70 = call float @sqrt(float %69)
%71 = fadd float %68, %70
%72 = load float, float* %2
%73 = fmul float 2.000000e+00, %72
%74 = fdiv float %71, %73
store float %74, float* %6
%75 = load float, float* %3
%76 = fneg float %75
%77 = load float, float* %5
%78 = call float @sqrt(float %77)
%79 = fsub float %76, %78
%80 = load float, float* %2
%81 = fmul float 2.000000e+00, %80
%82 = fdiv float %79, %81
store float %82, float* %7
%83 = load float, float* %6
%84 = fpext float %83 to double
%85 = load float, float* %7
%86 = fpext float %85 to double
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0), double %84, double %86)
br label %88
88: ; preds = %65, %55
br label %89
89: ; preds = %88, %20
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter a, b and c of quadratic equation: \00"
@.str.1 = [9 x i8] c"%f %f %f\00"
@.str.3 = [34 x i8] c"Roots of quadratic equation are: \00"
@.str.4 = [13 x i8] c"%.3f + %.3fi\00"
@.str.5 = [17 x i8] c", %.3f + %.3fi \0A\00"
@.str.7 = [38 x i8] c"Root of quadratic equation is: %.3f \0A\00"
@.str.9 = [47 x i8] c"Roots of quadratic equation are: %.3f , %.3f \0A\00"
@str = [24 x i8] c"Roots are real numbers.\00"
@str.10 = [22 x i8] c"Both roots are equal.\00"
@str.11 = [26 x i8] c"Roots are complex number.\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2, float* %3)
%9 = load float, float* %2
%10 = load float, float* %1
%11 = load float, float* %3
%12 = fmul float %10, -4.000000e+00
%13 = fmul float %12, %11
%14 = call float @llvm.fmuladd.f32(float %9, float %9, float %13)
%15 = fcmp olt float %14, 0.000000e+00
br i1 %15, label %16, label %45
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%19 = load float, float* %2
%20 = fneg float %19
%21 = load float, float* %1
%22 = fmul float %21, 2.000000e+00
%23 = fdiv float %20, %22
%24 = fpext float %23 to double
%25 = fneg float %14
%26 = call float @sqrt(float %25)
%27 = load float, float* %1
%28 = fmul float %27, 2.000000e+00
%29 = fdiv float %26, %28
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), double %24, double %30)
%32 = load float, float* %2
%33 = fneg float %32
%34 = load float, float* %1
%35 = fmul float %34, 2.000000e+00
%36 = fdiv float %33, %35
%37 = fpext float %36 to double
%38 = call float @sqrt(float %25)
%39 = fneg float %38
%40 = load float, float* %1
%41 = fmul float %40, 2.000000e+00
%42 = fdiv float %39, %41
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), double %37, double %43)
br label %74
45: ; preds = %0
%46 = fcmp oeq float %14, 0.000000e+00
br i1 %46, label %47, label %56
47: ; preds = %45
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0))
%49 = load float, float* %2
%50 = fneg float %49
%51 = load float, float* %1
%52 = fmul float %51, 2.000000e+00
%53 = fdiv float %50, %52
%54 = fpext float %53 to double
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), double %54)
br label %74
56: ; preds = %45
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%58 = load float, float* %2
%59 = call float @sqrt(float %14)
%60 = fsub float %59, %58
%61 = load float, float* %1
%62 = fmul float %61, 2.000000e+00
%63 = fdiv float %60, %62
%64 = load float, float* %2
%65 = fneg float %64
%66 = call float @sqrt(float %14)
%67 = fsub float %65, %66
%68 = load float, float* %1
%69 = fmul float %68, 2.000000e+00
%70 = fdiv float %67, %69
%71 = fpext float %63 to double
%72 = fpext float %70 to double
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0), double %71, double %72)
br label %74
74: ; preds = %47, %56, %16
ret i32 0
}