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


x86 assembly (clang, -O0):
<bhaskara>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1161 <bhaskara+0x41>
jp     1161 <bhaskara+0x41>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12eb <bhaskara+0x1cb>
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,-0x1c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    11b7 <bhaskara+0x97>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e6 <bhaskara+0x1c6>
movss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    122d <bhaskara+0x10d>
jp     122d <bhaskara+0x10d>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  0xe01(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe35(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12e1 <bhaskara+0x1c1>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  0xda2(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  0xd5f(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd81(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12e6 <bhaskara+0x1c6>
jmp    12eb <bhaskara+0x1cb>
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bhaskara>:
sub    $0x48,%rsp
movaps %xmm0,%xmm3
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm3
jne    1154 <bhaskara+0x24>
jp     1154 <bhaskara+0x24>
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x48,%rsp
ret
movss  0xea4(%rip),%xmm4
mulss  %xmm3,%xmm4
mulss  %xmm2,%xmm4
movaps %xmm1,%xmm5
mulss  %xmm1,%xmm5
addss  %xmm4,%xmm5
ucomiss %xmm5,%xmm0
jbe    1185 <bhaskara+0x55>
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
add    $0x48,%rsp
ret
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm5
jne    11a1 <bhaskara+0x71>
jp     11a1 <bhaskara+0x71>
jb     1266 <bhaskara+0x136>
xorps  %xmm0,%xmm0
sqrtss %xmm5,%xmm0
jmp    1284 <bhaskara+0x154>
movaps 0xe68(%rip),%xmm2
xorps  %xmm1,%xmm2
movaps %xmm2,0x20(%rsp)
xorps  %xmm4,%xmm4
sqrtss %xmm5,%xmm4
ucomiss %xmm0,%xmm5
movaps %xmm4,%xmm2
jae    11f6 <bhaskara+0xc6>
movaps %xmm5,%xmm0
movss  %xmm3,0x8(%rsp)
movaps %xmm1,0x10(%rsp)
movaps %xmm5,0x30(%rsp)
movss  %xmm4,0xc(%rsp)
call   1050 <sqrt@plt>
movss  0xc(%rsp),%xmm4
movaps 0x30(%rsp),%xmm5
movaps 0x10(%rsp),%xmm1
movss  0x8(%rsp),%xmm3
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
addss  %xmm3,%xmm3
divss  %xmm3,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm5
jae    122d <bhaskara+0xfd>
movaps %xmm5,%xmm0
movss  %xmm3,0x8(%rsp)
movss  %xmm2,0x10(%rsp)
call   1050 <sqrt@plt>
movss  0x10(%rsp),%xmm2
movss  0x8(%rsp),%xmm3
movaps %xmm0,%xmm4
movaps 0x20(%rsp),%xmm0
subss  %xmm4,%xmm0
divss  %xmm3,%xmm0
movaps %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xe09(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movaps 0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde6(%rip),%rdi
jmp    129b <bhaskara+0x16b>
movaps %xmm5,%xmm0
movss  %xmm3,0x8(%rsp)
movaps %xmm1,0x10(%rsp)
call   1050 <sqrt@plt>
movaps 0x10(%rsp),%xmm1
movss  0x8(%rsp),%xmm3
subss  %xmm1,%xmm0
addss  %xmm3,%xmm3
divss  %xmm3,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdaa(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x48,%rsp
ret

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 float @bhaskara(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* %5
store float %1, float* %6
store float %2, float* %7
%11 = load float, float* %5
%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 %68
15: ; preds = %3
%16 = load float, float* %6
%17 = load float, float* %6
%18 = load float, float* %5
%19 = fmul float 4.000000e+00, %18
%20 = load float, float* %7
%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* %10
%24 = load float, float* %10
%25 = fcmp olt float %24, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %15
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %67
28: ; preds = %15
%29 = load float, float* %10
%30 = fcmp oeq float %29, 0.000000e+00
br i1 %30, label %31, label %43
31: ; preds = %28
%32 = load float, float* %6
%33 = fneg float %32
%34 = load float, float* %10
%35 = call float @sqrt(float %34)
%36 = fadd float %33, %35
%37 = load float, float* %5
%38 = fmul float 2.000000e+00, %37
%39 = fdiv float %36, %38
store float %39, float* %8
%40 = load float, float* %8
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %41)
br label %66
43: ; preds = %28
%44 = load float, float* %6
%45 = fneg float %44
%46 = load float, float* %10
%47 = call float @sqrt(float %46)
%48 = fadd float %45, %47
%49 = load float, float* %5
%50 = fmul float 2.000000e+00, %49
%51 = fdiv float %48, %50
store float %51, float* %8
%52 = load float, float* %6
%53 = fneg float %52
%54 = load float, float* %10
%55 = call float @sqrt(float %54)
%56 = fsub float %53, %55
%57 = load float, float* %5
%58 = fmul float 2.000000e+00, %57
%59 = fdiv float %56, %58
store float %59, float* %9
%60 = load float, float* %8
%61 = fpext float %60 to double
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %61)
%63 = load float, float* %9
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %64)
br label %66
66: ; preds = %43, %31
br label %67
67: ; preds = %66, %26
br label %68
68: ; preds = %67, %13
%69 = load float, float* %4
ret float %69
}

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 float @bhaskara(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 %36
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 = fcmp olt float %10, 0.000000e+00
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %36
14: ; preds = %7
%15 = fcmp oeq float %10, 0.000000e+00
br i1 %15, label %16, label %23
16: ; preds = %14
%17 = tail call float @sqrt(float %10)
%18 = fsub float %17, %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 %36
23: ; preds = %14
%24 = fneg float %1
%25 = tail call float @sqrt(float %10)
%26 = fsub float %25, %1
%27 = fmul float %0, 2.000000e+00
%28 = fdiv float %26, %27
%29 = tail call float @sqrt(float %10)
%30 = fsub float %24, %29
%31 = fdiv float %30, %27
%32 = fpext float %28 to double
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %32)
%34 = fpext float %31 to double
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %34)
br label %36
36: ; preds = %12, %23, %16, %5
ret float undef
}