#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 *, float, float);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, float *, float *, float *);
float sqrt(float);
int main() {
  float a, b, c, mysqrt, root1, root2;
  puts("input a b c:");
  scanf("%f%f%f", &a, &b, &c);
  if ((b * b - 4 * a * c) < 0) {
    puts("invalid data");
    return -1;
  }
  mysqrt = sqrt((b * b - 4 * a * c));
  root1 = (-b + mysqrt) / (2 * a);
  root2 = (-b - mysqrt) / (2 * a);
  printf("root1 = %.2f\nroot2 = %.2f\n", root1, root2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <scanf@plt>
movss  -0xc(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
movss  0xe7b(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jbe    11c8 <main+0x88>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127a <main+0x13a>
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  0xe26(%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
call   1060 <sqrt@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
addss  -0x14(%rbp),%xmm0
movss  0xde2(%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
subss  -0x14(%rbp),%xmm0
movss  0xdb5(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
lea    0xdbb(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xed6(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x14(%rsp),%rcx
call   1050 <scanf@plt>
movss  0x10(%rsp),%xmm1
mulss  0xe87(%rip),%xmm1
movss  0xc(%rsp),%xmm0
mulss  0x14(%rsp),%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jbe    11ab <main+0x6b>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
ret
ucomiss %xmm1,%xmm0
jb     11b6 <main+0x76>
sqrtss %xmm0,%xmm0
jmp    11bb <main+0x7b>
call   1060 <sqrt@plt>
movss  0xc(%rsp),%xmm2
movaps 0xe48(%rip),%xmm1
xorps  %xmm2,%xmm1
subss  %xmm0,%xmm1
subss  %xmm2,%xmm0
movss  0x10(%rsp),%xmm2
addss  %xmm2,%xmm2
divss  %xmm2,%xmm0
divss  %xmm2,%xmm1
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"input a b c:\00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [13 x i8] c"invalid data\00"
@.str.3 = [27 x i8] c"root1 = %.2f\0Aroot2 = %.2f\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 @puts(i8* getelementptr inbounds ([13 x i8], [13 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)
%18 = fcmp olt float %17, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %0
%20 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %48
21: ; preds = %0
%22 = load float, float* %3
%23 = load float, float* %3
%24 = load float, float* %2
%25 = fmul float 4.000000e+00, %24
%26 = load float, float* %4
%27 = fmul float %25, %26
%28 = fneg float %27
%29 = call float @llvm.fmuladd.f32(float %22, float %23, float %28)
%30 = call float @sqrt(float %29)
store float %30, float* %5
%31 = load float, float* %3
%32 = fneg float %31
%33 = load float, float* %5
%34 = fadd float %32, %33
%35 = load float, float* %2
%36 = fmul float 2.000000e+00, %35
%37 = fdiv float %34, %36
store float %37, float* %6
%38 = load float, float* %3
%39 = fneg float %38
%40 = load float, float* %5
%41 = fsub float %39, %40
%42 = load float, float* %2
%43 = fmul float 2.000000e+00, %42
%44 = fdiv float %41, %43
store float %44, float* %7
%45 = load float, float* %6
%46 = load float, float* %7
%47 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), float %45, float %46)
store i32 0, i32* %1
br label %48
48: ; preds = %21, %19
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [13 x i8] c"input a b c:\00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [13 x i8] c"invalid data\00"
@.str.3 = [27 x i8] c"root1 = %.2f\0Aroot2 = %.2f\0A\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 ([13 x i8], [13 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 olt float %14, 0.000000e+00
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %29
18: ; preds = %0
%19 = call float @sqrt(float %14)
%20 = load float, float* %2
%21 = fneg float %20
%22 = fsub float %19, %20
%23 = load float, float* %1
%24 = fmul float %23, 2.000000e+00
%25 = fdiv float %22, %24
%26 = fsub float %21, %19
%27 = fdiv float %26, %24
%28 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), float %25, float %27)
br label %29
29: ; preds = %18, %16
%30 = phi i32 [ -1, %16 ], [ 0, %18 ]
ret i32 %30
}