#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 pow(float, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *, float *);
float sqrt(float);
int main() {
  float d, a, b, c, x1, x2;
  printf("Enter a, b, c values: ");
  scanf("%f%f%f", &a, &b, &c);
  d = pow(b, 2) - 4 * a * c;
  if (d > 0) {
    x1 = (-b + sqrt(d)) / 2 * a;
    x2 = (-b - sqrt(d)) / 2 * a;
    printf("root1 = %.2f\nroot2 = %.2f", x1, x2);
  } else if (d == 0) {
    x1 = x2 = b / a;
    printf("root1 = root2 = %.2f", x1);
  } else if (d < 0) {
    printf("%s\n", "Complex number, I forgot formula");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1040 <scanf@plt>
movss  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
cvtsi2ss %eax,%xmm1
movss  0xe70(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1270 <main+0x130>
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  0xe0a(%rip),%xmm1
divss  %xmm1,%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  0xdc7(%rip),%xmm1
divss  %xmm1,%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdc2(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12e3 <main+0x1a3>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    12b7 <main+0x177>
jp     12b7 <main+0x177>
movss  -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd95(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12de <main+0x19e>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    12d9 <main+0x199>
lea    0xd8a(%rip),%rdi
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12de <main+0x19e>
jmp    12e3 <main+0x1a3>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x1c(%rsp),%rcx
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
cvtsi2ss %eax,%xmm1
movss  0x14(%rsp),%xmm0
movss  0xe61(%rip),%xmm2
mulss  %xmm0,%xmm2
mulss  0x1c(%rsp),%xmm2
addss  %xmm1,%xmm2
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm2
jbe    126f <main+0x11f>
movss  0xc(%rsp),%xmm0
sqrtss %xmm2,%xmm3
movaps %xmm3,%xmm1
jae    11f7 <main+0xa7>
movss  %xmm0,0x18(%rsp)
movaps %xmm2,%xmm0
movss  %xmm2,0x10(%rsp)
movss  %xmm3,0x20(%rsp)
call   1070 <sqrt@plt>
movss  0x20(%rsp),%xmm3
movss  0x10(%rsp),%xmm2
movaps %xmm0,%xmm1
movss  0x18(%rsp),%xmm0
subss  %xmm0,%xmm1
mulss  0xe01(%rip),%xmm1
mulss  0x14(%rsp),%xmm1
movss  0xc(%rsp),%xmm4
xorps  0xdfa(%rip),%xmm4
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm2
jae    123f <main+0xef>
movaps %xmm2,%xmm0
movss  %xmm1,0x10(%rsp)
movaps %xmm4,0x20(%rsp)
call   1070 <sqrt@plt>
movaps 0x20(%rsp),%xmm4
movss  0x10(%rsp),%xmm1
movaps %xmm0,%xmm3
subss  %xmm3,%xmm4
mulss  0xdb9(%rip),%xmm4
mulss  0x14(%rsp),%xmm4
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm4,%xmm1
lea    0xdd8(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    12a8 <main+0x158>
jne    1294 <main+0x144>
jp     1294 <main+0x144>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xdcd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12a8 <main+0x158>
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
jbe    12a8 <main+0x158>
lea    0xdca(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter a, b, c values: \00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [26 x i8] c"root1 = %.2f\0Aroot2 = %.2f\00"
@.str.3 = [21 x i8] c"root1 = root2 = %.2f\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [33 x i8] c"Complex number, I forgot formula\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* %3, float* %4, float* %5)
%10 = load float, float* %4
%11 = call i32 @pow(float %10, i32 2)
%12 = sitofp i32 %11 to float
%13 = load float, float* %3
%14 = fmul float 4.000000e+00, %13
%15 = load float, float* %5
%16 = fneg float %14
%17 = call float @llvm.fmuladd.f32(float %16, float %15, float %12)
store float %17, float* %2
%18 = load float, float* %2
%19 = fcmp ogt float %18, 0.000000e+00
br i1 %19, label %20, label %42
20: ; preds = %0
%21 = load float, float* %4
%22 = fneg float %21
%23 = load float, float* %2
%24 = call float @sqrt(float %23)
%25 = fadd float %22, %24
%26 = fdiv float %25, 2.000000e+00
%27 = load float, float* %3
%28 = fmul float %26, %27
store float %28, float* %6
%29 = load float, float* %4
%30 = fneg float %29
%31 = load float, float* %2
%32 = call float @sqrt(float %31)
%33 = fsub float %30, %32
%34 = fdiv float %33, 2.000000e+00
%35 = load float, float* %3
%36 = fmul float %34, %35
store float %36, float* %7
%37 = load float, float* %6
%38 = fpext float %37 to double
%39 = load float, float* %7
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %38, double %40)
br label %59
42: ; preds = %0
%43 = load float, float* %2
%44 = fcmp oeq float %43, 0.000000e+00
br i1 %44, label %45, label %52
45: ; preds = %42
%46 = load float, float* %4
%47 = load float, float* %3
%48 = fdiv float %46, %47
store float %48, float* %7
store float %48, float* %6
%49 = load float, float* %6
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %50)
br label %58
52: ; preds = %42
%53 = load float, float* %2
%54 = fcmp olt float %53, 0.000000e+00
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %57
57: ; preds = %55, %52
br label %58
58: ; preds = %57, %45
br label %59
59: ; preds = %58, %20
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter a, b, c values: \00"
@.str.1 = [7 x i8] c"%f%f%f\00"
@.str.2 = [26 x i8] c"root1 = %.2f\0Aroot2 = %.2f\00"
@.str.3 = [21 x i8] c"root1 = root2 = %.2f\00"
@.str.5 = [33 x i8] c"Complex number, I forgot formula\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 ([23 x i8], [23 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 = call i32 @pow(float %9, i32 2)
%11 = sitofp i32 %10 to float
%12 = load float, float* %1
%13 = load float, float* %3
%14 = fmul float %12, -4.000000e+00
%15 = call float @llvm.fmuladd.f32(float %14, float %13, float %11)
%16 = fcmp ogt float %15, 0.000000e+00
br i1 %16, label %17, label %34
17: ; preds = %0
%18 = load float, float* %2
%19 = call float @sqrt(float %15)
%20 = fsub float %19, %18
%21 = fmul float %20, 5.000000e-01
%22 = load float, float* %1
%23 = fmul float %22, %21
%24 = load float, float* %2
%25 = fneg float %24
%26 = call float @sqrt(float %15)
%27 = fsub float %25, %26
%28 = fmul float %27, 5.000000e-01
%29 = load float, float* %1
%30 = fmul float %29, %28
%31 = fpext float %23 to double
%32 = fpext float %30 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %31, double %32)
br label %45
34: ; preds = %0
%35 = fcmp oeq float %15, 0.000000e+00
br i1 %35, label %36, label %41
36: ; preds = %34
%37 = load float, float* %2
%38 = fdiv float %37, %12
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %39)
br label %45
41: ; preds = %34
%42 = fcmp olt float %15, 0.000000e+00
br i1 %42, label %43, label %45
43: ; preds = %41
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %45
45: ; preds = %36, %43, %41, %17
ret i32 0
}