#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 const);
double pow(double, double);
double minkowski_distance(const double *u, const double *v, int n, double p) {
  int i = 0;
  double s = 0.0, d;
  for (i = 0; i < n; i++) {
    d = fabs(u[i] - v[i]);
    s = s + pow(d, p);
  }
  return pow(s, 1.0 / p);
}


x86 assembly (clang, -O0):
<minkowski_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ac <minkowski_distance+0x9c>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xea5(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <minkowski_distance+0x2e>
movsd  -0x30(%rbp),%xmm0
movsd  0xe47(%rip),%xmm1
divsd  -0x20(%rbp),%xmm1
call   1030 <pow@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minkowski_distance>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edx,%edx
jle    1140 <minkowski_distance+0x30>
mov    %rsi,%r14
mov    %rdi,%r12
movsd  %xmm0,0x8(%rsp)
mov    %edx,%r15d
cmp    $0x1,%edx
jne    1149 <minkowski_distance+0x39>
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
jmp    11c5 <minkowski_distance+0xb5>
xorpd  %xmm2,%xmm2
jmp    1204 <minkowski_distance+0xf4>
mov    %r15d,%r13d
and    $0xfffffffe,%r13d
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
cs 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 <minkowski_distance+0x50>
test   $0x1,%r15b
movsd  0x8(%rsp),%xmm0
je     1204 <minkowski_distance+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 @minkowski_distance(double* %0, double* %1, i32 %2, double %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store double %3, double* %8
store i32 0, i32* %9
store double 0.000000e+00, double* %10
store i32 0, i32* %9
br label %12
12: ; preds = %34, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %37
16: ; preds = %12
%17 = load double*, double** %5
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = load double*, double** %6
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = fsub double %21, %26
%28 = call double @llvm.fabs.f64(double %27)
store double %28, double* %11
%29 = load double, double* %10
%30 = load double, double* %11
%31 = load double, double* %8
%32 = call double @pow(double %30, double %31)
%33 = fadd double %29, %32
store double %33, double* %10
br label %34
34: ; preds = %16
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %12
37: ; preds = %12
%38 = load double, double* %10
%39 = load double, double* %8
%40 = fdiv double 1.000000e+00, %39
%41 = call double @pow(double %38, double %40)
ret double %41
}

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