#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 fabs(double);
double pow(double, double);
double Lpmetric(int nd, double *x, double *y, void *data) {
  double f = *(double *)data;
  double t = 0.0;
  for (int k = 0; k < nd; k++) {
    t += pow(fabs(x[k] - y[k]), f);
  }
  return pow(t, 1.0 / f);
}


x86 assembly (clang, -O0):
<Lpmetric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1196 <Lpmetric+0x86>
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
movaps 0xea0(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <pow@plt>
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1143 <Lpmetric+0x33>
movsd  -0x30(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
divsd  -0x28(%rbp),%xmm1
call   1030 <pow@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Lpmetric>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movsd  (%rcx),%xmm0
test   %edi,%edi
jle    1144 <Lpmetric+0x34>
mov    %rdx,%r14
mov    %rsi,%r12
movsd  %xmm0,0x8(%rsp)
mov    %edi,%r15d
cmp    $0x1,%edi
jne    114d <Lpmetric+0x3d>
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
jmp    11c5 <Lpmetric+0xb5>
xorpd  %xmm2,%xmm2
jmp    1204 <Lpmetric+0xf4>
mov    %r15d,%r13d
and    $0xfffffffe,%r13d
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsd  %xmm2,(%rsp)
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
movapd 0xe87(%rip),%xmm1
andpd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <pow@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%r12,%rbx,8),%xmm0
subsd  0x8(%r14,%rbx,8),%xmm0
andpd  0xe58(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <pow@plt>
movapd %xmm0,%xmm2
addsd  (%rsp),%xmm2
add    $0x2,%rbx
cmp    %rbx,%r13
jne    1160 <Lpmetric+0x50>
test   $0x1,%r15b
movsd  0x8(%rsp),%xmm0
je     1204 <Lpmetric+0xf4>
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
andpd  0xe1b(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm2,(%rsp)
call   1030 <pow@plt>
movsd  (%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
movsd  0xe04(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <pow@plt>

LLVM IR (-O0):
define double @Lpmetric(i32 %0, double* %1, double* %2, i8* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca i8*
%9 = alloca double
%10 = alloca double
%11 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store i8* %3, i8** %8
%12 = load i8*, i8** %8
%13 = bitcast i8* %12 to double*
%14 = load double, double* %13
store double %14, double* %9
store double 0.000000e+00, double* %10
store i32 0, i32* %11
br label %15
15: ; preds = %36, %4
%16 = load i32, i32* %11
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %39
19: ; preds = %15
%20 = load double*, double** %6
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double*, double** %7
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = fsub double %24, %29
%31 = call double @llvm.fabs.f64(double %30)
%32 = load double, double* %9
%33 = call double @pow(double %31, double %32)
%34 = load double, double* %10
%35 = fadd double %34, %33
store double %35, double* %10
br label %36
36: ; preds = %19
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
store i32 %38, i32* %11
br label %15
39: ; preds = %15
%40 = load double, double* %10
%41 = load double, double* %9
%42 = fdiv double 1.000000e+00, %41
%43 = call double @pow(double %40, double %42)
ret double %43
}

LLVM IR (-O2):
define double @Lpmetric(i32 %0, double* nocapture %1, double* nocapture %2, i8* nocapture %3) {
%5 = bitcast i8* %3 to double*
%6 = load double, double* %5
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %28
8: ; preds = %4
%9 = zext i32 %0 to i64
%10 = and i64 %9, 1
%11 = icmp eq i32 %0, 1
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = and i64 %9, 4294967294
br label %32
14: ; preds = %32, %8
%15 = phi double [ undef, %8 ], [ %52, %32 ]
%16 = phi i64 [ 0, %8 ], [ %53, %32 ]
%17 = phi double [ 0.000000e+00, %8 ], [ %52, %32 ]
%18 = icmp eq i64 %10, 0
br i1 %18, label %28, label %19
19: ; preds = %14
%20 = getelementptr inbounds double, double* %1, i64 %16
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %2, i64 %16
%23 = load double, double* %22
%24 = fsub double %21, %23
%25 = tail call double @llvm.fabs.f64(double %24)
%26 = tail call double @pow(double %25, double %6)
%27 = fadd double %17, %26
br label %28
28: ; preds = %19, %14, %4
%29 = phi double [ 0.000000e+00, %4 ], [ %15, %14 ], [ %27, %19 ]
%30 = fdiv double 1.000000e+00, %6
%31 = tail call double @pow(double %29, double %30)
ret double %31
32: ; preds = %32, %12
%33 = phi i64 [ 0, %12 ], [ %53, %32 ]
%34 = phi double [ 0.000000e+00, %12 ], [ %52, %32 ]
%35 = phi i64 [ 0, %12 ], [ %54, %32 ]
%36 = getelementptr inbounds double, double* %1, i64 %33
%37 = load double, double* %36
%38 = getelementptr inbounds double, double* %2, i64 %33
%39 = load double, double* %38
%40 = fsub double %37, %39
%41 = tail call double @llvm.fabs.f64(double %40)
%42 = tail call double @pow(double %41, double %6)
%43 = fadd double %34, %42
%44 = or i64 %33, 1
%45 = getelementptr inbounds double, double* %1, i64 %44
%46 = load double, double* %45
%47 = getelementptr inbounds double, double* %2, i64 %44
%48 = load double, double* %47
%49 = fsub double %46, %48
%50 = tail call double @llvm.fabs.f64(double %49)
%51 = tail call double @pow(double %50, double %6)
%52 = fadd double %43, %51
%53 = add nuw nsw i64 %33, 2
%54 = add i64 %35, 2
%55 = icmp eq i64 %54, %13
br i1 %55, label %14, label %32
}