#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 *);
float sqrt(float);
int main() {
  float a, b, c, d, r1, r2;
  printf("Enter values of a,b,c\n");
  scanf("%f%f%f", &a, &b, &c);
  d = (b * b) - (4 * a * c);
  r1 = (-b + sqrt(d)) / 2 * a;
  r2 = (-b - sqrt(d)) / 2 * a;
  printf("Roots =%f\n%f", r1, r2);
  if (d < 0) {
    printf("IMAGINARY\n");
  } else if (d == 0) {
    printf("SAME ROOTS\n");
  }
  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    0xecb(%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  0xe8d(%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  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  0xe30(%rip),%xmm1
divss  %xmm1,%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  0xded(%rip),%xmm1
divss  %xmm1,%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdec(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    1261 <main+0x131>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128b <main+0x15b>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1286 <main+0x156>
jp     1286 <main+0x156>
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128b <main+0x15b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x1c(%rsp),%rcx
call   1050 <scanf@plt>
movss  0x18(%rsp),%xmm3
movss  0x14(%rsp),%xmm0
mulss  0xe81(%rip),%xmm0
mulss  0x1c(%rsp),%xmm0
movaps %xmm3,%xmm1
mulss  %xmm3,%xmm1
addss  %xmm0,%xmm1
sqrtss %xmm1,%xmm2
xorps  %xmm4,%xmm4
ucomiss %xmm4,%xmm1
movaps %xmm2,%xmm0
movss  %xmm1,0x10(%rsp)
jae    11ce <main+0x8e>
movaps %xmm1,%xmm0
movss  %xmm2,0xc(%rsp)
movss  %xmm3,0x20(%rsp)
call   1060 <sqrt@plt>
xorps  %xmm4,%xmm4
movss  0x20(%rsp),%xmm3
movss  0xc(%rsp),%xmm2
movss  0x10(%rsp),%xmm1
subss  %xmm3,%xmm0
mulss  0xe2a(%rip),%xmm0
mulss  0x14(%rsp),%xmm0
movss  0x18(%rsp),%xmm3
xorps  0xe23(%rip),%xmm3
ucomiss %xmm4,%xmm1
jae    1216 <main+0xd6>
movss  %xmm0,0xc(%rsp)
movss  0x10(%rsp),%xmm0
movaps %xmm3,0x20(%rsp)
call   1060 <sqrt@plt>
movaps 0x20(%rsp),%xmm3
movaps %xmm0,%xmm2
movss  0xc(%rsp),%xmm0
subss  %xmm2,%xmm3
mulss  0xde2(%rip),%xmm3
mulss  0x14(%rsp),%xmm3
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
lea    0xded(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
ucomiss %xmm1,%xmm0
jbe    1258 <main+0x118>
lea    0xdff(%rip),%rdi
jmp    1266 <main+0x126>
ucomiss %xmm0,%xmm1
jne    126b <main+0x12b>
jp     126b <main+0x12b>
lea    0xde4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

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

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [13 x i8] c"Roots =%f\0A%f\00"
@str = [22 x i8] c"Enter values of a,b,c\00"
@str.5 = [11 x i8] c"SAME ROOTS\00"
@str.6 = [10 x i8] c"IMAGINARY\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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 = call float @sqrt(float %14)
%16 = fsub float %15, %9
%17 = fmul float %16, 5.000000e-01
%18 = load float, float* %1
%19 = fmul float %18, %17
%20 = load float, float* %2
%21 = fneg float %20
%22 = call float @sqrt(float %14)
%23 = fsub float %21, %22
%24 = fmul float %23, 5.000000e-01
%25 = load float, float* %1
%26 = fmul float %25, %24
%27 = fpext float %19 to double
%28 = fpext float %26 to double
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %27, double %28)
%30 = fcmp olt float %14, 0.000000e+00
br i1 %30, label %33, label %31
31: ; preds = %0
%32 = fcmp oeq float %14, 0.000000e+00
br i1 %32, label %33, label %36
33: ; preds = %31, %0
%34 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0), %0 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0), %31 ]
%35 = call i32 @puts(i8* dereferenceable(1) %34)
br label %36
36: ; preds = %33, %31
ret i32 0
}