#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 *, float *, float *, float *);
int sqrt(float);
int main() {
  float a, b, c, determinant, r1, r2, real, imag;
  printf("Enter coefficients a, b and c: ");
  scanf("%f%f%f", &a, &b, &c);
  determinant = b * b - 4 * a * c;
  if (determinant > 0) {
    r1 = (-b + sqrt(determinant)) / (2 * a);
    r2 = (-b - sqrt(determinant)) / (2 * a);
    printf("Roots are: %.2f and %.2f", r1, r2);
  } else if (determinant == 0) {
    r1 = r2 = -b / (2 * a);
    printf("Roots are: %.2f and %.2f", r1, r2);
  } else {
    real = -b / (2 * a);
    imag = sqrt(-determinant) / (2 * a);
    printf("Roots are: %.2f+%.2fi and %.2f-%.2fi", real, imag, real, imag);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  0xe89(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  -0x10(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1259 <main+0x129>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movss  -0x2c(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
movss  0xe22(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movss  -0x28(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
subss  %xmm1,%xmm0
movss  0xdde(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xde2(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1352 <main+0x222>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    12c2 <main+0x192>
jp     12c2 <main+0x192>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xd7a(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd79(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    134d <main+0x21d>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xd28(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1050 <sqrt@plt>
cvtsi2ss %eax,%xmm0
movss  0xcf7(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x20(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x24(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
lea    0xd02(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
jmp    1352 <main+0x222>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0xee5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm2
movss  0x4(%rsp),%xmm3
movss  0xe8f(%rip),%xmm1
mulss  %xmm3,%xmm1
mulss  0xc(%rsp),%xmm1
movaps %xmm2,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1213 <main+0xe3>
movaps %xmm2,0x10(%rsp)
movaps %xmm0,0x30(%rsp)
call   1050 <sqrt@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
subss  0x10(%rsp),%xmm1
movss  0x4(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm1
movss  %xmm1,0x10(%rsp)
movss  0x8(%rsp),%xmm0
xorps  0xe41(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x30(%rsp),%xmm0
call   1050 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movaps 0x20(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm1
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xe36(%rip),%rdi
jmp    1237 <main+0x107>
xorps  0xdf6(%rip),%xmm2
addss  %xmm3,%xmm3
divss  %xmm3,%xmm2
jne    1240 <main+0x110>
jp     1240 <main+0x110>
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe13(%rip),%rdi
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
jmp    1287 <main+0x157>
xorps  0xdc9(%rip),%xmm0
movaps %xmm2,0x10(%rsp)
call   1050 <sqrt@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
movss  0x4(%rsp),%xmm0
addss  %xmm0,%xmm0
divss  %xmm0,%xmm1
movaps 0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xde6(%rip),%rdi
movaps %xmm0,%xmm2
movaps %xmm1,%xmm3
mov    $0x4,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Enter coefficients a, b and c: \00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [25 x i8] c"Roots are: %.2f and %.2f\00"
@.str.3 = [37 x i8] c"Roots are: %.2f+%.2fi and %.2f-%.2fi\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %4)
%12 = load float, float* %3
%13 = load float, float* %3
%14 = load float, float* %2
%15 = fmul float 4.000000e+00, %14
%16 = load float, float* %4
%17 = fmul float %15, %16
%18 = fneg float %17
%19 = call float @llvm.fmuladd.f32(float %12, float %13, float %18)
store float %19, float* %5
%20 = load float, float* %5
%21 = fcmp ogt float %20, 0.000000e+00
br i1 %21, label %22, label %46
22: ; preds = %0
%23 = load float, float* %3
%24 = fneg float %23
%25 = load float, float* %5
%26 = call i32 @sqrt(float %25)
%27 = sitofp i32 %26 to float
%28 = fadd float %24, %27
%29 = load float, float* %2
%30 = fmul float 2.000000e+00, %29
%31 = fdiv float %28, %30
store float %31, float* %6
%32 = load float, float* %3
%33 = fneg float %32
%34 = load float, float* %5
%35 = call i32 @sqrt(float %34)
%36 = sitofp i32 %35 to float
%37 = fsub float %33, %36
%38 = load float, float* %2
%39 = fmul float 2.000000e+00, %38
%40 = fdiv float %37, %39
store float %40, float* %7
%41 = load float, float* %6
%42 = fpext float %41 to double
%43 = load float, float* %7
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %42, double %44)
br label %83
46: ; preds = %0
%47 = load float, float* %5
%48 = fcmp oeq float %47, 0.000000e+00
br i1 %48, label %49, label %60
49: ; preds = %46
%50 = load float, float* %3
%51 = fneg float %50
%52 = load float, float* %2
%53 = fmul float 2.000000e+00, %52
%54 = fdiv float %51, %53
store float %54, float* %7
store float %54, float* %6
%55 = load float, float* %6
%56 = fpext float %55 to double
%57 = load float, float* %7
%58 = fpext float %57 to double
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %56, double %58)
br label %82
60: ; preds = %46
%61 = load float, float* %3
%62 = fneg float %61
%63 = load float, float* %2
%64 = fmul float 2.000000e+00, %63
%65 = fdiv float %62, %64
store float %65, float* %8
%66 = load float, float* %5
%67 = fneg float %66
%68 = call i32 @sqrt(float %67)
%69 = sitofp i32 %68 to float
%70 = load float, float* %2
%71 = fmul float 2.000000e+00, %70
%72 = fdiv float %69, %71
store float %72, float* %9
%73 = load float, float* %8
%74 = fpext float %73 to double
%75 = load float, float* %9
%76 = fpext float %75 to double
%77 = load float, float* %8
%78 = fpext float %77 to double
%79 = load float, float* %9
%80 = fpext float %79 to double
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), double %74, double %76, double %78, double %80)
br label %82
82: ; preds = %60, %49
br label %83
83: ; preds = %82, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Enter coefficients a, b and c: \00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [25 x i8] c"Roots are: %.2f and %.2f\00"
@.str.3 = [37 x i8] c"Roots are: %.2f+%.2fi and %.2f-%.2fi\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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), float* %1, float* %2, float* %3)
%9 = load float, float* %2
%10 = load float, float* %1
%11 = load float, float* %3
%12 = fmul float %10, -4.000000e+00
%13 = fmul float %12, %11
%14 = call float @llvm.fmuladd.f32(float %9, float %9, float %13)
%15 = fcmp ogt float %14, 0.000000e+00
br i1 %15, label %16, label %34
16: ; preds = %0
%17 = call i32 @sqrt(float %14)
%18 = sitofp i32 %17 to float
%19 = fsub float %18, %9
%20 = load float, float* %1
%21 = fmul float %20, 2.000000e+00
%22 = fdiv float %19, %21
%23 = load float, float* %2
%24 = fneg float %23
%25 = call i32 @sqrt(float %14)
%26 = sitofp i32 %25 to float
%27 = fsub float %24, %26
%28 = load float, float* %1
%29 = fmul float %28, 2.000000e+00
%30 = fdiv float %27, %29
%31 = fpext float %22 to double
%32 = fpext float %30 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %31, double %32)
br label %52
34: ; preds = %0
%35 = fcmp oeq float %14, 0.000000e+00
%36 = fneg float %9
%37 = fmul float %10, 2.000000e+00
%38 = fdiv float %36, %37
br i1 %35, label %39, label %42
39: ; preds = %34
%40 = fpext float %38 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %40, double %40)
br label %52
42: ; preds = %34
%43 = fneg float %14
%44 = call i32 @sqrt(float %43)
%45 = sitofp i32 %44 to float
%46 = load float, float* %1
%47 = fmul float %46, 2.000000e+00
%48 = fdiv float %45, %47
%49 = fpext float %38 to double
%50 = fpext float %48 to double
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), double %49, double %50, double %49, double %50)
br label %52
52: ; preds = %39, %42, %16
ret i32 0
}