#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 */
scalar_t__ pow(double, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int sqrt(scalar_t__);
int /*<<< orphan*/ system(char *);
int main() {
  double a, b, c;
  double ans[2];
  printf("Quadratic equation solver\n");
  printf("ax^2+bx+c\n");
  printf("a : ");
  scanf("%lf", &a);
  printf("b : ");
  scanf("%lf", &b);
  printf("c : ");
  scanf("%lf", &c);
  if (sqrt(pow(b, 2) - (4 * a * c)) >= 0 && a != 0) {
    printf("Solved with 2 real roots!\n");
    printf("Root 1 : %lf\n",
           ((0 - b) + sqrt(pow(b, 2) - (4 * a * c))) / (2 * a));
    printf("Root 2 : %lf\n",
           ((0 - b) - sqrt(pow(b, 2) - (4 * a * c))) / (2 * a));
  } else if (a == 0) {
    printf("Failed...(a should not be zero)\n");
  } else
    printf("Failed...(Complex roots unsupported yet)\n");
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6f(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe0f(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1070 <sqrt@plt>
cmp    $0x0,%eax
jl     136d <main+0x21d>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    124a <main+0xfa>
jp     124a <main+0xfa>
jmp    136d <main+0x21d>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
cvtsi2sd %rax,%xmm1
movsd  0xd7f(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1070 <sqrt@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  0xd3f(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xd8b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
cvtsi2sd %rax,%xmm1
movsd  0xcf7(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1070 <sqrt@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xcb7(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xd11(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    13ab <main+0x25b>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1398 <main+0x248>
jp     1398 <main+0x248>
lea    0xcf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13a6 <main+0x256>
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13ab <main+0x25b>
lea    0xd19(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe7b(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe55(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
movsd  0x20(%rsp),%xmm0
mov    $0x2,%edi
call   1070 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xe05(%rip),%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1080 <sqrt@plt>
movsd  0x8(%rsp),%xmm0
test   %eax,%eax
js     1331 <main+0x1d1>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    122d <main+0xcd>
jnp    1331 <main+0x1d1>
lea    0xe76(%rip),%rdi
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
call   1030 <puts@plt>
movsd  0x20(%rsp),%xmm0
xorpd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rsp)
mov    $0x2,%edi
call   1070 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xd89(%rip),%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1080 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x28(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
lea    0xd6e(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x2,%edi
call   1070 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0xd1c(%rip),%xmm1
mulsd  0x8(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1080 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
lea    0xd01(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1352 <main+0x1f2>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1346 <main+0x1e6>
jp     1346 <main+0x1e6>
lea    0xd46(%rip),%rdi
jmp    134d <main+0x1ed>
lea    0xd14(%rip),%rdi
call   1030 <puts@plt>
lea    0xcde(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Quadratic equation solver\0A\00"
@.str.1 = [11 x i8] c"ax^2+bx+c\0A\00"
@.str.2 = [5 x i8] c"a : \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [5 x i8] c"b : \00"
@.str.5 = [5 x i8] c"c : \00"
@.str.6 = [27 x i8] c"Solved with 2 real roots!\0A\00"
@.str.7 = [14 x i8] c"Root 1 : %lf\0A\00"
@.str.8 = [14 x i8] c"Root 2 : %lf\0A\00"
@.str.9 = [33 x i8] c"Failed...(a should not be zero)\0A\00"
@.str.10 = [42 x i8] c"Failed...(Complex roots unsupported yet)\0A\00"
@.str.11 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca [2 x double]
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %4)
%14 = load double, double* %3
%15 = call i64 @pow(double %14, i32 2)
%16 = sitofp i64 %15 to double
%17 = load double, double* %2
%18 = fmul double 4.000000e+00, %17
%19 = load double, double* %4
%20 = fneg double %18
%21 = call double @llvm.fmuladd.f64(double %20, double %19, double %16)
%22 = fptosi double %21 to i64
%23 = call i32 @sqrt(i64 %22)
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %66
25: ; preds = %0
%26 = load double, double* %2
%27 = fcmp une double %26, 0.000000e+00
br i1 %27, label %28, label %66
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%30 = load double, double* %3
%31 = fsub double 0.000000e+00, %30
%32 = load double, double* %3
%33 = call i64 @pow(double %32, i32 2)
%34 = sitofp i64 %33 to double
%35 = load double, double* %2
%36 = fmul double 4.000000e+00, %35
%37 = load double, double* %4
%38 = fneg double %36
%39 = call double @llvm.fmuladd.f64(double %38, double %37, double %34)
%40 = fptosi double %39 to i64
%41 = call i32 @sqrt(i64 %40)
%42 = sitofp i32 %41 to double
%43 = fadd double %31, %42
%44 = load double, double* %2
%45 = fmul double 2.000000e+00, %44
%46 = fdiv double %43, %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), double %46)
%48 = load double, double* %3
%49 = fsub double 0.000000e+00, %48
%50 = load double, double* %3
%51 = call i64 @pow(double %50, i32 2)
%52 = sitofp i64 %51 to double
%53 = load double, double* %2
%54 = fmul double 4.000000e+00, %53
%55 = load double, double* %4
%56 = fneg double %54
%57 = call double @llvm.fmuladd.f64(double %56, double %55, double %52)
%58 = fptosi double %57 to i64
%59 = call i32 @sqrt(i64 %58)
%60 = sitofp i32 %59 to double
%61 = fsub double %49, %60
%62 = load double, double* %2
%63 = fmul double 2.000000e+00, %62
%64 = fdiv double %61, %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), double %64)
br label %74
66: ; preds = %25, %0
%67 = load double, double* %2
%68 = fcmp oeq double %67, 0.000000e+00
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
br label %73
71: ; preds = %66
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0))
br label %73
73: ; preds = %71, %69
br label %74
74: ; preds = %73, %28
%75 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [5 x i8] c"a : \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [5 x i8] c"b : \00"
@.str.5 = [5 x i8] c"c : \00"
@.str.7 = [14 x i8] c"Root 1 : %lf\0A\00"
@.str.8 = [14 x i8] c"Root 2 : %lf\0A\00"
@.str.11 = [6 x i8] c"pause\00"
@str = [26 x i8] c"Quadratic equation solver\00"
@str.12 = [10 x i8] c"ax^2+bx+c\00"
@str.13 = [41 x i8] c"Failed...(Complex roots unsupported yet)\00"
@str.14 = [32 x i8] c"Failed...(a should not be zero)\00"
@str.15 = [26 x i8] c"Solved with 2 real roots!\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.12, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %3)
%15 = load double, double* %2
%16 = call i64 @pow(double %15, i32 2)
%17 = sitofp i64 %16 to double
%18 = load double, double* %1
%19 = load double, double* %3
%20 = fmul double %18, -4.000000e+00
%21 = call double @llvm.fmuladd.f64(double %20, double %19, double %17)
%22 = fptosi double %21 to i64
%23 = call i32 @sqrt(i64 %22)
%24 = icmp sgt i32 %23, -1
%25 = load double, double* %1
%26 = fcmp une double %25, 0.000000e+00
%27 = select i1 %24, i1 %26, i1 false
br i1 %27, label %28, label %62
28: ; preds = %0
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%30 = load double, double* %2
%31 = fsub double 0.000000e+00, %30
%32 = call i64 @pow(double %30, i32 2)
%33 = sitofp i64 %32 to double
%34 = load double, double* %1
%35 = load double, double* %3
%36 = fmul double %34, -4.000000e+00
%37 = call double @llvm.fmuladd.f64(double %36, double %35, double %33)
%38 = fptosi double %37 to i64
%39 = call i32 @sqrt(i64 %38)
%40 = sitofp i32 %39 to double
%41 = fadd double %31, %40
%42 = load double, double* %1
%43 = fmul double %42, 2.000000e+00
%44 = fdiv double %41, %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), double %44)
%46 = load double, double* %2
%47 = fsub double 0.000000e+00, %46
%48 = call i64 @pow(double %46, i32 2)
%49 = sitofp i64 %48 to double
%50 = load double, double* %1
%51 = load double, double* %3
%52 = fmul double %50, -4.000000e+00
%53 = call double @llvm.fmuladd.f64(double %52, double %51, double %49)
%54 = fptosi double %53 to i64
%55 = call i32 @sqrt(i64 %54)
%56 = sitofp i32 %55 to double
%57 = fsub double %47, %56
%58 = load double, double* %1
%59 = fmul double %58, 2.000000e+00
%60 = fdiv double %57, %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), double %60)
br label %68
62: ; preds = %0
%63 = fcmp oeq double %25, 0.000000e+00
br i1 %63, label %64, label %66
64: ; preds = %62
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.14, i64 0, i64 0))
br label %68
66: ; preds = %62
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.13, i64 0, i64 0))
br label %68
68: ; preds = %64, %66, %28
%69 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}