#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 *, ...);
double sqrt(double);
void segon_grau(double a, double b, double c) {
  double delta = b * b - 4 * a * c;
  double x1 = 0;
  double x2 = 0;
  if (delta >= 0) {
    x1 = (-b + sqrt(delta)) / (2 * a);
    x2 = (-b - sqrt(delta)) / (2 * a);
    printf("x1 = %+.15lf; x2 = %+.15lf\n", x1, x2);
    printf("--\nIgualtats teoriques\n");
    printf("x1 + x2 = %+.15lf; -b/a = %+.15lf\n", x1 + x2, -b / a);
    printf("x1·x2 = %+.15lf; c/a = %+.15lf\n", x1 * x2, c / a);
  } else {
    printf("L'equacio no te arrels reals\n");
  }
}


x86 assembly (clang, -O0):
<segon_grau>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xeb7(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12b9 <segon_grau+0x199>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xe30(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  0xde3(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xdcc(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
divsd  -0x8(%rbp),%xmm1
lea    0xdb9(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
divsd  -0x8(%rbp),%xmm1
lea    0xdba(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12c7 <segon_grau+0x1a7>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<segon_grau>:
sub    $0x68,%rsp
movapd %xmm0,%xmm3
movsd  0xec0(%rip),%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm0
movapd %xmm1,%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm0,%xmm4
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm4
jae    116e <segon_grau+0x3e>
lea    0xf1b(%rip),%rdi
add    $0x68,%rsp
jmp    1030 <puts@plt>
movsd  %xmm2,0x48(%rsp)
movapd 0xe94(%rip),%xmm2
xorpd  %xmm1,%xmm2
movapd %xmm2,0x50(%rsp)
sqrtsd %xmm4,%xmm5
ucomisd %xmm0,%xmm4
movapd %xmm5,%xmm2
movsd  %xmm3,0x8(%rsp)
movapd %xmm1,0x20(%rsp)
jae    11d1 <segon_grau+0xa1>
movapd %xmm4,%xmm0
movapd %xmm4,0x10(%rsp)
movapd %xmm5,0x30(%rsp)
call   1050 <sqrt@plt>
movapd 0x30(%rsp),%xmm5
movapd 0x10(%rsp),%xmm4
movapd 0x20(%rsp),%xmm1
movsd  0x8(%rsp),%xmm3
movapd %xmm0,%xmm2
addsd  %xmm3,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm4
jae    120a <segon_grau+0xda>
movapd %xmm4,%xmm0
movapd %xmm2,0x10(%rsp)
movapd %xmm3,0x30(%rsp)
call   1050 <sqrt@plt>
movapd 0x30(%rsp),%xmm3
movapd 0x20(%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
movapd %xmm0,%xmm5
unpcklpd 0x50(%rsp),%xmm2
unpcklpd %xmm5,%xmm1
subpd  %xmm1,%xmm2
unpcklpd %xmm3,%xmm3
divpd  %xmm3,%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
movapd %xmm1,0x20(%rsp)
lea    0xde5(%rip),%rdi
movapd %xmm2,%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
movapd 0x10(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movapd 0x50(%rsp),%xmm1
divsd  0x8(%rsp),%xmm1
lea    0xdcb(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movapd 0x20(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
divsd  0x8(%rsp),%xmm1
lea    0xdc8(%rip),%rdi
mov    $0x2,%al
add    $0x68,%rsp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"x1 = %+.15lf; x2 = %+.15lf\0A\00"
@.str.1 = [24 x i8] c"--\0AIgualtats teoriques\0A\00"
@.str.2 = [35 x i8] c"x1 + x2 = %+.15lf; -b/a = %+.15lf\0A\00"
@.str.3 = [33 x i8] c"x1\C2\B7x2 = %+.15lf; c/a = %+.15lf\0A\00"
@.str.4 = [30 x i8] c"L'equacio no te arrels reals\0A\00"
define void @segon_grau(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%10 = load double, double* %5
%11 = load double, double* %5
%12 = load double, double* %4
%13 = fmul double 4.000000e+00, %12
%14 = load double, double* %6
%15 = fmul double %13, %14
%16 = fneg double %15
%17 = call double @llvm.fmuladd.f64(double %10, double %11, double %16)
store double %17, double* %7
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %9
%18 = load double, double* %7
%19 = fcmp oge double %18, 0.000000e+00
br i1 %19, label %20, label %56
20: ; preds = %3
%21 = load double, double* %5
%22 = fneg double %21
%23 = load double, double* %7
%24 = call double @sqrt(double %23)
%25 = fadd double %22, %24
%26 = load double, double* %4
%27 = fmul double 2.000000e+00, %26
%28 = fdiv double %25, %27
store double %28, double* %8
%29 = load double, double* %5
%30 = fneg double %29
%31 = load double, double* %7
%32 = call double @sqrt(double %31)
%33 = fsub double %30, %32
%34 = load double, double* %4
%35 = fmul double 2.000000e+00, %34
%36 = fdiv double %33, %35
store double %36, double* %9
%37 = load double, double* %8
%38 = load double, double* %9
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %37, double %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%41 = load double, double* %8
%42 = load double, double* %9
%43 = fadd double %41, %42
%44 = load double, double* %5
%45 = fneg double %44
%46 = load double, double* %4
%47 = fdiv double %45, %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), double %43, double %47)
%49 = load double, double* %8
%50 = load double, double* %9
%51 = fmul double %49, %50
%52 = load double, double* %6
%53 = load double, double* %4
%54 = fdiv double %52, %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %51, double %54)
br label %58
56: ; preds = %3
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %56, %20
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"x1 = %+.15lf; x2 = %+.15lf\0A\00"
@.str.2 = [35 x i8] c"x1 + x2 = %+.15lf; -b/a = %+.15lf\0A\00"
@.str.3 = [33 x i8] c"x1\C2\B7x2 = %+.15lf; c/a = %+.15lf\0A\00"
@str = [29 x i8] c"L'equacio no te arrels reals\00"
@str.5 = [23 x i8] c"--\0AIgualtats teoriques\00"
define void @segon_grau(double %0, double %1, double %2) {
%4 = fmul double %0, -4.000000e+00
%5 = fmul double %4, %2
%6 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %5)
%7 = fcmp ult double %6, 0.000000e+00
br i1 %7, label %31, label %8
8: ; preds = %3
%9 = fneg double %1
%10 = tail call double @sqrt(double %6)
%11 = fmul double %0, 2.000000e+00
%12 = tail call double @sqrt(double %6)
%13 = insertelement <2 x double> poison, double %10, i64 0
%14 = insertelement <2 x double> %13, double %9, i64 1
%15 = insertelement <2 x double> poison, double %1, i64 0
%16 = insertelement <2 x double> %15, double %12, i64 1
%17 = fsub <2 x double> %14, %16
%18 = insertelement <2 x double> poison, double %11, i64 0
%19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
%20 = fdiv <2 x double> %17, %19
%21 = extractelement <2 x double> %20, i64 0
%22 = extractelement <2 x double> %20, i64 1
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %21, double %22)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%25 = fadd double %21, %22
%26 = fdiv double %9, %0
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), double %25, double %26)
%28 = fmul double %21, %22
%29 = fdiv double %2, %0
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %28, double %29)
br label %33
31: ; preds = %3
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %33
33: ; preds = %31, %8
ret void
}