#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 *, int *, int *, int *);
int sqrt(double);
int main() {
  int a, b, c;
  double x1, x2, D;
  printf("Enter the coeficients of a quadratic equation: \n");
  scanf("%d %d %d", &a, &b, &c);
  D = b * b - 4 * a * c;
  if (D > 0) {
    x1 = (-b + sqrt(D)) / (2 * a);
    x2 = (-b - sqrt(D)) / (2 * a);
    printf("Real roots are:\nx1 = %lf\nx2 = %lf", x1, x2);
  } else if (D == 0) {
    x1 = x2 = -b / (2 * a);
    printf("Real roots are:\nx1 = %lf\nx2 = %lf", x1, x2);
  } else {
    x1 = -b / (2 * a);
    x2 = sqrt(-D) / (2 * a);
    printf("Root is %lf+i%lf\n", x1, x2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x10(%rbp),%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1206 <main+0xd6>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe40(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12be <main+0x18e>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1257 <main+0x127>
jp     1257 <main+0x127>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xdef(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12b9 <main+0x189>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1050 <sqrt@plt>
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xdaa(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12be <main+0x18e>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xf01(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x1c(%rsp),%rcx
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
mov    %ebx,%ecx
imul   %ebx,%ecx
mov    0x8(%rsp),%esi
mov    0x1c(%rsp),%eax
imul   %esi,%eax
shl    $0x2,%eax
sub    %eax,%ecx
cvtsi2sd %ecx,%xmm0
test   %ecx,%ecx
jle    11d9 <main+0x99>
movapd %xmm0,0x20(%rsp)
call   1060 <sqrt@plt>
sub    %ebx,%eax
mov    0x8(%rsp),%ecx
add    %ecx,%ecx
cltd
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0xc(%rsp),%ebx
movapd 0x20(%rsp),%xmm0
call   1060 <sqrt@plt>
add    %ebx,%eax
neg    %eax
mov    0x8(%rsp),%ecx
add    %ecx,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
lea    0xe42(%rip),%rdi
jmp    1214 <main+0xd4>
add    %esi,%esi
mov    %ebx,%eax
cltd
idiv   %esi
neg    %eax
cvtsi2sd %eax,%xmm1
test   %ecx,%ecx
je     1229 <main+0xe9>
xorpd  0xe0e(%rip),%xmm0
movsd  %xmm1,0x10(%rsp)
call   1060 <sqrt@plt>
mov    0x8(%rsp),%ecx
add    %ecx,%ecx
cltd
idiv   %ecx
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
lea    0xe27(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret
lea    0xde9(%rip),%rdi
movapd %xmm1,%xmm0
jmp    121a <main+0xda>

LLVM IR (-O0):
@.str = [49 x i8] c"Enter the coeficients of a quadratic equation: \0A\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [34 x i8] c"Real roots are:\0Ax1 = %lf\0Ax2 = %lf\00"
@.str.3 = [18 x i8] c"Root is %lf+i%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = mul nsw i32 %10, %11
%13 = load i32, i32* %2
%14 = mul nsw i32 4, %13
%15 = load i32, i32* %4
%16 = mul nsw i32 %14, %15
%17 = sub nsw i32 %12, %16
%18 = sitofp i32 %17 to double
store double %18, double* %7
%19 = load double, double* %7
%20 = fcmp ogt double %19, 0.000000e+00
br i1 %20, label %21, label %43
21: ; preds = %0
%22 = load i32, i32* %3
%23 = sub nsw i32 0, %22
%24 = load double, double* %7
%25 = call i32 @sqrt(double %24)
%26 = add nsw i32 %23, %25
%27 = load i32, i32* %2
%28 = mul nsw i32 2, %27
%29 = sdiv i32 %26, %28
%30 = sitofp i32 %29 to double
store double %30, double* %5
%31 = load i32, i32* %3
%32 = sub nsw i32 0, %31
%33 = load double, double* %7
%34 = call i32 @sqrt(double %33)
%35 = sub nsw i32 %32, %34
%36 = load i32, i32* %2
%37 = mul nsw i32 2, %36
%38 = sdiv i32 %35, %37
%39 = sitofp i32 %38 to double
store double %39, double* %6
%40 = load double, double* %5
%41 = load double, double* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %40, double %41)
br label %74
43: ; preds = %0
%44 = load double, double* %7
%45 = fcmp oeq double %44, 0.000000e+00
br i1 %45, label %46, label %56
46: ; preds = %43
%47 = load i32, i32* %3
%48 = sub nsw i32 0, %47
%49 = load i32, i32* %2
%50 = mul nsw i32 2, %49
%51 = sdiv i32 %48, %50
%52 = sitofp i32 %51 to double
store double %52, double* %6
store double %52, double* %5
%53 = load double, double* %5
%54 = load double, double* %6
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %53, double %54)
br label %73
56: ; preds = %43
%57 = load i32, i32* %3
%58 = sub nsw i32 0, %57
%59 = load i32, i32* %2
%60 = mul nsw i32 2, %59
%61 = sdiv i32 %58, %60
%62 = sitofp i32 %61 to double
store double %62, double* %5
%63 = load double, double* %7
%64 = fneg double %63
%65 = call i32 @sqrt(double %64)
%66 = load i32, i32* %2
%67 = mul nsw i32 2, %66
%68 = sdiv i32 %65, %67
%69 = sitofp i32 %68 to double
store double %69, double* %6
%70 = load double, double* %5
%71 = load double, double* %6
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %70, double %71)
br label %73
73: ; preds = %56, %46
br label %74
74: ; preds = %73, %21
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [34 x i8] c"Real roots are:\0Ax1 = %lf\0Ax2 = %lf\00"
@.str.3 = [18 x i8] c"Root is %lf+i%lf\0A\00"
@str = [48 x i8] c"Enter the coeficients of a quadratic equation: \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 ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, %9
%11 = load i32, i32* %1
%12 = mul i32 %11, -4
%13 = load i32, i32* %3
%14 = mul i32 %12, %13
%15 = add i32 %14, %10
%16 = sitofp i32 %15 to double
%17 = icmp sgt i32 %15, 0
br i1 %17, label %18, label %34
18: ; preds = %0
%19 = call i32 @sqrt(double %16)
%20 = sub i32 %19, %9
%21 = load i32, i32* %1
%22 = shl nsw i32 %21, 1
%23 = sdiv i32 %20, %22
%24 = sitofp i32 %23 to double
%25 = load i32, i32* %2
%26 = call i32 @sqrt(double %16)
%27 = add i32 %25, %26
%28 = sub i32 0, %27
%29 = load i32, i32* %1
%30 = shl nsw i32 %29, 1
%31 = sdiv i32 %28, %30
%32 = sitofp i32 %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %24, double %32)
br label %50
34: ; preds = %0
%35 = icmp eq i32 %15, 0
%36 = shl nsw i32 %11, 1
%37 = sdiv i32 %9, %36
%38 = sub nsw i32 0, %37
%39 = sitofp i32 %38 to double
br i1 %35, label %40, label %42
40: ; preds = %34
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %39, double %39)
br label %50
42: ; preds = %34
%43 = fneg double %16
%44 = call i32 @sqrt(double %43)
%45 = load i32, i32* %1
%46 = shl nsw i32 %45, 1
%47 = sdiv i32 %44, %46
%48 = sitofp i32 %47 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %39, double %48)
br label %50
50: ; preds = %40, %42, %18
ret i32 0
}