#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 sqrt(double);
double bslipds_event_scan(double t, double *Y, int n, double *pars,
                          double *res) {
  double l;
  double xr, zr;
  xr = Y[0] - pars[13];
  zr = Y[2] - pars[15];
  l = sqrt(xr * xr + Y[1] * Y[1] + zr * zr);
  if (pars[16] == 1.) {
    *res = l - pars[5];
  } else {
    *res = l - pars[4];
  }
}


x86 assembly (clang, -O0):
<bslipds_event_scan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
subsd  0x68(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x28(%rbp),%rax
subsd  0x78(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movsd  0x80(%rax),%xmm0
movsd  0xe53(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11d8 <bslipds_event_scan+0xc8>
jp     11d8 <bslipds_event_scan+0xc8>
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
subsd  0x28(%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11ee <bslipds_event_scan+0xde>
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
subsd  0x20(%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bslipds_event_scan>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
movsd  (%rdi),%xmm1
subsd  0x68(%rdx),%xmm1
movsd  0x8(%rdi),%xmm2
movsd  0x10(%rdi),%xmm0
subsd  0x78(%rdx),%xmm0
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1156 <bslipds_event_scan+0x46>
sqrtsd %xmm0,%xmm0
jmp    115b <bslipds_event_scan+0x4b>
call   1030 <sqrt@plt>
movsd  0xe9d(%rip),%xmm1
cmpeqsd 0x80(%rbx),%xmm1
movq   %xmm1,%rax
and    $0x1,%eax
subsd  0x20(%rbx,%rax,8),%xmm0
movsd  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @bslipds_event_scan(double %0, double* %1, i32 %2, double* %3, double* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double %0, double* %7
store double* %1, double** %8
store i32 %2, i32* %9
store double* %3, double** %10
store double* %4, double** %11
%15 = load double*, double** %8
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = load double*, double** %10
%19 = getelementptr inbounds double, double* %18, i64 13
%20 = load double, double* %19
%21 = fsub double %17, %20
store double %21, double* %13
%22 = load double*, double** %8
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = load double*, double** %10
%26 = getelementptr inbounds double, double* %25, i64 15
%27 = load double, double* %26
%28 = fsub double %24, %27
store double %28, double* %14
%29 = load double, double* %13
%30 = load double, double* %13
%31 = load double*, double** %8
%32 = getelementptr inbounds double, double* %31, i64 1
%33 = load double, double* %32
%34 = load double*, double** %8
%35 = getelementptr inbounds double, double* %34, i64 1
%36 = load double, double* %35
%37 = fmul double %33, %36
%38 = call double @llvm.fmuladd.f64(double %29, double %30, double %37)
%39 = load double, double* %14
%40 = load double, double* %14
%41 = call double @llvm.fmuladd.f64(double %39, double %40, double %38)
%42 = call double @sqrt(double %41)
store double %42, double* %12
%43 = load double*, double** %10
%44 = getelementptr inbounds double, double* %43, i64 16
%45 = load double, double* %44
%46 = fcmp oeq double %45, 1.000000e+00
br i1 %46, label %47, label %54
47: ; preds = %5
%48 = load double, double* %12
%49 = load double*, double** %10
%50 = getelementptr inbounds double, double* %49, i64 5
%51 = load double, double* %50
%52 = fsub double %48, %51
%53 = load double*, double** %11
store double %52, double* %53
br label %61
54: ; preds = %5
%55 = load double, double* %12
%56 = load double*, double** %10
%57 = getelementptr inbounds double, double* %56, i64 4
%58 = load double, double* %57
%59 = fsub double %55, %58
%60 = load double*, double** %11
store double %59, double* %60
br label %61
61: ; preds = %54, %47
%62 = load double, double* %6
ret double %62
}

LLVM IR (-O2):
define double @bslipds_event_scan(double %0, double* nocapture %1, i32 %2, double* nocapture %3, double* nocapture writeonly %4) {
%6 = load double, double* %1
%7 = getelementptr inbounds double, double* %3, i64 13
%8 = load double, double* %7
%9 = fsub double %6, %8
%10 = getelementptr inbounds double, double* %1, i64 2
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %3, i64 15
%13 = load double, double* %12
%14 = fsub double %11, %13
%15 = getelementptr inbounds double, double* %1, i64 1
%16 = load double, double* %15
%17 = fmul double %16, %16
%18 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %17)
%19 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %18)
%20 = tail call double @sqrt(double %19)
%21 = getelementptr inbounds double, double* %3, i64 16
%22 = load double, double* %21
%23 = fcmp oeq double %22, 1.000000e+00
%24 = select i1 %23, i64 5, i64 4
%25 = getelementptr inbounds double, double* %3, i64 %24
%26 = load double, double* %25
%27 = fsub double %20, %26
store double %27, double* %4
ret double undef
}