#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 */
float LIMAT_MAX(float, float);
float sqrtf(float);
int limat_quadratic_solve_maxroot(float a, float b, float c, float *X) {
  float X1;
  float X2;
  float det = b * b - 4.0f * a * c;
  if (det >= 0.0f)
    return 0;
  det = sqrtf(det);
  X1 = (-b - det) / (2.0f * a);
  X2 = (-b + det) / (2.0f * a);
  *X = LIMAT_MAX(X1, X2);
  return 1;
}


x86 assembly (clang, -O0):
<limat_quadratic_solve_maxroot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  0xeb3(%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,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     118e <limat_quadratic_solve_maxroot+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    1215 <limat_quadratic_solve_maxroot+0xf5>
movss  -0x24(%rbp),%xmm0
call   1040 <sqrtf@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
subss  -0x24(%rbp),%xmm0
movss  0xe48(%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
addss  -0x24(%rbp),%xmm0
movss  0xe1b(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
call   1030 <LIMAT_MAX@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<limat_quadratic_solve_maxroot>:
push   %rbx
sub    $0x20,%rsp
movaps %xmm1,%xmm4
movaps %xmm0,%xmm3
movss  0xecd(%rip),%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm2,%xmm1
movaps %xmm4,%xmm0
mulss  %xmm4,%xmm0
addss  %xmm1,%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jae    11a8 <limat_quadratic_solve_maxroot+0x88>
mov    %rdi,%rbx
jb     115e <limat_quadratic_solve_maxroot+0x3e>
xorps  %xmm1,%xmm1
sqrtss %xmm0,%xmm1
jmp    117c <limat_quadratic_solve_maxroot+0x5c>
movss  %xmm3,0xc(%rsp)
movaps %xmm4,0x10(%rsp)
call   1040 <sqrtf@plt>
movaps 0x10(%rsp),%xmm4
movss  0xc(%rsp),%xmm3
movaps %xmm0,%xmm1
movaps 0xe8d(%rip),%xmm0
xorps  %xmm4,%xmm0
subss  %xmm1,%xmm0
addss  %xmm3,%xmm3
divss  %xmm3,%xmm0
subss  %xmm4,%xmm1
divss  %xmm3,%xmm1
call   1030 <LIMAT_MAX@plt>
movss  %xmm0,(%rbx)
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @limat_quadratic_solve_maxroot(float %0, float %1, float %2, float* %3) {
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float*
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
store float* %3, float** %9
%13 = load float, float* %7
%14 = load float, float* %7
%15 = load float, float* %6
%16 = fmul float 4.000000e+00, %15
%17 = load float, float* %8
%18 = fmul float %16, %17
%19 = fneg float %18
%20 = call float @llvm.fmuladd.f32(float %13, float %14, float %19)
store float %20, float* %12
%21 = load float, float* %12
%22 = fcmp oge float %21, 0.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %4
store i32 0, i32* %5
br label %45
24: ; preds = %4
%25 = load float, float* %12
%26 = call float @sqrtf(float %25)
store float %26, float* %12
%27 = load float, float* %7
%28 = fneg float %27
%29 = load float, float* %12
%30 = fsub float %28, %29
%31 = load float, float* %6
%32 = fmul float 2.000000e+00, %31
%33 = fdiv float %30, %32
store float %33, float* %10
%34 = load float, float* %7
%35 = fneg float %34
%36 = load float, float* %12
%37 = fadd float %35, %36
%38 = load float, float* %6
%39 = fmul float 2.000000e+00, %38
%40 = fdiv float %37, %39
store float %40, float* %11
%41 = load float, float* %10
%42 = load float, float* %11
%43 = call float @LIMAT_MAX(float %41, float %42)
%44 = load float*, float** %9
store float %43, float* %44
store i32 1, i32* %5
br label %45
45: ; preds = %24, %23
%46 = load i32, i32* %5
ret i32 %46
}

LLVM IR (-O2):
define i32 @limat_quadratic_solve_maxroot(float %0, float %1, float %2, float* nocapture writeonly %3) {
%5 = fmul float %0, -4.000000e+00
%6 = fmul float %5, %2
%7 = tail call float @llvm.fmuladd.f32(float %1, float %1, float %6)
%8 = fcmp ult float %7, 0.000000e+00
br i1 %8, label %9, label %18
9: ; preds = %4
%10 = tail call float @sqrtf(float %7)
%11 = fneg float %1
%12 = fsub float %11, %10
%13 = fmul float %0, 2.000000e+00
%14 = fdiv float %12, %13
%15 = fsub float %10, %1
%16 = fdiv float %15, %13
%17 = tail call float @LIMAT_MAX(float %14, float %16)
store float %17, float* %3
br label %18
18: ; preds = %4, %9
%19 = phi i32 [ 1, %9 ], [ 0, %4 ]
ret i32 %19
}