#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 dnrm2(int const, double *, int);
double dnrm3(int const, double *, int const);
double fabs(double const);
int /*<<< orphan*/ free(double *);
size_t idamax(int const, double *);
size_t idamin(int const, double *);
double *malloc(int const);
double pcapack_distance(const int method, const int n, const double *restrict x,
                        const double *restrict y, const int p) {
  double dist = 0;
  double tmp;
  int i;
  int ux, uy;
  double *work;
  int i1 = 1;
  double neg1 = -1.;
  work = malloc(n * sizeof(*work));

  for (i = 0; i < n; i++)
    work[i] = x[i] - y[i];
  if (method == 1)
    dist = dnrm2(n, work, 1);
  else if (method == 2)
    dist = work[idamax(n, work)];
  else if (method == 3)
    dist = work[idamin(n, work)];
  else if (method == 4) {
#pragma omp parallel for simd default(shared) reduction(+ : dist)
    for (i = 0; i < n; i++)
      dist += fabs(work[i]);
  } else if (method == 5) {
#pragma omp parallel for simd default(shared) reduction(+ : dist)
    for (i = 0; i < n; i++) {
      tmp = fabs(x[i]) + fabs(y[i]);
      if (tmp != 0.)
        dist += fabs(work[i]) / tmp;
    }
  } else if (method == 6) {
#pragma omp parallel for simd default(shared) reduction(+ : dist)
    for (i = 0; i < n; i++) {
      tmp = fabs(x[i] + y[i]);
      if (tmp != 0.)
        dist += fabs(work[i]) / tmp;
    }
  } else if (method == 7)
    dist = dnrm3(n, work, p);
  else if (method == 8) {
    int on = 0;
#pragma omp parallel for simd default(shared) reduction(+ : dist, on)
    for (i = 0; i < n; i++) {
      if (x[i] || y[i]) {
        on++;
        if (!(x[i] && y[i]))
          dist += 1.;
      }
    }
    if (on != 0)
      dist /= (double)on;
  }
  free(work);
  return dist;
}


x86 assembly (clang, -O0):
<pcapack_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x4c(%rbp)
movsd  0xe6f(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f1 <pcapack_distance+0x91>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b0 <pcapack_distance+0x50>
cmpl   $0x1,-0x4(%rbp)
jne    1216 <pcapack_distance+0xb6>
mov    -0x8(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    $0x1,%edx
call   1080 <dnrm2@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    156e <pcapack_distance+0x40e>
cmpl   $0x2,-0x4(%rbp)
jne    124a <pcapack_distance+0xea>
mov    -0x48(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x48(%rbp),%rsi
call   1060 <idamax@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1569 <pcapack_distance+0x409>
cmpl   $0x3,-0x4(%rbp)
jne    127e <pcapack_distance+0x11e>
mov    -0x48(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x48(%rbp),%rsi
call   1050 <idamin@plt>
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1564 <pcapack_distance+0x404>
cmpl   $0x4,-0x4(%rbp)
jne    12d0 <pcapack_distance+0x170>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12cb <pcapack_distance+0x16b>
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xd61(%rip),%xmm1
pand   %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    128f <pcapack_distance+0x12f>
jmp    155f <pcapack_distance+0x3ff>
cmpl   $0x5,-0x4(%rbp)
jne    1382 <pcapack_distance+0x222>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    137d <pcapack_distance+0x21d>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xd0f(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xcf7(%rip),%xmm2
pand   %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1343 <pcapack_distance+0x1e3>
jp     1343 <pcapack_distance+0x1e3>
jmp    136a <pcapack_distance+0x20a>
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xcb9(%rip),%xmm1
pand   %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    136f <pcapack_distance+0x20f>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12e1 <pcapack_distance+0x181>
jmp    155a <pcapack_distance+0x3fa>
cmpl   $0x6,-0x4(%rbp)
jne    1425 <pcapack_distance+0x2c5>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1420 <pcapack_distance+0x2c0>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movaps 0xc50(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13e6 <pcapack_distance+0x286>
jp     13e6 <pcapack_distance+0x286>
jmp    140d <pcapack_distance+0x2ad>
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xc16(%rip),%xmm1
pand   %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1412 <pcapack_distance+0x2b2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1393 <pcapack_distance+0x233>
jmp    1555 <pcapack_distance+0x3f5>
cmpl   $0x7,-0x4(%rbp)
jne    1448 <pcapack_distance+0x2e8>
mov    -0x8(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <dnrm3@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1550 <pcapack_distance+0x3f0>
cmpl   $0x8,-0x4(%rbp)
jne    154b <pcapack_distance+0x3eb>
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1529 <pcapack_distance+0x3c9>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    14b1 <pcapack_distance+0x351>
jp     14b1 <pcapack_distance+0x351>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    14b1 <pcapack_distance+0x351>
jp     14b1 <pcapack_distance+0x351>
jmp    1516 <pcapack_distance+0x3b6>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    14df <pcapack_distance+0x37f>
jp     14df <pcapack_distance+0x37f>
jmp    14ff <pcapack_distance+0x39f>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1511 <pcapack_distance+0x3b1>
jp     1511 <pcapack_distance+0x3b1>
movsd  0xb01(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1516 <pcapack_distance+0x3b6>
jmp    151b <pcapack_distance+0x3bb>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1460 <pcapack_distance+0x300>
cmpl   $0x0,-0x5c(%rbp)
je     1546 <pcapack_distance+0x3e6>
cvtsi2sdl -0x5c(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    154b <pcapack_distance+0x3eb>
jmp    1550 <pcapack_distance+0x3f0>
jmp    1555 <pcapack_distance+0x3f5>
jmp    155a <pcapack_distance+0x3fa>
jmp    155f <pcapack_distance+0x3ff>
jmp    1564 <pcapack_distance+0x404>
jmp    1569 <pcapack_distance+0x409>
jmp    156e <pcapack_distance+0x40e>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x28(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcapack_distance>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r13d
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %esi,%r12d
mov    %edi,%ebp
lea    0x0(,%r12,8),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
test   %r12d,%r12d
jle    128a <pcapack_distance+0x12a>
mov    %r12d,%eax
cmp    $0x4,%r12d
jae    11a5 <pcapack_distance+0x45>
xor    %ecx,%ecx
jmp    1270 <pcapack_distance+0x110>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdx
mov    %rdx,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
test   %rdx,%rdx
je     12bf <pcapack_distance+0x15f>
mov    %rsi,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movupd (%rbx,%rdx,8),%xmm0
movupd 0x10(%rbx,%rdx,8),%xmm1
movupd (%r15,%rdx,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%r15,%rdx,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%r14,%rdx,8)
movupd %xmm1,0x10(%r14,%rdx,8)
movupd 0x20(%rbx,%rdx,8),%xmm0
movupd 0x30(%rbx,%rdx,8),%xmm1
movupd 0x20(%r15,%rdx,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x30(%r15,%rdx,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,0x20(%r14,%rdx,8)
movupd %xmm1,0x30(%r14,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rdi
jne    11d0 <pcapack_distance+0x70>
test   $0x1,%sil
je     126a <pcapack_distance+0x10a>
movupd (%rbx,%rdx,8),%xmm0
movupd 0x10(%rbx,%rdx,8),%xmm1
movupd (%r15,%rdx,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%r15,%rdx,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%r14,%rdx,8)
movupd %xmm1,0x10(%r14,%rdx,8)
cmp    %rax,%rcx
je     128a <pcapack_distance+0x12a>
nop
movsd  (%rbx,%rcx,8),%xmm0
subsd  (%r15,%rcx,8),%xmm0
movsd  %xmm0,(%r14,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1270 <pcapack_distance+0x110>
xorpd  %xmm0,%xmm0
add    $0xffffffff,%ebp
cmp    $0x7,%ebp
ja     1506 <pcapack_distance+0x3a6>
lea    0xd7f(%rip),%rax
movslq (%rax,%rbp,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %r12d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1080 <dnrm2@plt>
jmp    1506 <pcapack_distance+0x3a6>
xor    %edx,%edx
test   $0x1,%sil
jne    123d <pcapack_distance+0xdd>
jmp    126a <pcapack_distance+0x10a>
mov    %r12d,%edi
mov    %r14,%rsi
call   1060 <idamax@plt>
movsd  (%r14,%rax,8),%xmm0
jmp    1506 <pcapack_distance+0x3a6>
mov    %r12d,%edi
mov    %r14,%rsi
call   1050 <idamin@plt>
movsd  (%r14,%rax,8),%xmm0
jmp    1506 <pcapack_distance+0x3a6>
test   %r12d,%r12d
jle    1506 <pcapack_distance+0x3a6>
mov    %r12d,%ecx
lea    -0x1(%rcx),%rdx
mov    %ecx,%eax
and    $0x3,%eax
cmp    $0x3,%rdx
jae    147b <pcapack_distance+0x31b>
xorpd  %xmm0,%xmm0
xor    %edx,%edx
jmp    14d8 <pcapack_distance+0x378>
test   %r12d,%r12d
jle    1506 <pcapack_distance+0x3a6>
mov    %r12d,%eax
xorpd  %xmm5,%xmm5
xor    %ecx,%ecx
movapd 0xcd3(%rip),%xmm1
movapd 0xccb(%rip),%xmm2
xorpd  %xmm0,%xmm0
jmp    135d <pcapack_distance+0x1fd>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %rcx,%rax
je     1506 <pcapack_distance+0x3a6>
movsd  (%rbx,%rcx,8),%xmm4
andpd  %xmm1,%xmm4
movsd  (%r15,%rcx,8),%xmm3
andpd  %xmm1,%xmm3
addsd  %xmm4,%xmm3
ucomisd %xmm5,%xmm3
jne    137c <pcapack_distance+0x21c>
jnp    1350 <pcapack_distance+0x1f0>
movsd  (%r14,%rcx,8),%xmm4
andpd  %xmm2,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm0
jmp    1350 <pcapack_distance+0x1f0>
test   %r12d,%r12d
jle    1506 <pcapack_distance+0x3a6>
mov    %r12d,%eax
xorpd  %xmm4,%xmm4
xor    %ecx,%ecx
movapd 0xc66(%rip),%xmm1
xorpd  %xmm0,%xmm0
jmp    13bd <pcapack_distance+0x25d>
add    $0x1,%rcx
cmp    %rcx,%rax
je     1506 <pcapack_distance+0x3a6>
movsd  (%rbx,%rcx,8),%xmm2
addsd  (%r15,%rcx,8),%xmm2
ucomisd %xmm4,%xmm2
jne    13d0 <pcapack_distance+0x270>
jnp    13b0 <pcapack_distance+0x250>
movsd  (%r14,%rcx,8),%xmm3
divsd  %xmm2,%xmm3
andpd  %xmm1,%xmm3
addsd  %xmm3,%xmm0
jmp    13b0 <pcapack_distance+0x250>
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r13d,%edx
call   1040 <dnrm3@plt>
jmp    1506 <pcapack_distance+0x3a6>
test   %r12d,%r12d
jle    1506 <pcapack_distance+0x3a6>
mov    %r12d,%eax
xorpd  %xmm3,%xmm3
xor    %edx,%edx
movsd  0xbef(%rip),%xmm1
xor    %ecx,%ecx
xorpd  %xmm0,%xmm0
jmp    142d <pcapack_distance+0x2cd>
nopl   0x0(%rax)
addsd  %xmm1,%xmm0
add    $0x1,%rdx
cmp    %rdx,%rax
je     1463 <pcapack_distance+0x303>
movsd  (%rbx,%rdx,8),%xmm2
ucomisd %xmm3,%xmm2
jne    143a <pcapack_distance+0x2da>
jnp    1450 <pcapack_distance+0x2f0>
add    $0x1,%ecx
movsd  (%r15,%rdx,8),%xmm2
ucomisd %xmm3,%xmm2
jne    1424 <pcapack_distance+0x2c4>
jp     1424 <pcapack_distance+0x2c4>
jmp    1420 <pcapack_distance+0x2c0>
nopl   (%rax)
movsd  (%r15,%rdx,8),%xmm2
ucomisd %xmm3,%xmm2
jne    145e <pcapack_distance+0x2fe>
jnp    1424 <pcapack_distance+0x2c4>
add    $0x1,%ecx
jmp    1420 <pcapack_distance+0x2c0>
test   %ecx,%ecx
je     1506 <pcapack_distance+0x3a6>
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  %xmm1,%xmm0
jmp    1506 <pcapack_distance+0x3a6>
and    $0xfffffffc,%ecx
xorpd  %xmm1,%xmm1
xor    %edx,%edx
movapd 0xb84(%rip),%xmm5
nopl   0x0(%rax)
movsd  (%r14,%rdx,8),%xmm2
movsd  0x8(%r14,%rdx,8),%xmm3
movsd  0x10(%r14,%rdx,8),%xmm4
movsd  0x18(%r14,%rdx,8),%xmm0
andpd  %xmm5,%xmm2
addsd  %xmm1,%xmm2
andpd  %xmm5,%xmm3
addsd  %xmm2,%xmm3
andpd  %xmm5,%xmm4
addsd  %xmm3,%xmm4
andpd  %xmm5,%xmm0
addsd  %xmm4,%xmm0
add    $0x4,%rdx
movapd %xmm0,%xmm1
cmp    %rdx,%rcx
jne    1490 <pcapack_distance+0x330>
test   %rax,%rax
je     1506 <pcapack_distance+0x3a6>
lea    (%r14,%rdx,8),%rcx
xor    %edx,%edx
movapd 0xb25(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movsd  (%rcx,%rdx,8),%xmm1
andpd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rdx
cmp    %rdx,%rax
jne    14f0 <pcapack_distance+0x390>
movapd %xmm0,(%rsp)
mov    %r14,%rdi
call   1030 <free@plt>
movaps (%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @pcapack_distance(i32 %0, i32 %1, double* noalias %2, double* noalias %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double*
%17 = alloca i32
%18 = alloca double
%19 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
store double 0.000000e+00, double* %11
store i32 1, i32* %17
store double -1.000000e+00, double* %18
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 8
%23 = trunc i64 %22 to i32
%24 = call double* @malloc(i32 %23)
store double* %24, double** %16
store i32 0, i32* %13
br label %25
25: ; preds = %45, %5
%26 = load i32, i32* %13
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %48
29: ; preds = %25
%30 = load double*, double** %8
%31 = load i32, i32* %13
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = load double*, double** %9
%36 = load i32, i32* %13
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fsub double %34, %39
%41 = load double*, double** %16
%42 = load i32, i32* %13
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
store double %40, double* %44
br label %45
45: ; preds = %29
%46 = load i32, i32* %13
%47 = add nsw i32 %46, 1
store i32 %47, i32* %13
br label %25
48: ; preds = %25
%49 = load i32, i32* %6
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i32, i32* %7
%53 = load double*, double** %16
%54 = call double @dnrm2(i32 %52, double* %53, i32 1)
store double %54, double* %11
br label %245
55: ; preds = %48
%56 = load i32, i32* %6
%57 = icmp eq i32 %56, 2
br i1 %57, label %58, label %65
58: ; preds = %55
%59 = load double*, double** %16
%60 = load i32, i32* %7
%61 = load double*, double** %16
%62 = call i64 @idamax(i32 %60, double* %61)
%63 = getelementptr inbounds double, double* %59, i64 %62
%64 = load double, double* %63
store double %64, double* %11
br label %244
65: ; preds = %55
%66 = load i32, i32* %6
%67 = icmp eq i32 %66, 3
br i1 %67, label %68, label %75
68: ; preds = %65
%69 = load double*, double** %16
%70 = load i32, i32* %7
%71 = load double*, double** %16
%72 = call i64 @idamin(i32 %70, double* %71)
%73 = getelementptr inbounds double, double* %69, i64 %72
%74 = load double, double* %73
store double %74, double* %11
br label %243
75: ; preds = %65
%76 = load i32, i32* %6
%77 = icmp eq i32 %76, 4
br i1 %77, label %78, label %96
78: ; preds = %75
store i32 0, i32* %13
br label %79
79: ; preds = %92, %78
%80 = load i32, i32* %13
%81 = load i32, i32* %7
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %95
83: ; preds = %79
%84 = load double*, double** %16
%85 = load i32, i32* %13
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = call double @llvm.fabs.f64(double %88)
%90 = load double, double* %11
%91 = fadd double %90, %89
store double %91, double* %11
br label %92
92: ; preds = %83
%93 = load i32, i32* %13
%94 = add nsw i32 %93, 1
store i32 %94, i32* %13
br label %79
95: ; preds = %79
br label %242
96: ; preds = %75
%97 = load i32, i32* %6
%98 = icmp eq i32 %97, 5
br i1 %98, label %99, label %136
99: ; preds = %96
store i32 0, i32* %13
br label %100
100: ; preds = %132, %99
%101 = load i32, i32* %13
%102 = load i32, i32* %7
%103 = icmp slt i32 %101, %102
br i1 %103, label %104, label %135
104: ; preds = %100
%105 = load double*, double** %8
%106 = load i32, i32* %13
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds double, double* %105, i64 %107
%109 = load double, double* %108
%110 = call double @llvm.fabs.f64(double %109)
%111 = load double*, double** %9
%112 = load i32, i32* %13
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %111, i64 %113
%115 = load double, double* %114
%116 = call double @llvm.fabs.f64(double %115)
%117 = fadd double %110, %116
store double %117, double* %12
%118 = load double, double* %12
%119 = fcmp une double %118, 0.000000e+00
br i1 %119, label %120, label %131
120: ; preds = %104
%121 = load double*, double** %16
%122 = load i32, i32* %13
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds double, double* %121, i64 %123
%125 = load double, double* %124
%126 = call double @llvm.fabs.f64(double %125)
%127 = load double, double* %12
%128 = fdiv double %126, %127
%129 = load double, double* %11
%130 = fadd double %129, %128
store double %130, double* %11
br label %131
131: ; preds = %120, %104
br label %132
132: ; preds = %131
%133 = load i32, i32* %13
%134 = add nsw i32 %133, 1
store i32 %134, i32* %13
br label %100
135: ; preds = %100
br label %241
136: ; preds = %96
%137 = load i32, i32* %6
%138 = icmp eq i32 %137, 6
br i1 %138, label %139, label %175
139: ; preds = %136
store i32 0, i32* %13
br label %140
140: ; preds = %171, %139
%141 = load i32, i32* %13
%142 = load i32, i32* %7
%143 = icmp slt i32 %141, %142
br i1 %143, label %144, label %174
144: ; preds = %140
%145 = load double*, double** %8
%146 = load i32, i32* %13
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds double, double* %145, i64 %147
%149 = load double, double* %148
%150 = load double*, double** %9
%151 = load i32, i32* %13
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double, double* %150, i64 %152
%154 = load double, double* %153
%155 = fadd double %149, %154
%156 = call double @llvm.fabs.f64(double %155)
store double %156, double* %12
%157 = load double, double* %12
%158 = fcmp une double %157, 0.000000e+00
br i1 %158, label %159, label %170
159: ; preds = %144
%160 = load double*, double** %16
%161 = load i32, i32* %13
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds double, double* %160, i64 %162
%164 = load double, double* %163
%165 = call double @llvm.fabs.f64(double %164)
%166 = load double, double* %12
%167 = fdiv double %165, %166
%168 = load double, double* %11
%169 = fadd double %168, %167
store double %169, double* %11
br label %170
170: ; preds = %159, %144
br label %171
171: ; preds = %170
%172 = load i32, i32* %13
%173 = add nsw i32 %172, 1
store i32 %173, i32* %13
br label %140
174: ; preds = %140
br label %240
175: ; preds = %136
%176 = load i32, i32* %6
%177 = icmp eq i32 %176, 7
br i1 %177, label %178, label %183
178: ; preds = %175
%179 = load i32, i32* %7
%180 = load double*, double** %16
%181 = load i32, i32* %10
%182 = call double @dnrm3(i32 %179, double* %180, i32 %181)
store double %182, double* %11
br label %239
183: ; preds = %175
%184 = load i32, i32* %6
%185 = icmp eq i32 %184, 8
br i1 %185, label %186, label %238
186: ; preds = %183
store i32 0, i32* %19
store i32 0, i32* %13
br label %187
187: ; preds = %226, %186
%188 = load i32, i32* %13
%189 = load i32, i32* %7
%190 = icmp slt i32 %188, %189
br i1 %190, label %191, label %229
191: ; preds = %187
%192 = load double*, double** %8
%193 = load i32, i32* %13
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds double, double* %192, i64 %194
%196 = load double, double* %195
%197 = fcmp une double %196, 0.000000e+00
br i1 %197, label %205, label %198
198: ; preds = %191
%199 = load double*, double** %9
%200 = load i32, i32* %13
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds double, double* %199, i64 %201
%203 = load double, double* %202
%204 = fcmp une double %203, 0.000000e+00
br i1 %204, label %205, label %225
205: ; preds = %198, %191
%206 = load i32, i32* %19
%207 = add nsw i32 %206, 1
store i32 %207, i32* %19
%208 = load double*, double** %8
%209 = load i32, i32* %13
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds double, double* %208, i64 %210
%212 = load double, double* %211
%213 = fcmp une double %212, 0.000000e+00
br i1 %213, label %214, label %221
214: ; preds = %205
%215 = load double*, double** %9
%216 = load i32, i32* %13
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds double, double* %215, i64 %217
%219 = load double, double* %218
%220 = fcmp une double %219, 0.000000e+00
br i1 %220, label %224, label %221
221: ; preds = %214, %205
%222 = load double, double* %11
%223 = fadd double %222, 1.000000e+00
store double %223, double* %11
br label %224
224: ; preds = %221, %214
br label %225
225: ; preds = %224, %198
br label %226
226: ; preds = %225
%227 = load i32, i32* %13
%228 = add nsw i32 %227, 1
store i32 %228, i32* %13
br label %187
229: ; preds = %187
%230 = load i32, i32* %19
%231 = icmp ne i32 %230, 0
br i1 %231, label %232, label %237
232: ; preds = %229
%233 = load i32, i32* %19
%234 = sitofp i32 %233 to double
%235 = load double, double* %11
%236 = fdiv double %235, %234
store double %236, double* %11
br label %237
237: ; preds = %232, %229
br label %238
238: ; preds = %237, %183
br label %239
239: ; preds = %238, %178
br label %240
240: ; preds = %239, %174
br label %241
241: ; preds = %240, %135
br label %242
242: ; preds = %241, %95
br label %243
243: ; preds = %242, %68
br label %244
244: ; preds = %243, %58
br label %245
245: ; preds = %244, %51
%246 = load double*, double** %16
%247 = call i32 @free(double* %246)
%248 = load double, double* %11
ret double %248
}

LLVM IR (-O2):
define double @pcapack_distance(i32 %0, i32 %1, double* noalias nocapture %2, double* noalias nocapture %3, i32 %4) {
%6 = shl i32 %1, 3
%7 = tail call double* @malloc(i32 %6)
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %100
9: ; preds = %5
%10 = zext i32 %1 to i64
%11 = icmp ult i32 %1, 4
br i1 %11, label %88, label %12
12: ; preds = %9
%13 = and i64 %10, 4294967292
%14 = add nsw i64 %13, -4
%15 = lshr exact i64 %14, 2
%16 = add nuw nsw i64 %15, 1
%17 = and i64 %16, 1
%18 = icmp eq i64 %14, 0
br i1 %18, label %64, label %19
19: ; preds = %12
%20 = and i64 %16, 9223372036854775806
br label %21
21: ; preds = %21, %19
%22 = phi i64 [ 0, %19 ], [ %61, %21 ]
%23 = phi i64 [ 0, %19 ], [ %62, %21 ]
%24 = getelementptr inbounds double, double* %2, i64 %22
%25 = bitcast double* %24 to <2 x double>*
%26 = load <2 x double>, <2 x double>* %25
%27 = getelementptr inbounds double, double* %24, i64 2
%28 = bitcast double* %27 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = getelementptr inbounds double, double* %3, i64 %22
%31 = bitcast double* %30 to <2 x double>*
%32 = load <2 x double>, <2 x double>* %31
%33 = getelementptr inbounds double, double* %30, i64 2
%34 = bitcast double* %33 to <2 x double>*
%35 = load <2 x double>, <2 x double>* %34
%36 = fsub <2 x double> %26, %32
%37 = fsub <2 x double> %29, %35
%38 = getelementptr inbounds double, double* %7, i64 %22
%39 = bitcast double* %38 to <2 x double>*
store <2 x double> %36, <2 x double>* %39
%40 = getelementptr inbounds double, double* %38, i64 2
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> %37, <2 x double>* %41
%42 = or i64 %22, 4
%43 = getelementptr inbounds double, double* %2, i64 %42
%44 = bitcast double* %43 to <2 x double>*
%45 = load <2 x double>, <2 x double>* %44
%46 = getelementptr inbounds double, double* %43, i64 2
%47 = bitcast double* %46 to <2 x double>*
%48 = load <2 x double>, <2 x double>* %47
%49 = getelementptr inbounds double, double* %3, i64 %42
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = getelementptr inbounds double, double* %49, i64 2
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = fsub <2 x double> %45, %51
%56 = fsub <2 x double> %48, %54
%57 = getelementptr inbounds double, double* %7, i64 %42
%58 = bitcast double* %57 to <2 x double>*
store <2 x double> %55, <2 x double>* %58
%59 = getelementptr inbounds double, double* %57, i64 2
%60 = bitcast double* %59 to <2 x double>*
store <2 x double> %56, <2 x double>* %60
%61 = add nuw i64 %22, 8
%62 = add i64 %23, 2
%63 = icmp eq i64 %62, %20
br i1 %63, label %64, label %21
64: ; preds = %21, %12
%65 = phi i64 [ 0, %12 ], [ %61, %21 ]
%66 = icmp eq i64 %17, 0
br i1 %66, label %86, label %67
67: ; preds = %64
%68 = getelementptr inbounds double, double* %2, i64 %65
%69 = bitcast double* %68 to <2 x double>*
%70 = load <2 x double>, <2 x double>* %69
%71 = getelementptr inbounds double, double* %68, i64 2
%72 = bitcast double* %71 to <2 x double>*
%73 = load <2 x double>, <2 x double>* %72
%74 = getelementptr inbounds double, double* %3, i64 %65
%75 = bitcast double* %74 to <2 x double>*
%76 = load <2 x double>, <2 x double>* %75
%77 = getelementptr inbounds double, double* %74, i64 2
%78 = bitcast double* %77 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = fsub <2 x double> %70, %76
%81 = fsub <2 x double> %73, %79
%82 = getelementptr inbounds double, double* %7, i64 %65
%83 = bitcast double* %82 to <2 x double>*
store <2 x double> %80, <2 x double>* %83
%84 = getelementptr inbounds double, double* %82, i64 2
%85 = bitcast double* %84 to <2 x double>*
store <2 x double> %81, <2 x double>* %85
br label %86
86: ; preds = %64, %67
%87 = icmp eq i64 %13, %10
br i1 %87, label %100, label %88
88: ; preds = %9, %86
%89 = phi i64 [ 0, %9 ], [ %13, %86 ]
br label %90
90: ; preds = %88, %90
%91 = phi i64 [ %98, %90 ], [ %89, %88 ]
%92 = getelementptr inbounds double, double* %2, i64 %91
%93 = load double, double* %92
%94 = getelementptr inbounds double, double* %3, i64 %91
%95 = load double, double* %94
%96 = fsub double %93, %95
%97 = getelementptr inbounds double, double* %7, i64 %91
store double %96, double* %97
%98 = add nuw nsw i64 %91, 1
%99 = icmp eq i64 %98, %10
br i1 %99, label %100, label %90
100: ; preds = %90, %86, %5
switch i32 %0, label %243 [
i32 1, label %118
i32 2, label %120
i32 3, label %124
i32 4, label %110
i32 5, label %107
i32 6, label %104
i32 7, label %194
i32 8, label %101
]
101: ; preds = %100
br i1 %8, label %102, label %243
102: ; preds = %101
%103 = zext i32 %1 to i64
br label %196
104: ; preds = %100
br i1 %8, label %105, label %243
105: ; preds = %104
%106 = zext i32 %1 to i64
br label %175
107: ; preds = %100
br i1 %8, label %108, label %243
108: ; preds = %107
%109 = zext i32 %1 to i64
br label %154
110: ; preds = %100
br i1 %8, label %111, label %243
111: ; preds = %110
%112 = zext i32 %1 to i64
%113 = add nsw i64 %112, -1
%114 = and i64 %112, 3
%115 = icmp ult i64 %113, 3
br i1 %115, label %227, label %116
116: ; preds = %111
%117 = and i64 %112, 4294967292
br label %128
118: ; preds = %100
%119 = tail call double @dnrm2(i32 %1, double* %7, i32 1)
br label %243
120: ; preds = %100
%121 = tail call i64 @idamax(i32 %1, double* %7)
%122 = getelementptr inbounds double, double* %7, i64 %121
%123 = load double, double* %122
br label %243
124: ; preds = %100
%125 = tail call i64 @idamin(i32 %1, double* %7)
%126 = getelementptr inbounds double, double* %7, i64 %125
%127 = load double, double* %126
br label %243
128: ; preds = %128, %116
%129 = phi i64 [ 0, %116 ], [ %151, %128 ]
%130 = phi double [ 0.000000e+00, %116 ], [ %150, %128 ]
%131 = phi i64 [ 0, %116 ], [ %152, %128 ]
%132 = getelementptr inbounds double, double* %7, i64 %129
%133 = load double, double* %132
%134 = tail call double @llvm.fabs.f64(double %133)
%135 = fadd double %130, %134
%136 = or i64 %129, 1
%137 = getelementptr inbounds double, double* %7, i64 %136
%138 = load double, double* %137
%139 = tail call double @llvm.fabs.f64(double %138)
%140 = fadd double %135, %139
%141 = or i64 %129, 2
%142 = getelementptr inbounds double, double* %7, i64 %141
%143 = load double, double* %142
%144 = tail call double @llvm.fabs.f64(double %143)
%145 = fadd double %140, %144
%146 = or i64 %129, 3
%147 = getelementptr inbounds double, double* %7, i64 %146
%148 = load double, double* %147
%149 = tail call double @llvm.fabs.f64(double %148)
%150 = fadd double %145, %149
%151 = add nuw nsw i64 %129, 4
%152 = add i64 %131, 4
%153 = icmp eq i64 %152, %117
br i1 %153, label %227, label %128
154: ; preds = %108, %171
%155 = phi i64 [ 0, %108 ], [ %173, %171 ]
%156 = phi double [ 0.000000e+00, %108 ], [ %172, %171 ]
%157 = getelementptr inbounds double, double* %2, i64 %155
%158 = load double, double* %157
%159 = tail call double @llvm.fabs.f64(double %158)
%160 = getelementptr inbounds double, double* %3, i64 %155
%161 = load double, double* %160
%162 = tail call double @llvm.fabs.f64(double %161)
%163 = fadd double %159, %162
%164 = fcmp une double %163, 0.000000e+00
br i1 %164, label %165, label %171
165: ; preds = %154
%166 = getelementptr inbounds double, double* %7, i64 %155
%167 = load double, double* %166
%168 = tail call double @llvm.fabs.f64(double %167)
%169 = fdiv double %168, %163
%170 = fadd double %156, %169
br label %171
171: ; preds = %154, %165
%172 = phi double [ %170, %165 ], [ %156, %154 ]
%173 = add nuw nsw i64 %155, 1
%174 = icmp eq i64 %173, %109
br i1 %174, label %243, label %154
175: ; preds = %105, %190
%176 = phi i64 [ 0, %105 ], [ %192, %190 ]
%177 = phi double [ 0.000000e+00, %105 ], [ %191, %190 ]
%178 = getelementptr inbounds double, double* %2, i64 %176
%179 = load double, double* %178
%180 = getelementptr inbounds double, double* %3, i64 %176
%181 = load double, double* %180
%182 = fadd double %179, %181
%183 = fcmp une double %182, 0.000000e+00
br i1 %183, label %184, label %190
184: ; preds = %175
%185 = getelementptr inbounds double, double* %7, i64 %176
%186 = load double, double* %185
%187 = fdiv double %186, %182
%188 = tail call double @llvm.fabs.f64(double %187)
%189 = fadd double %177, %188
br label %190
190: ; preds = %175, %184
%191 = phi double [ %189, %184 ], [ %177, %175 ]
%192 = add nuw nsw i64 %176, 1
%193 = icmp eq i64 %192, %106
br i1 %193, label %243, label %175
194: ; preds = %100
%195 = tail call double @dnrm3(i32 %1, double* %7, i32 %4)
br label %243
196: ; preds = %102, %217
%197 = phi i64 [ 0, %102 ], [ %220, %217 ]
%198 = phi i32 [ 0, %102 ], [ %219, %217 ]
%199 = phi double [ 0.000000e+00, %102 ], [ %218, %217 ]
%200 = getelementptr inbounds double, double* %2, i64 %197
%201 = load double, double* %200
%202 = fcmp une double %201, 0.000000e+00
br i1 %202, label %209, label %203
203: ; preds = %196
%204 = getelementptr inbounds double, double* %3, i64 %197
%205 = load double, double* %204
%206 = fcmp une double %205, 0.000000e+00
br i1 %206, label %207, label %217
207: ; preds = %203
%208 = add nsw i32 %198, 1
br label %214
209: ; preds = %196
%210 = add nsw i32 %198, 1
%211 = getelementptr inbounds double, double* %3, i64 %197
%212 = load double, double* %211
%213 = fcmp une double %212, 0.000000e+00
br i1 %213, label %217, label %214
214: ; preds = %207, %209
%215 = phi i32 [ %210, %209 ], [ %208, %207 ]
%216 = fadd double %199, 1.000000e+00
br label %217
217: ; preds = %203, %214, %209
%218 = phi double [ %199, %209 ], [ %216, %214 ], [ %199, %203 ]
%219 = phi i32 [ %210, %209 ], [ %215, %214 ], [ %198, %203 ]
%220 = add nuw nsw i64 %197, 1
%221 = icmp eq i64 %220, %103
br i1 %221, label %222, label %196
222: ; preds = %217
%223 = icmp eq i32 %219, 0
br i1 %223, label %243, label %224
224: ; preds = %222
%225 = sitofp i32 %219 to double
%226 = fdiv double %218, %225
br label %243
227: ; preds = %128, %111
%228 = phi double [ undef, %111 ], [ %150, %128 ]
%229 = phi i64 [ 0, %111 ], [ %151, %128 ]
%230 = phi double [ 0.000000e+00, %111 ], [ %150, %128 ]
%231 = icmp eq i64 %114, 0
br i1 %231, label %243, label %232
232: ; preds = %227, %232
%233 = phi i64 [ %240, %232 ], [ %229, %227 ]
%234 = phi double [ %239, %232 ], [ %230, %227 ]
%235 = phi i64 [ %241, %232 ], [ 0, %227 ]
%236 = getelementptr inbounds double, double* %7, i64 %233
%237 = load double, double* %236
%238 = tail call double @llvm.fabs.f64(double %237)
%239 = fadd double %234, %238
%240 = add nuw nsw i64 %233, 1
%241 = add i64 %235, 1
%242 = icmp eq i64 %241, %114
br i1 %242, label %243, label %232
243: ; preds = %190, %171, %227, %232, %101, %104, %107, %110, %222, %224, %100, %120, %194, %124, %118
%244 = phi double [ %119, %118 ], [ %123, %120 ], [ %127, %124 ], [ %195, %194 ], [ 0.000000e+00, %100 ], [ %226, %224 ], [ %218, %222 ], [ 0.000000e+00, %110 ], [ 0.000000e+00, %107 ], [ 0.000000e+00, %104 ], [ 0.000000e+00, %101 ], [ %228, %227 ], [ %239, %232 ], [ %172, %171 ], [ %191, %190 ]
%245 = tail call i32 @free(double* %7)
ret double %244
}