#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 *, double *, double *, double *);
double sqrt(double);
int main(void) {
  double a, b, c, disc, x1, x2, p, q;
  printf("input a,b,c:");
  scanf("%lf,%lf,%lf", &a, &b, &c);
  disc = b * b - 4 * a * c;
  if (disc < 0) {
    printf("There is NO real root in this equation. reinput a,b,c\n");
    return -1;
  }
  p = -b / (2.0 * a);
  q = sqrt(disc) / (2.0 * a);
  x1 = p + q;
  x2 = p - q;
  printf("x1=%7.2f\nx2=%7.2f\n", x1, x2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xe89(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11cd <main+0x9d>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    125c <main+0x12c>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe17(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  0xdf7(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xe12(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed4(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <scanf@plt>
movsd  0x18(%rsp),%xmm1
movsd  0x8(%rsp),%xmm3
movsd  0xe7f(%rip),%xmm2
mulsd  %xmm3,%xmm2
mulsd  0x10(%rsp),%xmm2
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jbe    11b7 <main+0x77>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x48,%rsp
ret
xorpd  0xe51(%rip),%xmm1
ucomisd %xmm2,%xmm0
jb     11cb <main+0x8b>
sqrtsd %xmm0,%xmm0
jmp    11e8 <main+0xa8>
movapd %xmm1,0x30(%rsp)
movapd %xmm3,0x20(%rsp)
call   1060 <sqrt@plt>
movapd 0x20(%rsp),%xmm3
movapd 0x30(%rsp),%xmm1
movhpd 0x8(%rsp),%xmm3
addpd  %xmm3,%xmm3
unpcklpd %xmm0,%xmm1
divpd  %xmm3,%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
movapd %xmm1,%xmm0
addsd  %xmm2,%xmm0
subsd  %xmm2,%xmm1
lea    0xe24(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"input a,b,c:\00"
@.str.1 = [12 x i8] c"%lf,%lf,%lf\00"
@.str.2 = [55 x i8] c"There is NO real root in this equation. reinput a,b,c\0A\00"
@.str.3 = [19 x i8] c"x1=%7.2f\0Ax2=%7.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3, double* %4)
%12 = load double, double* %3
%13 = load double, double* %3
%14 = load double, double* %2
%15 = fmul double 4.000000e+00, %14
%16 = load double, double* %4
%17 = fmul double %15, %16
%18 = fneg double %17
%19 = call double @llvm.fmuladd.f64(double %12, double %13, double %18)
store double %19, double* %5
%20 = load double, double* %5
%21 = fcmp olt double %20, 0.000000e+00
br i1 %21, label %22, label %24
22: ; preds = %0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %44
24: ; preds = %0
%25 = load double, double* %3
%26 = fneg double %25
%27 = load double, double* %2
%28 = fmul double 2.000000e+00, %27
%29 = fdiv double %26, %28
store double %29, double* %8
%30 = load double, double* %5
%31 = call double @sqrt(double %30)
%32 = load double, double* %2
%33 = fmul double 2.000000e+00, %32
%34 = fdiv double %31, %33
store double %34, double* %9
%35 = load double, double* %8
%36 = load double, double* %9
%37 = fadd double %35, %36
store double %37, double* %6
%38 = load double, double* %8
%39 = load double, double* %9
%40 = fsub double %38, %39
store double %40, double* %7
%41 = load double, double* %6
%42 = load double, double* %7
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %41, double %42)
store i32 0, i32* %1
br label %44
44: ; preds = %24, %22
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@.str = [13 x i8] c"input a,b,c:\00"
@.str.1 = [12 x i8] c"%lf,%lf,%lf\00"
@.str.3 = [19 x i8] c"x1=%7.2f\0Ax2=%7.2f\0A\00"
@str = [54 x i8] c"There is NO real root in this equation. reinput a,b,c\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2, double* %3)
%9 = load double, double* %2
%10 = load double, double* %1
%11 = load double, double* %3
%12 = fmul double %10, -4.000000e+00
%13 = fmul double %12, %11
%14 = call double @llvm.fmuladd.f64(double %9, double %9, double %13)
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
br label %33
18: ; preds = %0
%19 = fneg double %9
%20 = call double @sqrt(double %14)
%21 = load double, double* %1
%22 = insertelement <2 x double> poison, double %10, i64 0
%23 = insertelement <2 x double> %22, double %21, i64 1
%24 = fmul <2 x double> %23, <double 2.000000e+00, double 2.000000e+00>
%25 = insertelement <2 x double> poison, double %19, i64 0
%26 = insertelement <2 x double> %25, double %20, i64 1
%27 = fdiv <2 x double> %26, %24
%28 = extractelement <2 x double> %27, i64 0
%29 = extractelement <2 x double> %27, i64 1
%30 = fadd double %28, %29
%31 = fsub double %28, %29
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %30, double %31)
br label %33
33: ; preds = %18, %16
%34 = phi i32 [ -1, %16 ], [ 0, %18 ]
ret i32 %34
}