#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);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
double sqrt(double);
int main() {
  double a, b, c, d, e, x1, x2;
  printf("\na = ");
  scanf("%lf", &a);
  printf("b = ");
  scanf("%lf", &b);
  printf("c = ");
  scanf("%lf", &c);
  e = b * b - 4. * a * c;
  if (e < 0.) {
    printf("\nError: roots are complex\n");
    exit(1);
  }
  if (a == 0.) {
    printf("\nError: a = 0.\n");
    exit(1);
  }
  d = sqrt(e);
  x1 = (-b + d) / (2. * a);
  x2 = (-b - d) / (2. * a);
  printf("\nx1 = %12.3e   x2 = %12.3e\n", x1, x2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xe45(%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,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    120f <main+0xcf>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    123f <main+0xff>
jp     123f <main+0xff>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movsd  -0x30(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xd91(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xd5a(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    0xd82(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebc(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0xe3f(%rip),%xmm2
mulsd  %xmm1,%xmm2
mulsd  0x18(%rsp),%xmm2
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
ja     123c <main+0xec>
ucomisd %xmm2,%xmm1
jne    11e5 <main+0x95>
jnp    1245 <main+0xf5>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11f5 <main+0xa5>
sqrtsd %xmm0,%xmm0
jmp    11fa <main+0xaa>
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
movapd 0xe08(%rip),%xmm1
xorpd  %xmm2,%xmm1
subsd  %xmm0,%xmm1
subsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm2
addsd  %xmm2,%xmm2
divsd  %xmm2,%xmm0
divsd  %xmm2,%xmm1
lea    0xe07(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe1c(%rip),%rdi
jmp    124c <main+0xfc>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\0Aa = \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [5 x i8] c"b = \00"
@.str.3 = [5 x i8] c"c = \00"
@.str.4 = [27 x i8] c"\0AError: roots are complex\0A\00"
@.str.5 = [16 x i8] c"\0AError: a = 0.\0A\00"
@.str.6 = [28 x i8] c"\0Ax1 = %12.3e x2 = %12.3e\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
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%15 = load double, double* %3
%16 = load double, double* %3
%17 = load double, double* %2
%18 = fmul double 4.000000e+00, %17
%19 = load double, double* %4
%20 = fmul double %18, %19
%21 = fneg double %20
%22 = call double @llvm.fmuladd.f64(double %15, double %16, double %21)
store double %22, double* %6
%23 = load double, double* %6
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %25, label %28
25: ; preds = %0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %0
%29 = load double, double* %2
%30 = fcmp oeq double %29, 0.000000e+00
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %28
%35 = load double, double* %6
%36 = call double @sqrt(double %35)
store double %36, double* %5
%37 = load double, double* %3
%38 = fneg double %37
%39 = load double, double* %5
%40 = fadd double %38, %39
%41 = load double, double* %2
%42 = fmul double 2.000000e+00, %41
%43 = fdiv double %40, %42
store double %43, double* %7
%44 = load double, double* %3
%45 = fneg double %44
%46 = load double, double* %5
%47 = fsub double %45, %46
%48 = load double, double* %2
%49 = fmul double 2.000000e+00, %48
%50 = fdiv double %47, %49
store double %50, double* %8
%51 = load double, double* %7
%52 = load double, double* %8
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), double %51, double %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"\0Aa = \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [5 x i8] c"b = \00"
@.str.3 = [5 x i8] c"c = \00"
@.str.6 = [28 x i8] c"\0Ax1 = %12.3e x2 = %12.3e\0A\00"
@str = [15 x i8] c"\0AError: a = 0.\00"
@str.7 = [26 x i8] c"\0AError: roots are complex\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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%9 = 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.1, i64 0, i64 0), double* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%13 = load double, double* %2
%14 = load double, double* %1
%15 = load double, double* %3
%16 = fmul double %14, -4.000000e+00
%17 = fmul double %16, %15
%18 = call double @llvm.fmuladd.f64(double %13, double %13, double %17)
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.7, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %0
%24 = fcmp oeq double %14, 0.000000e+00
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %23
%29 = call double @sqrt(double %18)
%30 = load double, double* %2
%31 = fneg double %30
%32 = fsub double %29, %30
%33 = load double, double* %1
%34 = fmul double %33, 2.000000e+00
%35 = fdiv double %32, %34
%36 = fsub double %31, %29
%37 = fdiv double %36, %34
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), double %35, double %37)
ret i32 0
}