#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 veclen(double *);
double distance_ab(double **o3_p, long ia, long ib, long ipa, long ipb) {
  double dist = -1.0, txyz[4];
  long i;
  if (o3_p[ia][ipa] > 0.0 && o3_p[ib][ipb] > 0.0) {
    for (i = 1; i <= 3; i++)
      txyz[i] = o3_p[ia][ipa - 4 + i] - o3_p[ib][ipb - 4 + i];
    dist = veclen(txyz);
  }
  return dist;
}


x86 assembly (clang, -O0):
<distance_ab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  0xecc(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11f3 <distance_ab+0xe3>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11f3 <distance_ab+0xe3>
movq   $0x1,-0x58(%rbp)
cmpq   $0x3,-0x58(%rbp)
jg     11e5 <distance_ab+0xd5>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%rcx
sub    $0x4,%rcx
add    -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%rcx
sub    $0x4,%rcx
add    -0x58(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1185 <distance_ab+0x75>
lea    -0x50(%rbp),%rdi
call   1030 <veclen@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distance_ab>:
sub    $0x28,%rsp
mov    (%rdi,%rsi,8),%rax
movsd  (%rax,%rcx,8),%xmm2
movsd  0xedb(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jbe    1180 <distance_ab+0x70>
mov    (%rdi,%rdx,8),%rdx
movsd  (%rdx,%r8,8),%xmm2
ucomisd %xmm1,%xmm2
jbe    1180 <distance_ab+0x70>
movsd  -0x18(%rax,%rcx,8),%xmm0
subsd  -0x18(%rdx,%r8,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  -0x10(%rax,%rcx,8),%xmm0
subsd  -0x10(%rdx,%r8,8),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  -0x8(%rax,%rcx,8),%xmm0
subsd  -0x8(%rdx,%r8,8),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %rsp,%rdi
call   1030 <veclen@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @distance_ab(double** %0, i64 %1, i64 %2, i64 %3, i64 %4) {
%6 = alloca double**
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca double
%12 = alloca [4 x double]
%13 = alloca i64
store double** %0, double*** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i64 %4, i64* %10
store double -1.000000e+00, double* %11
%14 = load double**, double*** %6
%15 = load i64, i64* %7
%16 = getelementptr inbounds double*, double** %14, i64 %15
%17 = load double*, double** %16
%18 = load i64, i64* %9
%19 = getelementptr inbounds double, double* %17, i64 %18
%20 = load double, double* %19
%21 = fcmp ogt double %20, 0.000000e+00
br i1 %21, label %22, label %65
22: ; preds = %5
%23 = load double**, double*** %6
%24 = load i64, i64* %8
%25 = getelementptr inbounds double*, double** %23, i64 %24
%26 = load double*, double** %25
%27 = load i64, i64* %10
%28 = getelementptr inbounds double, double* %26, i64 %27
%29 = load double, double* %28
%30 = fcmp ogt double %29, 0.000000e+00
br i1 %30, label %31, label %65
31: ; preds = %22
store i64 1, i64* %13
br label %32
32: ; preds = %59, %31
%33 = load i64, i64* %13
%34 = icmp sle i64 %33, 3
br i1 %34, label %35, label %62
35: ; preds = %32
%36 = load double**, double*** %6
%37 = load i64, i64* %7
%38 = getelementptr inbounds double*, double** %36, i64 %37
%39 = load double*, double** %38
%40 = load i64, i64* %9
%41 = sub nsw i64 %40, 4
%42 = load i64, i64* %13
%43 = add nsw i64 %41, %42
%44 = getelementptr inbounds double, double* %39, i64 %43
%45 = load double, double* %44
%46 = load double**, double*** %6
%47 = load i64, i64* %8
%48 = getelementptr inbounds double*, double** %46, i64 %47
%49 = load double*, double** %48
%50 = load i64, i64* %10
%51 = sub nsw i64 %50, 4
%52 = load i64, i64* %13
%53 = add nsw i64 %51, %52
%54 = getelementptr inbounds double, double* %49, i64 %53
%55 = load double, double* %54
%56 = fsub double %45, %55
%57 = load i64, i64* %13
%58 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 %57
store double %56, double* %58
br label %59
59: ; preds = %35
%60 = load i64, i64* %13
%61 = add nsw i64 %60, 1
store i64 %61, i64* %13
br label %32
62: ; preds = %32
%63 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%64 = call double @veclen(double* %63)
store double %64, double* %11
br label %65
65: ; preds = %62, %22, %5
%66 = load double, double* %11
ret double %66
}

LLVM IR (-O2):
define double @distance_ab(double** nocapture %0, i64 %1, i64 %2, i64 %3, i64 %4) {
%6 = alloca [4 x double]
%7 = bitcast [4 x double]* %6 to i8*
%8 = getelementptr inbounds double*, double** %0, i64 %1
%9 = load double*, double** %8
%10 = getelementptr inbounds double, double* %9, i64 %3
%11 = load double, double* %10
%12 = fcmp ogt double %11, 0.000000e+00
br i1 %12, label %13, label %46
13: ; preds = %5
%14 = getelementptr inbounds double*, double** %0, i64 %2
%15 = load double*, double** %14
%16 = getelementptr inbounds double, double* %15, i64 %4
%17 = load double, double* %16
%18 = fcmp ogt double %17, 0.000000e+00
br i1 %18, label %19, label %46
19: ; preds = %13
%20 = add i64 %3, -3
%21 = getelementptr inbounds double, double* %9, i64 %20
%22 = load double, double* %21
%23 = add i64 %4, -3
%24 = getelementptr inbounds double, double* %15, i64 %23
%25 = load double, double* %24
%26 = fsub double %22, %25
%27 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 1
store double %26, double* %27
%28 = add i64 %3, -2
%29 = getelementptr inbounds double, double* %9, i64 %28
%30 = load double, double* %29
%31 = add i64 %4, -2
%32 = getelementptr inbounds double, double* %15, i64 %31
%33 = load double, double* %32
%34 = fsub double %30, %33
%35 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 2
store double %34, double* %35
%36 = add i64 %3, -1
%37 = getelementptr inbounds double, double* %9, i64 %36
%38 = load double, double* %37
%39 = add i64 %4, -1
%40 = getelementptr inbounds double, double* %15, i64 %39
%41 = load double, double* %40
%42 = fsub double %38, %41
%43 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 3
store double %42, double* %43
%44 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 0
%45 = call double @veclen(double* %44)
br label %46
46: ; preds = %19, %13, %5
%47 = phi double [ %45, %19 ], [ -1.000000e+00, %13 ], [ -1.000000e+00, %5 ]
ret double %47
}