#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*/ exit(int /*<<< orphan*/);
float fabs(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *, float *);
int sqrt(float);
int main(int argc, char **argv) {
  float fA, fB, fC, fDesc, fX1, fX2, fRealp, fImagp;
  printf("\n*************************************************************");
  printf("\n*\tPROGRAM TO FIND ROOTS OF A QUADRATIC EQUATION\t *\n");
  printf("*************************************************************");
  printf("\nEnter the coefficients of a,b,c \n");
  scanf("%f%f%f", &fA, &fB, &fC);
  if (0 == fA) {
    printf("\nInvalid input not a quadratic equation-try again\n");
    exit(0);
  }
  fDesc = fB * fB - 4 * fA * fC;
  if (0 == fDesc) {
    fX1 = fX2 = -fB / (2 * fA);
    printf("\nRoots are equal and the Roots are \n");
    printf("\nRoot1 = %f and Root2 = %f\n", fX1, fX2);
  } else if (fDesc > 0) {
    fX1 = (-fB + sqrt(fDesc)) / (2 * fA);
    fX2 = (-fB - sqrt(fDesc)) / (2 * fA);
    printf("\nThe Roots are Real and distinct, they are \n");
    printf("\nRoot1 = %f and Root2 = %f\n", fX1, fX2);
  } else {
    fRealp = -fB / (2 * fA);
    fImagp = sqrt(fabs(fDesc)) / (2 * fA);
    printf("\nThe Roots are imaginary and they are\n");
    printf("\nRoot1 = %f+i%f\n", fRealp, fImagp);
    printf("\nRoot2 = %f-i%f\n", fRealp, fImagp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
jne    11de <main+0x8e>
jp     11de <main+0x8e>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movss  0xe10(%rip),%xmm1
mulss  -0x14(%rbp),%xmm1
mulss  -0x1c(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x20(%rbp),%xmm0
jne    1287 <main+0x137>
jp     1287 <main+0x137>
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xdc3(%rip),%xmm1
mulss  -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  %xmm0,-0x24(%rbp)
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe83(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    13f7 <main+0x2a7>
movss  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1353 <main+0x203>
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x20(%rbp),%xmm0
call   1060 <sqrt@plt>
movss  -0x38(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
movss  0xd36(%rip),%xmm1
mulss  -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x20(%rbp),%xmm0
call   1060 <sqrt@plt>
movss  -0x34(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
subss  %xmm1,%xmm0
movss  0xcf2(%rip),%xmm1
mulss  -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdb7(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    13f2 <main+0x2a2>
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xc97(%rip),%xmm1
mulss  -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x20(%rbp),%xmm0
call   1040 <fabs@plt>
call   1060 <sqrt@plt>
cvtsi2ss %eax,%xmm0
movss  0xc6e(%rip),%xmm1
mulss  -0x14(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x30(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xda3(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x30(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd94(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    13f7 <main+0x2a7>
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    0xf4b(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf65(%rip),%rdi
call   1030 <puts@plt>
lea    0xee0(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x28(%rsp),%rdx
lea    0x2c(%rsp),%rcx
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm4
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm4
jne    11b7 <main+0x67>
jnp    1354 <main+0x204>
movss  0x28(%rsp),%xmm3
movss  0xe3b(%rip),%xmm2
mulss  %xmm4,%xmm2
mulss  0x2c(%rsp),%xmm2
movaps %xmm3,%xmm0
mulss  %xmm3,%xmm0
addss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
jne    1219 <main+0xc9>
jp     1219 <main+0xc9>
xorps  0xe28(%rip),%xmm3
addss  %xmm4,%xmm4
divss  %xmm4,%xmm3
movaps %xmm3,0x10(%rsp)
lea    0xf60(%rip),%rdi
call   1030 <puts@plt>
movaps 0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe65(%rip),%rdi
movaps %xmm0,%xmm1
jmp    1346 <main+0x1f6>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    12bf <main+0x16f>
movaps %xmm3,0x10(%rsp)
movaps %xmm0,0x30(%rsp)
call   1060 <sqrt@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
subss  0x10(%rsp),%xmm1
movss  0xc(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0x20(%rsp)
movss  0x28(%rsp),%xmm0
xorps  0xdae(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x30(%rsp),%xmm0
call   1060 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movaps 0x10(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movaps 0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdbc(%rip),%rdi
jmp    1346 <main+0x1f6>
xorps  0xd4a(%rip),%xmm3
addss  %xmm4,%xmm4
divss  %xmm4,%xmm3
movaps %xmm3,0x10(%rsp)
andps  0xd46(%rip),%xmm0
call   1060 <sqrt@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
movss  0xc(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0x20(%rsp)
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
movaps 0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0x20(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  %xmm1,0x20(%rsp)
lea    0xd66(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xd69(%rip),%rdi
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret
lea    0xe25(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [63 x i8] c"\0A*************************************************************\00"
@.str.1 = [53 x i8] c"\0A*\09PROGRAM TO FIND ROOTS OF A QUADRATIC EQUATION\09 *\0A\00"
@.str.2 = [62 x i8] c"*************************************************************\00"
@.str.3 = [35 x i8] c"\0AEnter the coefficients of a,b,c \0A\00"
@.str.4 = [7 x i8] c"%f%f%f\00"
@.str.5 = [51 x i8] c"\0AInvalid input not a quadratic equation-try again\0A\00"
@.str.6 = [37 x i8] c"\0ARoots are equal and the Roots are \0A\00"
@.str.7 = [28 x i8] c"\0ARoot1 = %f and Root2 = %f\0A\00"
@.str.8 = [45 x i8] c"\0AThe Roots are Real and distinct, they are \0A\00"
@.str.9 = [39 x i8] c"\0AThe Roots are imaginary and they are\0A\00"
@.str.10 = [17 x i8] c"\0ARoot1 = %f+i%f\0A\00"
@.str.11 = [17 x i8] c"\0ARoot2 = %f-i%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), float* %6, float* %7, float* %8)
%19 = load float, float* %6
%20 = fcmp oeq float 0.000000e+00, %19
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %2
%25 = load float, float* %7
%26 = load float, float* %7
%27 = load float, float* %6
%28 = fmul float 4.000000e+00, %27
%29 = load float, float* %8
%30 = fmul float %28, %29
%31 = fneg float %30
%32 = call float @llvm.fmuladd.f32(float %25, float %26, float %31)
store float %32, float* %9
%33 = load float, float* %9
%34 = fcmp oeq float 0.000000e+00, %33
br i1 %34, label %35, label %47
35: ; preds = %24
%36 = load float, float* %7
%37 = fneg float %36
%38 = load float, float* %6
%39 = fmul float 2.000000e+00, %38
%40 = fdiv float %37, %39
store float %40, float* %11
store float %40, float* %10
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%42 = load float, float* %10
%43 = fpext float %42 to double
%44 = load float, float* %11
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %43, double %45)
br label %100
47: ; preds = %24
%48 = load float, float* %9
%49 = fcmp ogt float %48, 0.000000e+00
br i1 %49, label %50, label %75
50: ; preds = %47
%51 = load float, float* %7
%52 = fneg float %51
%53 = load float, float* %9
%54 = call i32 @sqrt(float %53)
%55 = sitofp i32 %54 to float
%56 = fadd float %52, %55
%57 = load float, float* %6
%58 = fmul float 2.000000e+00, %57
%59 = fdiv float %56, %58
store float %59, float* %10
%60 = load float, float* %7
%61 = fneg float %60
%62 = load float, float* %9
%63 = call i32 @sqrt(float %62)
%64 = sitofp i32 %63 to float
%65 = fsub float %61, %64
%66 = load float, float* %6
%67 = fmul float 2.000000e+00, %66
%68 = fdiv float %65, %67
store float %68, float* %11
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%70 = load float, float* %10
%71 = fpext float %70 to double
%72 = load float, float* %11
%73 = fpext float %72 to double
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %71, double %73)
br label %99
75: ; preds = %47
%76 = load float, float* %7
%77 = fneg float %76
%78 = load float, float* %6
%79 = fmul float 2.000000e+00, %78
%80 = fdiv float %77, %79
store float %80, float* %12
%81 = load float, float* %9
%82 = call float @fabs(float %81)
%83 = call i32 @sqrt(float %82)
%84 = sitofp i32 %83 to float
%85 = load float, float* %6
%86 = fmul float 2.000000e+00, %85
%87 = fdiv float %84, %86
store float %87, float* %13
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
%89 = load float, float* %12
%90 = fpext float %89 to double
%91 = load float, float* %13
%92 = fpext float %91 to double
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), double %90, double %92)
%94 = load float, float* %12
%95 = fpext float %94 to double
%96 = load float, float* %13
%97 = fpext float %96 to double
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), double %95, double %97)
br label %99
99: ; preds = %75, %50
br label %100
100: ; preds = %99, %35
ret i32 0
}

LLVM IR (-O2):
@.str = [63 x i8] c"\0A*************************************************************\00"
@.str.2 = [62 x i8] c"*************************************************************\00"
@.str.4 = [7 x i8] c"%f%f%f\00"
@.str.7 = [28 x i8] c"\0ARoot1 = %f and Root2 = %f\0A\00"
@.str.10 = [17 x i8] c"\0ARoot1 = %f+i%f\0A\00"
@.str.11 = [17 x i8] c"\0ARoot2 = %f-i%f\0A\00"
@str = [52 x i8] c"\0A*\09PROGRAM TO FIND ROOTS OF A QUADRATIC EQUATION\09 *\00"
@str.12 = [34 x i8] c"\0AEnter the coefficients of a,b,c \00"
@str.13 = [38 x i8] c"\0AThe Roots are imaginary and they are\00"
@str.14 = [44 x i8] c"\0AThe Roots are Real and distinct, they are \00"
@str.15 = [36 x i8] c"\0ARoots are equal and the Roots are \00"
@str.16 = [50 x i8] c"\0AInvalid input not a quadratic equation-try again\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = bitcast float* %3 to i8*
%7 = bitcast float* %4 to i8*
%8 = bitcast float* %5 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.12, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), float* %3, float* %4, float* %5)
%14 = load float, float* %3
%15 = fcmp oeq float %14, 0.000000e+00
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.16, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %2
%20 = load float, float* %4
%21 = load float, float* %5
%22 = fmul float %14, -4.000000e+00
%23 = fmul float %22, %21
%24 = call float @llvm.fmuladd.f32(float %20, float %20, float %23)
%25 = fcmp oeq float %24, 0.000000e+00
br i1 %25, label %26, label %33
26: ; preds = %19
%27 = fneg float %20
%28 = fmul float %14, 2.000000e+00
%29 = fdiv float %27, %28
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.15, i64 0, i64 0))
%31 = fpext float %29 to double
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %31, double %31)
br label %69
33: ; preds = %19
%34 = fcmp ogt float %24, 0.000000e+00
br i1 %34, label %35, label %54
35: ; preds = %33
%36 = call i32 @sqrt(float %24)
%37 = sitofp i32 %36 to float
%38 = fsub float %37, %20
%39 = load float, float* %3
%40 = fmul float %39, 2.000000e+00
%41 = fdiv float %38, %40
%42 = load float, float* %4
%43 = fneg float %42
%44 = call i32 @sqrt(float %24)
%45 = sitofp i32 %44 to float
%46 = fsub float %43, %45
%47 = load float, float* %3
%48 = fmul float %47, 2.000000e+00
%49 = fdiv float %46, %48
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.14, i64 0, i64 0))
%51 = fpext float %41 to double
%52 = fpext float %49 to double
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %51, double %52)
br label %69
54: ; preds = %33
%55 = fneg float %20
%56 = fmul float %14, 2.000000e+00
%57 = fdiv float %55, %56
%58 = call float @llvm.fabs.f32(float %24)
%59 = call i32 @sqrt(float %58)
%60 = sitofp i32 %59 to float
%61 = load float, float* %3
%62 = fmul float %61, 2.000000e+00
%63 = fdiv float %60, %62
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.13, i64 0, i64 0))
%65 = fpext float %57 to double
%66 = fpext float %63 to double
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), double %65, double %66)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), double %65, double %66)
br label %69
69: ; preds = %35, %54, %26
ret i32 0
}