#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(void) {
  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 = %g and Root2 = %g\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 = %g and Root2 = %g\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 = %g+i%g\n", fRealp, fImagp);
    printf("\nRoot2 = %g-i%g\n", fRealp, fImagp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jne    11d7 <main+0x87>
jp     11d7 <main+0x87>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  0xe17(%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
jne    1280 <main+0x130>
jp     1280 <main+0x130>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xdca(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  %xmm0,-0x18(%rbp)
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe90(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    13f0 <main+0x2a0>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    134c <main+0x1fc>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x14(%rbp),%xmm0
call   1060 <sqrt@plt>
movss  -0x2c(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
movss  0xd3d(%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,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
call   1060 <sqrt@plt>
movss  -0x28(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
subss  %xmm1,%xmm0
movss  0xcf9(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdc4(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    13eb <main+0x29b>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xc9e(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <fabs@plt>
call   1060 <sqrt@plt>
cvtsi2ss %eax,%xmm0
movss  0xc75(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdb0(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xda1(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    13f0 <main+0x2a0>
xor    %eax,%eax
add    $0x30,%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    0xf68(%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    0xf63(%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    0xe98(%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    0xe0c(%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    0xe28(%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 = [56 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 = [54 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 = %g and Root2 = %g\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 = %g+i%g\0A\00"
@.str.11 = [17 x i8] c"\0ARoot2 = %g-i%g\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
%8 = alloca float
%9 = alloca float
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), float* %2, float* %3, float* %4)
%15 = load float, float* %2
%16 = fcmp oeq float 0.000000e+00, %15
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %0
%21 = load float, float* %3
%22 = load float, float* %3
%23 = load float, float* %2
%24 = fmul float 4.000000e+00, %23
%25 = load float, float* %4
%26 = fmul float %24, %25
%27 = fneg float %26
%28 = call float @llvm.fmuladd.f32(float %21, float %22, float %27)
store float %28, float* %5
%29 = load float, float* %5
%30 = fcmp oeq float 0.000000e+00, %29
br i1 %30, label %31, label %43
31: ; preds = %20
%32 = load float, float* %3
%33 = fneg float %32
%34 = load float, float* %2
%35 = fmul float 2.000000e+00, %34
%36 = fdiv float %33, %35
store float %36, float* %7
store float %36, float* %6
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%38 = load float, float* %6
%39 = fpext float %38 to double
%40 = load float, float* %7
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %39, double %41)
br label %96
43: ; preds = %20
%44 = load float, float* %5
%45 = fcmp ogt float %44, 0.000000e+00
br i1 %45, label %46, label %71
46: ; preds = %43
%47 = load float, float* %3
%48 = fneg float %47
%49 = load float, float* %5
%50 = call i32 @sqrt(float %49)
%51 = sitofp i32 %50 to float
%52 = fadd float %48, %51
%53 = load float, float* %2
%54 = fmul float 2.000000e+00, %53
%55 = fdiv float %52, %54
store float %55, float* %6
%56 = load float, float* %3
%57 = fneg float %56
%58 = load float, float* %5
%59 = call i32 @sqrt(float %58)
%60 = sitofp i32 %59 to float
%61 = fsub float %57, %60
%62 = load float, float* %2
%63 = fmul float 2.000000e+00, %62
%64 = fdiv float %61, %63
store float %64, float* %7
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%66 = load float, float* %6
%67 = fpext float %66 to double
%68 = load float, float* %7
%69 = fpext float %68 to double
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %67, double %69)
br label %95
71: ; preds = %43
%72 = load float, float* %3
%73 = fneg float %72
%74 = load float, float* %2
%75 = fmul float 2.000000e+00, %74
%76 = fdiv float %73, %75
store float %76, float* %8
%77 = load float, float* %5
%78 = call float @fabs(float %77)
%79 = call i32 @sqrt(float %78)
%80 = sitofp i32 %79 to float
%81 = load float, float* %2
%82 = fmul float 2.000000e+00, %81
%83 = fdiv float %80, %82
store float %83, float* %9
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
%85 = load float, float* %8
%86 = fpext float %85 to double
%87 = load float, float* %9
%88 = fpext float %87 to double
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), double %86, double %88)
%90 = load float, float* %8
%91 = fpext float %90 to double
%92 = load float, float* %9
%93 = fpext float %92 to double
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), double %91, double %93)
br label %95
95: ; preds = %71, %46
br label %96
96: ; preds = %95, %31
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 = %g and Root2 = %g\0A\00"
@.str.10 = [17 x i8] c"\0ARoot1 = %g+i%g\0A\00"
@.str.11 = [17 x i8] c"\0ARoot2 = %g-i%g\0A\00"
@str = [55 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 = [53 x i8] c"\0AInvalid input, not a quadratic equation - try again\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 ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.12, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), float* %1, float* %2, float* %3)
%12 = load float, float* %1
%13 = fcmp oeq float %12, 0.000000e+00
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %0
%18 = load float, float* %2
%19 = load float, float* %3
%20 = fmul float %12, -4.000000e+00
%21 = fmul float %20, %19
%22 = call float @llvm.fmuladd.f32(float %18, float %18, float %21)
%23 = fcmp oeq float %22, 0.000000e+00
br i1 %23, label %24, label %31
24: ; preds = %17
%25 = fneg float %18
%26 = fmul float %12, 2.000000e+00
%27 = fdiv float %25, %26
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.15, i64 0, i64 0))
%29 = fpext float %27 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %29, double %29)
br label %67
31: ; preds = %17
%32 = fcmp ogt float %22, 0.000000e+00
br i1 %32, label %33, label %52
33: ; preds = %31
%34 = call i32 @sqrt(float %22)
%35 = sitofp i32 %34 to float
%36 = fsub float %35, %18
%37 = load float, float* %1
%38 = fmul float %37, 2.000000e+00
%39 = fdiv float %36, %38
%40 = load float, float* %2
%41 = fneg float %40
%42 = call i32 @sqrt(float %22)
%43 = sitofp i32 %42 to float
%44 = fsub float %41, %43
%45 = load float, float* %1
%46 = fmul float %45, 2.000000e+00
%47 = fdiv float %44, %46
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.14, i64 0, i64 0))
%49 = fpext float %39 to double
%50 = fpext float %47 to double
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %49, double %50)
br label %67
52: ; preds = %31
%53 = fneg float %18
%54 = fmul float %12, 2.000000e+00
%55 = fdiv float %53, %54
%56 = call float @llvm.fabs.f32(float %22)
%57 = call i32 @sqrt(float %56)
%58 = sitofp i32 %57 to float
%59 = load float, float* %1
%60 = fmul float %59, 2.000000e+00
%61 = fdiv float %58, %60
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.13, i64 0, i64 0))
%63 = fpext float %55 to double
%64 = fpext float %61 to double
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), double %63, double %64)
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), double %63, double %64)
br label %67
67: ; preds = %33, %52, %24
ret i32 0
}