#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 */
typedef scalar_t__ int8_t;

/* Variables and functions */
double get_cube_offset_double(scalar_t__, double *, double *);
double get_min_dist_double(double *point_coord, int8_t no_dims, double *bbox) {
  double cube_offset = 0, cube_offset_dim;
  int8_t i;
  for (i = 0; i < no_dims; i++) {
    cube_offset_dim = get_cube_offset_double(i, point_coord, bbox);
    cube_offset += cube_offset_dim * cube_offset_dim;
  }
  return cube_offset;
}


x86 assembly (clang, -O0):
<get_min_dist_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1185 <get_min_dist_double+0x75>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <get_cube_offset_double@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1134 <get_min_dist_double+0x24>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_min_dist_double>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
jle    1165 <get_min_dist_double+0x55>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <get_cube_offset_double@plt>
mulsd  %xmm0,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <get_min_dist_double+0x20>
jmp    1169 <get_min_dist_double+0x59>
xorpd  %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @get_min_dist_double(double* %0, i64 %1, double* %2) {
%4 = alloca double*
%5 = alloca i64
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca i64
store double* %0, double** %4
store i64 %1, i64* %5
store double* %2, double** %6
store double 0.000000e+00, double* %7
store i64 0, i64* %9
br label %10
10: ; preds = %23, %3
%11 = load i64, i64* %9
%12 = load i64, i64* %5
%13 = icmp slt i64 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load i64, i64* %9
%16 = load double*, double** %4
%17 = load double*, double** %6
%18 = call double @get_cube_offset_double(i64 %15, double* %16, double* %17)
store double %18, double* %8
%19 = load double, double* %8
%20 = load double, double* %8
%21 = load double, double* %7
%22 = call double @llvm.fmuladd.f64(double %19, double %20, double %21)
store double %22, double* %7
br label %23
23: ; preds = %14
%24 = load i64, i64* %9
%25 = add nsw i64 %24, 1
store i64 %25, i64* %9
br label %10
26: ; preds = %10
%27 = load double, double* %7
ret double %27
}

LLVM IR (-O2):
define double @get_min_dist_double(double* %0, i64 %1, double* %2) {
%4 = icmp sgt i64 %1, 0
br i1 %4, label %5, label %12
5: ; preds = %3, %5
%6 = phi i64 [ %10, %5 ], [ 0, %3 ]
%7 = phi double [ %9, %5 ], [ 0.000000e+00, %3 ]
%8 = tail call double @get_cube_offset_double(i64 %6, double* %0, double* %2)
%9 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %7)
%10 = add nuw nsw i64 %6, 1
%11 = icmp eq i64 %10, %1
br i1 %11, label %12, label %5
12: ; preds = %5, %3
%13 = phi double [ 0.000000e+00, %3 ], [ %9, %5 ]
ret double %13
}