#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*/ fabs(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
float sqrt(int /*<<< orphan*/);
int main() {
  int a, b, c;
  float d, x1, x2, r;
  printf("Enter the three co-efficient :\n");
  scanf("%d%d%d", &a, &b, &c);
  if (a * b * c == 0) {
    printf("\n Invalid Input ");
  } else {
    d = b * b - 4 * a * c;
    r = sqrt(fabs(d));
    if (d > 0) {
      x1 = (-b + r) / (2.0 * a);
      x2 = (-b - r) / (2.0 * a);
      printf("\n The roots are real and distinct\n");
      printf("\n The roots are \n 1) x1=%f\t\t \n 2) x2=%f", x1, x2);
    } else if (d == 0) {
      x1 = x2 = -b / (2.0 * a);
      printf("\n The roots are real and equal\n");
      printf("\n The roots are: \n 1) x1=x2=%f", x1);
    } else {
      x1 = -b / (2.0 * a);
      x2 = r / (2.0 * a);
      printf("\n The roots are real and imaginary\n");
      printf("\n The roots are:\n 1) %f +i %f \t\t\n 2) %f –i %f ", x1, x2, x1,
             x2);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cmp    $0x0,%eax
jne    119c <main+0x5c>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1377 <main+0x237>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x10(%rbp),%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <fabs@plt>
mov    %eax,%edi
call   1060 <sqrt@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1272 <main+0x132>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
addss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  0xe02(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xor    %eax,%eax
sub    -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm0
subss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  0xdd2(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdfd(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1372 <main+0x232>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    12df <main+0x19f>
jp     12df <main+0x19f>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  0xd61(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  %xmm0,-0x18(%rbp)
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    136d <main+0x22d>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  0xd0b(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm2
movsd  0xce4(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x18(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x1c(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
lea    0xd88(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
jmp    1372 <main+0x232>
jmp    1377 <main+0x237>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
lea    0xe98(%rip),%rdi
lea    0x18(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x1c(%rsp),%rcx
call   1060 <scanf@plt>
mov    0x14(%rsp),%ebx
mov    0x1c(%rsp),%eax
imul   0x18(%rsp),%eax
mov    %eax,%ecx
imul   %ebx,%ecx
test   %ecx,%ecx
je     122f <main+0xdf>
imul   %ebx,%ebx
shl    $0x2,%eax
sub    %eax,%ebx
cvtsi2ss %ebx,%xmm0
call   1050 <fabs@plt>
mov    %eax,%edi
call   1070 <sqrt@plt>
xor    %eax,%eax
test   %ebx,%ebx
jle    1242 <main+0xf2>
sub    0x14(%rsp),%eax
cvtsi2ss %eax,%xmm1
movaps %xmm0,%xmm2
addss  %xmm1,%xmm2
cvtss2sd %xmm2,%xmm2
cvtsi2sdl 0x18(%rsp),%xmm3
addsd  %xmm3,%xmm3
divsd  %xmm3,%xmm2
cvtsd2ss %xmm2,%xmm2
movss  %xmm2,0xc(%rsp)
subss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
divsd  %xmm3,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdf5(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    12d2 <main+0x182>
lea    0xdd1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12d2 <main+0x182>
sub    0x14(%rsp),%eax
cvtsi2sd %eax,%xmm2
cvtsi2sdl 0x18(%rsp),%xmm1
addsd  %xmm1,%xmm1
divsd  %xmm1,%xmm2
cvtsd2ss %xmm2,%xmm2
movss  %xmm2,0xc(%rsp)
test   %ebx,%ebx
je     12ae <main+0x15e>
cvtss2sd %xmm0,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdc0(%rip),%rdi
movaps %xmm0,%xmm2
movaps %xmm1,%xmm3
mov    $0x4,%al
call   1040 <printf@plt>
jmp    12d2 <main+0x182>
lea    0xe1d(%rip),%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd75(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Enter the three co-efficient :\0A\00"
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [17 x i8] c"\0A Invalid Input \00"
@.str.3 = [35 x i8] c"\0A The roots are real and distinct\0A\00"
@.str.4 = [40 x i8] c"\0A The roots are \0A 1) x1=%f\09\09 \0A 2) x2=%f\00"
@.str.5 = [32 x i8] c"\0A The roots are real and equal\0A\00"
@.str.6 = [31 x i8] c"\0A The roots are: \0A 1) x1=x2=%f\00"
@.str.7 = [36 x i8] c"\0A The roots are real and imaginary\0A\00"
@.str.8 = [49 x i8] c"\0A The roots are:\0A 1) %f +i %f \09\09\0A 2) %f \E2\80\93i %f \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = mul nsw i32 %11, %12
%14 = load i32, i32* %4
%15 = mul nsw i32 %13, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %107
19: ; preds = %0
%20 = load i32, i32* %3
%21 = load i32, i32* %3
%22 = mul nsw i32 %20, %21
%23 = load i32, i32* %2
%24 = mul nsw i32 4, %23
%25 = load i32, i32* %4
%26 = mul nsw i32 %24, %25
%27 = sub nsw i32 %22, %26
%28 = sitofp i32 %27 to float
store float %28, float* %5
%29 = load float, float* %5
%30 = call i32 @fabs(float %29)
%31 = call float @sqrt(i32 %30)
store float %31, float* %8
%32 = load float, float* %5
%33 = fcmp ogt float %32, 0.000000e+00
br i1 %33, label %34, label %63
34: ; preds = %19
%35 = load i32, i32* %3
%36 = sub nsw i32 0, %35
%37 = sitofp i32 %36 to float
%38 = load float, float* %8
%39 = fadd float %37, %38
%40 = fpext float %39 to double
%41 = load i32, i32* %2
%42 = sitofp i32 %41 to double
%43 = fmul double 2.000000e+00, %42
%44 = fdiv double %40, %43
%45 = fptrunc double %44 to float
store float %45, float* %6
%46 = load i32, i32* %3
%47 = sub nsw i32 0, %46
%48 = sitofp i32 %47 to float
%49 = load float, float* %8
%50 = fsub float %48, %49
%51 = fpext float %50 to double
%52 = load i32, i32* %2
%53 = sitofp i32 %52 to double
%54 = fmul double 2.000000e+00, %53
%55 = fdiv double %51, %54
%56 = fptrunc double %55 to float
store float %56, float* %7
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%58 = load float, float* %6
%59 = fpext float %58 to double
%60 = load float, float* %7
%61 = fpext float %60 to double
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), double %59, double %61)
br label %106
63: ; preds = %19
%64 = load float, float* %5
%65 = fcmp oeq float %64, 0.000000e+00
br i1 %65, label %66, label %79
66: ; preds = %63
%67 = load i32, i32* %3
%68 = sub nsw i32 0, %67
%69 = sitofp i32 %68 to double
%70 = load i32, i32* %2
%71 = sitofp i32 %70 to double
%72 = fmul double 2.000000e+00, %71
%73 = fdiv double %69, %72
%74 = fptrunc double %73 to float
store float %74, float* %7
store float %74, float* %6
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%76 = load float, float* %6
%77 = fpext float %76 to double
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %77)
br label %105
79: ; preds = %63
%80 = load i32, i32* %3
%81 = sub nsw i32 0, %80
%82 = sitofp i32 %81 to double
%83 = load i32, i32* %2
%84 = sitofp i32 %83 to double
%85 = fmul double 2.000000e+00, %84
%86 = fdiv double %82, %85
%87 = fptrunc double %86 to float
store float %87, float* %6
%88 = load float, float* %8
%89 = fpext float %88 to double
%90 = load i32, i32* %2
%91 = sitofp i32 %90 to double
%92 = fmul double 2.000000e+00, %91
%93 = fdiv double %89, %92
%94 = fptrunc double %93 to float
store float %94, float* %7
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%96 = load float, float* %6
%97 = fpext float %96 to double
%98 = load float, float* %7
%99 = fpext float %98 to double
%100 = load float, float* %6
%101 = fpext float %100 to double
%102 = load float, float* %7
%103 = fpext float %102 to double
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), double %97, double %99, double %101, double %103)
br label %105
105: ; preds = %79, %66
br label %106
106: ; preds = %105, %34
br label %107
107: ; preds = %106, %17
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d%d%d\00"
@.str.2 = [17 x i8] c"\0A Invalid Input \00"
@.str.4 = [40 x i8] c"\0A The roots are \0A 1) x1=%f\09\09 \0A 2) x2=%f\00"
@.str.6 = [31 x i8] c"\0A The roots are: \0A 1) x1=x2=%f\00"
@.str.8 = [49 x i8] c"\0A The roots are:\0A 1) %f +i %f \09\09\0A 2) %f \E2\80\93i %f \00"
@str = [31 x i8] c"Enter the three co-efficient :\00"
@str.9 = [35 x i8] c"\0A The roots are real and imaginary\00"
@str.10 = [31 x i8] c"\0A The roots are real and equal\00"
@str.11 = [34 x i8] c"\0A The roots are real and distinct\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = mul i32 %11, %9
%13 = mul i32 %12, %10
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %66
17: ; preds = %0
%18 = mul nsw i32 %10, %10
%19 = mul i32 %12, -4
%20 = add i32 %19, %18
%21 = sitofp i32 %20 to float
%22 = call i32 @fabs(float %21)
%23 = call float @sqrt(i32 %22)
%24 = icmp sgt i32 %20, 0
br i1 %24, label %25, label %44
25: ; preds = %17
%26 = load i32, i32* %2
%27 = sub nsw i32 0, %26
%28 = sitofp i32 %27 to float
%29 = fadd float %23, %28
%30 = fpext float %29 to double
%31 = load i32, i32* %1
%32 = sitofp i32 %31 to double
%33 = fmul double %32, 2.000000e+00
%34 = fdiv double %30, %33
%35 = fptrunc double %34 to float
%36 = fsub float %28, %23
%37 = fpext float %36 to double
%38 = fdiv double %37, %33
%39 = fptrunc double %38 to float
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.11, i64 0, i64 0))
%41 = fpext float %35 to double
%42 = fpext float %39 to double
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), double %41, double %42)
br label %66
44: ; preds = %17
%45 = icmp eq i32 %20, 0
%46 = load i32, i32* %2
%47 = sub nsw i32 0, %46
%48 = sitofp i32 %47 to double
%49 = load i32, i32* %1
%50 = sitofp i32 %49 to double
%51 = fmul double %50, 2.000000e+00
%52 = fdiv double %48, %51
%53 = fptrunc double %52 to float
br i1 %45, label %54, label %58
54: ; preds = %44
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.10, i64 0, i64 0))
%56 = fpext float %53 to double
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %56)
br label %66
58: ; preds = %44
%59 = fpext float %23 to double
%60 = fdiv double %59, %51
%61 = fptrunc double %60 to float
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.9, i64 0, i64 0))
%63 = fpext float %53 to double
%64 = fpext float %61 to double
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), double %63, double %64, double %63, double %64)
br label %66
66: ; preds = %25, %58, %54, %15
ret i32 0
}