#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 */
double abs(float);
float sqrt(float);
float tottime(float v0, float a, float d) {
  return (abs(v0) -
          sqrt((v0 * v0 - 2.0 * a * abs(d) > 0 ? v0 * v0 - 2.0 * a * abs(d)
                                               : 0))) /
         a;
}


x86 assembly (clang, -O0):
<tottime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <abs@plt>
movsd  %xmm0,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe96(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <abs@plt>
movsd  -0x20(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1223 <tottime+0x103>
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe26(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <abs@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1230 <tottime+0x110>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1230 <tottime+0x110>
movsd  -0x30(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
cvtss2sd %xmm1,%xmm1
subsd  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tottime>:
sub    $0x28,%rsp
movss  %xmm2,0x10(%rsp)
movss  %xmm1,0x18(%rsp)
movss  %xmm0,0x8(%rsp)
call   1030 <abs@plt>
movsd  %xmm0,0x20(%rsp)
movss  0x8(%rsp),%xmm0
mulss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movss  0x18(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <abs@plt>
movsd  0xe88(%rip),%xmm2
mulsd  0x18(%rsp),%xmm2
mulsd  %xmm2,%xmm0
addsd  0x8(%rsp),%xmm0
xorps  %xmm3,%xmm3
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
xorpd  %xmm0,%xmm0
jbe    11c4 <tottime+0xa4>
movss  0x10(%rsp),%xmm0
movsd  %xmm2,0x10(%rsp)
call   1030 <abs@plt>
xorps  %xmm3,%xmm3
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
ucomiss %xmm3,%xmm0
jb     11cf <tottime+0xaf>
sqrtss %xmm0,%xmm0
jmp    11d4 <tottime+0xb4>
call   1040 <sqrt@plt>
cvtss2sd %xmm0,%xmm0
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
divsd  0x18(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define float @tottime(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%7 = load float, float* %4
%8 = call double @abs(float %7)
%9 = load float, float* %4
%10 = load float, float* %4
%11 = fmul float %9, %10
%12 = fpext float %11 to double
%13 = load float, float* %5
%14 = fpext float %13 to double
%15 = fmul double 2.000000e+00, %14
%16 = load float, float* %6
%17 = call double @abs(float %16)
%18 = fneg double %15
%19 = call double @llvm.fmuladd.f64(double %18, double %17, double %12)
%20 = fcmp ogt double %19, 0.000000e+00
br i1 %20, label %21, label %33
21: ; preds = %3
%22 = load float, float* %4
%23 = load float, float* %4
%24 = fmul float %22, %23
%25 = fpext float %24 to double
%26 = load float, float* %5
%27 = fpext float %26 to double
%28 = fmul double 2.000000e+00, %27
%29 = load float, float* %6
%30 = call double @abs(float %29)
%31 = fneg double %28
%32 = call double @llvm.fmuladd.f64(double %31, double %30, double %25)
br label %34
33: ; preds = %3
br label %34
34: ; preds = %33, %21
%35 = phi double [ %32, %21 ], [ 0.000000e+00, %33 ]
%36 = fptrunc double %35 to float
%37 = call float @sqrt(float %36)
%38 = fpext float %37 to double
%39 = fsub double %8, %38
%40 = load float, float* %5
%41 = fpext float %40 to double
%42 = fdiv double %39, %41
%43 = fptrunc double %42 to float
ret float %43
}

LLVM IR (-O2):
define float @tottime(float %0, float %1, float %2) {
%4 = tail call double @abs(float %0)
%5 = fmul float %0, %0
%6 = fpext float %5 to double
%7 = fpext float %1 to double
%8 = tail call double @abs(float %2)
%9 = fmul double %7, -2.000000e+00
%10 = tail call double @llvm.fmuladd.f64(double %9, double %8, double %6)
%11 = fcmp ogt double %10, 0.000000e+00
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = tail call double @abs(float %2)
%14 = tail call double @llvm.fmuladd.f64(double %9, double %13, double %6)
%15 = fptrunc double %14 to float
br label %16
16: ; preds = %3, %12
%17 = phi float [ %15, %12 ], [ 0.000000e+00, %3 ]
%18 = tail call float @sqrt(float %17)
%19 = fpext float %18 to double
%20 = fsub double %4, %19
%21 = fdiv double %20, %7
%22 = fptrunc double %21 to float
ret float %22
}