#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 */
scalar_t__ pow(double const, int);
double sqrt(double);
double hypotenuse(const int numInputs, const double *inputs,
                  const double *connectionWeights) {
  int i;
  double sumOfSqrs = 0;
  double hypt;
  for (i = 0; i < numInputs; i++) {
    sumOfSqrs += pow(inputs[i], 2);
  }
  hypt = sqrt(sumOfSqrs);
  return hypt;
}


x86 assembly (clang, -O0):
<hypotenuse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1182 <hypotenuse+0x62>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1142 <hypotenuse+0x22>
movsd  -0x28(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hypotenuse>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xorpd  %xmm0,%xmm0
test   %edi,%edi
jle    1249 <hypotenuse+0x129>
mov    %rsi,%r12
mov    %edi,%r15d
lea    -0x1(%r15),%rax
mov    %r15d,%r14d
and    $0x3,%r14d
cmp    $0x3,%rax
jae    1156 <hypotenuse+0x36>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    11f8 <hypotenuse+0xd8>
and    $0xfffffffc,%r15d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
movsd  %xmm0,(%rsp)
movsd  (%r12,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%r12,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%r12,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%r12,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
add    $0x4,%rbx
cmp    %rbx,%r15
jne    1160 <hypotenuse+0x40>
test   %r14,%r14
je     1249 <hypotenuse+0x129>
lea    (%r12,%rbx,8),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm0,(%rsp)
movsd  (%r15,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1210 <hypotenuse+0xf0>
ucomisd 0xdaf(%rip),%xmm0
jb     1263 <hypotenuse+0x143>
sqrtsd %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define double @hypotenuse(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
store double 0.000000e+00, double* %8
store i32 0, i32* %7
br label %10
10: ; preds = %24, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load double*, double** %5
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = call i64 @pow(double %19, i32 2)
%21 = sitofp i64 %20 to double
%22 = load double, double* %8
%23 = fadd double %22, %21
store double %23, double* %8
br label %24
24: ; preds = %14
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %10
27: ; preds = %10
%28 = load double, double* %8
%29 = call double @sqrt(double %28)
store double %29, double* %9
%30 = load double, double* %9
ret double %30
}

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