#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 sqrt(float);
int main() {
  float ca, cb, cc, delta, raiz_delta, x1, x2;
  printf("Calcula equação do 2o grau: ax² + bx + c = 0\n");
  printf("Digite o valor de a: ");
  scanf("%f", &ca);
  printf("Digite o valor de b: ");
  scanf("%f", &cb);
  printf("Digite o valor de c: ");
  scanf("%f", &cc);
  if (ca != 0) {
    delta = (cb * cb) - (4 * ca * cc);
    raiz_delta = sqrt(delta);
    if (delta > 0) {
      x1 = (-cb + raiz_delta) / (2 * ca);
      x2 = (-cb - raiz_delta) / (2 * ca);
      printf("Raízes da equação: \n x1 = %.2f \n x2 = %.2f", x1, x2);
    } else if (delta == 0) {
      printf("Raiz única! x1 e x2: %.2f", x1);
    } else {
      printf("Não existe raiz real! Delta menor que zero.");
    }
  } else {
    printf("Não é uma equação de 2o grau!");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c3 <main+0x93>
jp     11c3 <main+0x93>
jmp    12e3 <main+0x1b3>
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  0xe2b(%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  -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1298 <main+0x168>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
addss  -0x18(%rbp),%xmm0
movss  0xdcc(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
subss  -0x18(%rbp),%xmm0
movss  0xd9f(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdf2(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12de <main+0x1ae>
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    12cb <main+0x19b>
jp     12cb <main+0x19b>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xded(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12d9 <main+0x1a9>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12de <main+0x1ae>
jmp    12f1 <main+0x1c1>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xfb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed0(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    11b7 <main+0x77>
jnp    11e0 <main+0xa0>
movss  (%rsp),%xmm2
mulss  0xe3c(%rip),%xmm1
mulss  0xc(%rsp),%xmm1
mulss  %xmm2,%xmm2
addss  %xmm1,%xmm2
ucomiss %xmm0,%xmm2
jb     11e9 <main+0xa9>
xorps  %xmm0,%xmm0
sqrtss %xmm2,%xmm0
jmp    11fd <main+0xbd>
lea    0xef4(%rip),%rdi
jmp    1264 <main+0x124>
movaps %xmm2,%xmm0
movss  %xmm2,0x8(%rsp)
call   1060 <sqrt@plt>
movss  0x8(%rsp),%xmm2
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm2
jbe    1249 <main+0x109>
movss  (%rsp),%xmm1
movaps 0xdff(%rip),%xmm2
xorps  %xmm1,%xmm2
subss  %xmm0,%xmm2
subss  %xmm1,%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm1,%xmm1
divss  %xmm1,%xmm0
divss  %xmm1,%xmm2
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
lea    0xe25(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    126b <main+0x12b>
jne    125d <main+0x11d>
jp     125d <main+0x11d>
lea    0xe3f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    126b <main+0x12b>
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Calcula equa\C3\A7\C3\A3o do 2o grau: ax\C2\B2 + bx + c = 0\0A\00"
@.str.1 = [22 x i8] c"Digite o valor de a: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [22 x i8] c"Digite o valor de b: \00"
@.str.4 = [22 x i8] c"Digite o valor de c: \00"
@.str.5 = [46 x i8] c"Ra\C3\ADzes da equa\C3\A7\C3\A3o: \0A x1 = %.2f \0A x2 = %.2f\00"
@.str.6 = [27 x i8] c"Raiz \C3\BAnica! x1 e x2: %.2f\00"
@.str.7 = [45 x i8] c"N\C3\A3o existe raiz real! Delta menor que zero.\00"
@.str.8 = [34 x i8] c"N\C3\A3o \C3\A9 uma equa\C3\A7\C3\A3o de 2o grau!\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
%8 = alloca float
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
%16 = load float, float* %2
%17 = fcmp une float %16, 0.000000e+00
br i1 %17, label %18, label %62
18: ; preds = %0
%19 = load float, float* %3
%20 = load float, float* %3
%21 = load float, float* %2
%22 = fmul float 4.000000e+00, %21
%23 = load float, float* %4
%24 = fmul float %22, %23
%25 = fneg float %24
%26 = call float @llvm.fmuladd.f32(float %19, float %20, float %25)
store float %26, float* %5
%27 = load float, float* %5
%28 = call float @sqrt(float %27)
store float %28, float* %6
%29 = load float, float* %5
%30 = fcmp ogt float %29, 0.000000e+00
br i1 %30, label %31, label %51
31: ; preds = %18
%32 = load float, float* %3
%33 = fneg float %32
%34 = load float, float* %6
%35 = fadd float %33, %34
%36 = load float, float* %2
%37 = fmul float 2.000000e+00, %36
%38 = fdiv float %35, %37
store float %38, float* %7
%39 = load float, float* %3
%40 = fneg float %39
%41 = load float, float* %6
%42 = fsub float %40, %41
%43 = load float, float* %2
%44 = fmul float 2.000000e+00, %43
%45 = fdiv float %42, %44
store float %45, float* %8
%46 = load float, float* %7
%47 = fpext float %46 to double
%48 = load float, float* %8
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), double %47, double %49)
br label %61
51: ; preds = %18
%52 = load float, float* %5
%53 = fcmp oeq float %52, 0.000000e+00
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load float, float* %7
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %56)
br label %60
58: ; preds = %51
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
br label %60
60: ; preds = %58, %54
br label %61
61: ; preds = %60, %31
br label %64
62: ; preds = %0
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
br label %64
64: ; preds = %62, %61
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"Digite o valor de a: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [22 x i8] c"Digite o valor de b: \00"
@.str.4 = [22 x i8] c"Digite o valor de c: \00"
@.str.5 = [46 x i8] c"Ra\C3\ADzes da equa\C3\A7\C3\A3o: \0A x1 = %.2f \0A x2 = %.2f\00"
@.str.6 = [27 x i8] c"Raiz \C3\BAnica! x1 e x2: %.2f\00"
@.str.7 = [45 x i8] c"N\C3\A3o existe raiz real! Delta menor que zero.\00"
@.str.8 = [34 x i8] c"N\C3\A3o \C3\A9 uma equa\C3\A7\C3\A3o de 2o grau!\00"
@str = [48 x i8] c"Calcula equa\C3\A7\C3\A3o do 2o grau: ax\C2\B2 + bx + c = 0\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 ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%14 = load float, float* %1
%15 = fcmp une float %14, 0.000000e+00
br i1 %15, label %16, label %42
16: ; preds = %0
%17 = load float, float* %2
%18 = load float, float* %3
%19 = fmul float %14, -4.000000e+00
%20 = fmul float %19, %18
%21 = call float @llvm.fmuladd.f32(float %17, float %17, float %20)
%22 = call float @sqrt(float %21)
%23 = fcmp ogt float %21, 0.000000e+00
br i1 %23, label %24, label %36
24: ; preds = %16
%25 = load float, float* %2
%26 = fneg float %25
%27 = fsub float %22, %25
%28 = load float, float* %1
%29 = fmul float %28, 2.000000e+00
%30 = fdiv float %27, %29
%31 = fsub float %26, %22
%32 = fdiv float %31, %29
%33 = fpext float %30 to double
%34 = fpext float %32 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), double %33, double %34)
br label %44
36: ; preds = %16
%37 = fcmp oeq float %21, 0.000000e+00
br i1 %37, label %38, label %40
38: ; preds = %36
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double undef)
br label %44
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
br label %44
42: ; preds = %0
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
br label %44
44: ; preds = %24, %40, %38, %42
ret i32 0
}