#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 sqrt(float);
void baskaras(float a, float b, float c) {
  float x1 = 0, x2 = 0, delta = 0, sqrdelta;
  if (a == 0) {
    printf("Nao e uma funcao do segundo grau. /n");
  } else {
    delta = (b * b) - 4 * a * c;
    sqrdelta = sqrt(delta);
    if (delta < 0) {
      printf("Nao ha raiz, pois delta menor do que 0 \n");
    } else if (delta == 0) {
      x1 = (-b + sqrdelta) / (2 * a);
      printf("x1 e x2 = %.2f \n", x1);
    } else {
      x1 = (-b + sqrdelta) / (2 * a);
      x2 = (-b - sqrdelta) / (2 * a);
      printf("x1 = %.2f \n", x1);
      printf("x2 = %.2f \n", x2);
    }
  }
}


x86 assembly (clang, -O0):
<baskaras>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1179 <baskaras+0x59>
jp     1179 <baskaras+0x59>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d0 <baskaras+0x1b0>
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
movss  0xe75(%rip),%xmm1
mulss  -0x4(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <sqrt@plt>
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11de <baskaras+0xbe>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cb <baskaras+0x1ab>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    123e <baskaras+0x11e>
jp     123e <baskaras+0x11e>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
addss  -0x1c(%rbp),%xmm0
movss  0xdf0(%rip),%xmm1
mulss  -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12c6 <baskaras+0x1a6>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
addss  -0x1c(%rbp),%xmm0
movss  0xda7(%rip),%xmm1
mulss  -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
subss  -0x1c(%rbp),%xmm0
movss  0xd7a(%rip),%xmm1
mulss  -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdbf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd9c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12cb <baskaras+0x1ab>
jmp    12d0 <baskaras+0x1b0>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<baskaras>:
sub    $0x38,%rsp
movaps %xmm0,%xmm4
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm4
jne    1153 <baskaras+0x23>
jp     1153 <baskaras+0x23>
lea    0xed8(%rip),%rdi
xor    %eax,%eax
add    $0x38,%rsp
jmp    1040 <printf@plt>
movss  0xea5(%rip),%xmm3
mulss  %xmm4,%xmm3
mulss  %xmm2,%xmm3
movaps %xmm1,%xmm5
mulss  %xmm1,%xmm5
addss  %xmm3,%xmm5
ucomiss %xmm0,%xmm5
jb     117c <baskaras+0x4c>
xorps  %xmm0,%xmm0
sqrtss %xmm5,%xmm0
jmp    11a4 <baskaras+0x74>
movaps %xmm5,%xmm0
movaps %xmm1,0x10(%rsp)
movss  %xmm4,0xc(%rsp)
movaps %xmm5,0x20(%rsp)
call   1050 <sqrt@plt>
movaps 0x20(%rsp),%xmm5
movss  0xc(%rsp),%xmm4
movaps 0x10(%rsp),%xmm1
xorps  %xmm2,%xmm2
ucomiss %xmm5,%xmm2
jbe    11bc <baskaras+0x8c>
lea    0xeaf(%rip),%rdi
add    $0x38,%rsp
jmp    1030 <puts@plt>
ucomiss %xmm2,%xmm5
jne    11dc <baskaras+0xac>
jp     11dc <baskaras+0xac>
subss  %xmm1,%xmm0
addss  %xmm4,%xmm4
divss  %xmm4,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6b(%rip),%rdi
jmp    1224 <baskaras+0xf4>
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
xorps  0xe26(%rip),%xmm1
addss  %xmm4,%xmm4
divss  %xmm4,%xmm2
subss  %xmm0,%xmm1
divss  %xmm4,%xmm1
movaps %xmm1,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe49(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movaps 0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe26(%rip),%rdi
mov    $0x1,%al
add    $0x38,%rsp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"Nao e uma funcao do segundo grau. /n\00"
@.str.1 = [41 x i8] c"Nao ha raiz, pois delta menor do que 0 \0A\00"
@.str.2 = [17 x i8] c"x1 e x2 = %.2f \0A\00"
@.str.3 = [12 x i8] c"x1 = %.2f \0A\00"
@.str.4 = [12 x i8] c"x2 = %.2f \0A\00"
define void @baskaras(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
store float 0.000000e+00, float* %7
store float 0.000000e+00, float* %8
store float 0.000000e+00, float* %9
%11 = load float, float* %4
%12 = fcmp oeq float %11, 0.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %67
15: ; preds = %3
%16 = load float, float* %5
%17 = load float, float* %5
%18 = load float, float* %4
%19 = fmul float 4.000000e+00, %18
%20 = load float, float* %6
%21 = fmul float %19, %20
%22 = fneg float %21
%23 = call float @llvm.fmuladd.f32(float %16, float %17, float %22)
store float %23, float* %9
%24 = load float, float* %9
%25 = call float @sqrt(float %24)
store float %25, float* %10
%26 = load float, float* %9
%27 = fcmp olt float %26, 0.000000e+00
br i1 %27, label %28, label %30
28: ; preds = %15
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %66
30: ; preds = %15
%31 = load float, float* %9
%32 = fcmp oeq float %31, 0.000000e+00
br i1 %32, label %33, label %44
33: ; preds = %30
%34 = load float, float* %5
%35 = fneg float %34
%36 = load float, float* %10
%37 = fadd float %35, %36
%38 = load float, float* %4
%39 = fmul float 2.000000e+00, %38
%40 = fdiv float %37, %39
store float %40, float* %7
%41 = load float, float* %7
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %42)
br label %65
44: ; preds = %30
%45 = load float, float* %5
%46 = fneg float %45
%47 = load float, float* %10
%48 = fadd float %46, %47
%49 = load float, float* %4
%50 = fmul float 2.000000e+00, %49
%51 = fdiv float %48, %50
store float %51, float* %7
%52 = load float, float* %5
%53 = fneg float %52
%54 = load float, float* %10
%55 = fsub float %53, %54
%56 = load float, float* %4
%57 = fmul float 2.000000e+00, %56
%58 = fdiv float %55, %57
store float %58, float* %8
%59 = load float, float* %7
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %60)
%62 = load float, float* %8
%63 = fpext float %62 to double
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %63)
br label %65
65: ; preds = %44, %33
br label %66
66: ; preds = %65, %28
br label %67
67: ; preds = %66, %13
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"Nao e uma funcao do segundo grau. /n\00"
@.str.2 = [17 x i8] c"x1 e x2 = %.2f \0A\00"
@.str.3 = [12 x i8] c"x1 = %.2f \0A\00"
@.str.4 = [12 x i8] c"x2 = %.2f \0A\00"
@str = [40 x i8] c"Nao ha raiz, pois delta menor do que 0 \00"
define void @baskaras(float %0, float %1, float %2) {
%4 = fcmp oeq float %0, 0.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %34
7: ; preds = %3
%8 = fmul float %0, -4.000000e+00
%9 = fmul float %8, %2
%10 = tail call float @llvm.fmuladd.f32(float %1, float %1, float %9)
%11 = tail call float @sqrt(float %10)
%12 = fcmp olt float %10, 0.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %34
15: ; preds = %7
%16 = fcmp oeq float %10, 0.000000e+00
br i1 %16, label %17, label %23
17: ; preds = %15
%18 = fsub float %11, %1
%19 = fmul float %0, 2.000000e+00
%20 = fdiv float %18, %19
%21 = fpext float %20 to double
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %21)
br label %34
23: ; preds = %15
%24 = fneg float %1
%25 = fsub float %11, %1
%26 = fmul float %0, 2.000000e+00
%27 = fdiv float %25, %26
%28 = fsub float %24, %11
%29 = fdiv float %28, %26
%30 = fpext float %27 to double
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %30)
%32 = fpext float %29 to double
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %32)
br label %34
34: ; preds = %13, %23, %17, %5
ret void
}