#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 vecint_P1_2d(double *un, int *iv, double *cb, double *v) {
  double *u0, *u1, *u2, dd;
  u0 = &un[2 * (iv[0] - 1)];
  u1 = &un[2 * (iv[1] - 1)];
  u2 = &un[2 * (iv[2] - 1)];
  v[0] = cb[0] * u0[0] + cb[1] * u1[0] + cb[2] * u2[0];
  v[1] = cb[0] * u0[1] + cb[1] * u1[1] + cb[2] * u2[1];
  dd = sqrt(v[0] * v[0] + v[1] * v[1]);
  return (dd);
}


x86 assembly (clang, -O0):
<vecint_P1_2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%ecx
sub    $0x1,%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%ecx
sub    $0x1,%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x30(%rbp),%rax
mulsd  (%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x30(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x20(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vecint_P1_2d>:
mov    (%rsi),%eax
mov    0x4(%rsi),%r8d
add    %eax,%eax
add    $0xfffffffe,%eax
movslq %eax,%r9
lea    -0x2(%r8,%r8,1),%eax
cltq
mov    0x8(%rsi),%esi
lea    -0x2(%rsi,%rsi,1),%esi
movslq %esi,%rsi
movsd  (%rdx),%xmm1
movsd  0x8(%rdx),%xmm0
mulsd  (%rdi,%rax,8),%xmm0
mulsd  (%rdi,%r9,8),%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rdx),%xmm0
mulsd  (%rdi,%rsi,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx)
movsd  (%rdx),%xmm1
movsd  0x8(%rdx),%xmm2
mulsd  0x8(%rdi,%rax,8),%xmm2
mulsd  0x8(%rdi,%r9,8),%xmm1
addsd  %xmm2,%xmm1
movsd  0x10(%rdx),%xmm2
mulsd  0x8(%rdi,%rsi,8),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rcx)
mulsd  %xmm2,%xmm2
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11a2 <vecint_P1_2d+0x92>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define double @vecint_P1_2d(double* %0, i32* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca i32*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double
store double* %0, double** %5
store i32* %1, i32** %6
store double* %2, double** %7
store double* %3, double** %8
%13 = load double*, double** %5
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i64 0
%16 = load i32, i32* %15
%17 = sub nsw i32 %16, 1
%18 = mul nsw i32 2, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %13, i64 %19
store double* %20, double** %9
%21 = load double*, double** %5
%22 = load i32*, i32** %6
%23 = getelementptr inbounds i32, i32* %22, i64 1
%24 = load i32, i32* %23
%25 = sub nsw i32 %24, 1
%26 = mul nsw i32 2, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %21, i64 %27
store double* %28, double** %10
%29 = load double*, double** %5
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i64 2
%32 = load i32, i32* %31
%33 = sub nsw i32 %32, 1
%34 = mul nsw i32 2, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %29, i64 %35
store double* %36, double** %11
%37 = load double*, double** %7
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = load double*, double** %9
%41 = getelementptr inbounds double, double* %40, i64 0
%42 = load double, double* %41
%43 = load double*, double** %7
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = load double*, double** %10
%47 = getelementptr inbounds double, double* %46, i64 0
%48 = load double, double* %47
%49 = fmul double %45, %48
%50 = call double @llvm.fmuladd.f64(double %39, double %42, double %49)
%51 = load double*, double** %7
%52 = getelementptr inbounds double, double* %51, i64 2
%53 = load double, double* %52
%54 = load double*, double** %11
%55 = getelementptr inbounds double, double* %54, i64 0
%56 = load double, double* %55
%57 = call double @llvm.fmuladd.f64(double %53, double %56, double %50)
%58 = load double*, double** %8
%59 = getelementptr inbounds double, double* %58, i64 0
store double %57, double* %59
%60 = load double*, double** %7
%61 = getelementptr inbounds double, double* %60, i64 0
%62 = load double, double* %61
%63 = load double*, double** %9
%64 = getelementptr inbounds double, double* %63, i64 1
%65 = load double, double* %64
%66 = load double*, double** %7
%67 = getelementptr inbounds double, double* %66, i64 1
%68 = load double, double* %67
%69 = load double*, double** %10
%70 = getelementptr inbounds double, double* %69, i64 1
%71 = load double, double* %70
%72 = fmul double %68, %71
%73 = call double @llvm.fmuladd.f64(double %62, double %65, double %72)
%74 = load double*, double** %7
%75 = getelementptr inbounds double, double* %74, i64 2
%76 = load double, double* %75
%77 = load double*, double** %11
%78 = getelementptr inbounds double, double* %77, i64 1
%79 = load double, double* %78
%80 = call double @llvm.fmuladd.f64(double %76, double %79, double %73)
%81 = load double*, double** %8
%82 = getelementptr inbounds double, double* %81, i64 1
store double %80, double* %82
%83 = load double*, double** %8
%84 = getelementptr inbounds double, double* %83, i64 0
%85 = load double, double* %84
%86 = load double*, double** %8
%87 = getelementptr inbounds double, double* %86, i64 0
%88 = load double, double* %87
%89 = load double*, double** %8
%90 = getelementptr inbounds double, double* %89, i64 1
%91 = load double, double* %90
%92 = load double*, double** %8
%93 = getelementptr inbounds double, double* %92, i64 1
%94 = load double, double* %93
%95 = fmul double %91, %94
%96 = call double @llvm.fmuladd.f64(double %85, double %88, double %95)
%97 = call double @sqrt(double %96)
store double %97, double* %12
%98 = load double, double* %12
ret double %98
}

LLVM IR (-O2):
define double @vecint_P1_2d(double* nocapture %0, i32* nocapture %1, double* nocapture %2, double* nocapture %3) {
%5 = load i32, i32* %1
%6 = shl i32 %5, 1
%7 = add i32 %6, -2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = getelementptr inbounds i32, i32* %1, i64 1
%11 = load i32, i32* %10
%12 = shl i32 %11, 1
%13 = add i32 %12, -2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %0, i64 %14
%16 = getelementptr inbounds i32, i32* %1, i64 2
%17 = load i32, i32* %16
%18 = shl i32 %17, 1
%19 = add i32 %18, -2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %2
%23 = load double, double* %9
%24 = getelementptr inbounds double, double* %2, i64 1
%25 = load double, double* %24
%26 = load double, double* %15
%27 = fmul double %25, %26
%28 = tail call double @llvm.fmuladd.f64(double %22, double %23, double %27)
%29 = getelementptr inbounds double, double* %2, i64 2
%30 = load double, double* %29
%31 = load double, double* %21
%32 = tail call double @llvm.fmuladd.f64(double %30, double %31, double %28)
store double %32, double* %3
%33 = load double, double* %2
%34 = getelementptr inbounds double, double* %9, i64 1
%35 = load double, double* %34
%36 = load double, double* %24
%37 = getelementptr inbounds double, double* %15, i64 1
%38 = load double, double* %37
%39 = fmul double %36, %38
%40 = tail call double @llvm.fmuladd.f64(double %33, double %35, double %39)
%41 = load double, double* %29
%42 = getelementptr inbounds double, double* %21, i64 1
%43 = load double, double* %42
%44 = tail call double @llvm.fmuladd.f64(double %41, double %43, double %40)
%45 = getelementptr inbounds double, double* %3, i64 1
store double %44, double* %45
%46 = fmul double %44, %44
%47 = tail call double @llvm.fmuladd.f64(double %32, double %32, double %46)
%48 = tail call double @sqrt(double %47)
ret double %48
}