#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__ dist_nearest_point(double *, int, double **, int);
scalar_t__ fabs(scalar_t__);
int /*<<< orphan*/ free_matrix(void **, int);
int /*<<< orphan*/ free_vector(double *);
double **get_extreme_sols(double **, int, int);
double *get_max_values(double **, int, int);
double *get_min_values(double **, int, int);
double **normalize_front(double **, int, int, double *, double *);
double generalized_spread_original(double **front, int frontlen,
                                   double **truefront, int truefrontlen,
                                   int nobj) {
  size_t i;
  double sum, sum_extremis, dbar, res;
  double *min_values, *max_values;
  double **extreme_sols, **norm_front, **norm_truefront;
  min_values = get_min_values(truefront, truefrontlen, nobj);
  max_values = get_max_values(truefront, truefrontlen, nobj);
  norm_front = normalize_front(front, frontlen, nobj, min_values, max_values);
  norm_truefront =
      normalize_front(truefront, truefrontlen, nobj, min_values, max_values);
  extreme_sols = get_extreme_sols(norm_truefront, truefrontlen, nobj);
  dbar = 0;
  for (i = 0; i < truefrontlen; i++) {
    dbar += dist_nearest_point(norm_truefront[i], nobj, norm_front, frontlen);
  }
  dbar = dbar / truefrontlen;
  sum_extremis = 0;
  for (i = 0; i < nobj; i++) {
    sum_extremis +=
        dist_nearest_point(extreme_sols[i], nobj, norm_front, frontlen);
  }
  sum = 0;
  for (i = 0; i < truefrontlen; i++) {
    sum +=
        fabs(dist_nearest_point(norm_truefront[i], nobj, norm_front, frontlen) -
             dbar);
  }
  res = (sum + sum_extremis) / (sum_extremis + truefrontlen * dbar);
  free_matrix((void **)norm_front, frontlen);
  free_matrix((void **)norm_truefront, truefrontlen);
  free_matrix((void **)extreme_sols, nobj);
  free_vector(min_values);
  free_vector(max_values);
  return (res);
}


x86 assembly (clang, -O0):
<generalized_spread_original>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1080 <get_min_values@plt>
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1090 <get_max_values@plt>
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%r8
call   10a0 <normalize_front@plt>
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%r8
call   10a0 <normalize_front@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <get_extreme_sols@plt>
mov    %rax,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
jae    1265 <generalized_spread_original+0xe5>
mov    -0x70(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%esi
mov    -0x68(%rbp),%rdx
mov    -0xc(%rbp),%ecx
call   1070 <dist_nearest_point@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1219 <generalized_spread_original+0x99>
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmp    %rcx,%rax
jae    12d4 <generalized_spread_original+0x154>
mov    -0x60(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%esi
mov    -0x68(%rbp),%rdx
mov    -0xc(%rbp),%ecx
call   1070 <dist_nearest_point@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1288 <generalized_spread_original+0x108>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
jae    1344 <generalized_spread_original+0x1c4>
mov    -0x70(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%esi
mov    -0x68(%rbp),%rdx
mov    -0xc(%rbp),%ecx
call   1070 <dist_nearest_point@plt>
cvtsi2sd %rax,%xmm0
subsd  -0x40(%rbp),%xmm0
cvttsd2si %xmm0,%rdi
call   1060 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    12e4 <generalized_spread_original+0x164>
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <free_matrix@plt>
mov    -0x70(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <free_matrix@plt>
mov    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1040 <free_matrix@plt>
mov    -0x50(%rbp),%rdi
call   1050 <free_vector@plt>
mov    -0x58(%rbp),%rdi
call   1050 <free_vector@plt>
movsd  -0x48(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generalized_spread_original>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8d,%r14d
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %esi,%r13d
mov    %esi,0x2c(%rsp)
mov    %rdi,0x8(%rsp)
mov    %rdx,%rdi
mov    %ecx,%esi
mov    %r8d,%edx
call   1080 <get_min_values@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
call   1090 <get_max_values@plt>
mov    %rax,%r12
mov    0x8(%rsp),%rdi
mov    %r13d,%esi
mov    %r14d,%edx
mov    %rbp,%rcx
mov    %rax,%r8
call   10a0 <normalize_front@plt>
mov    %rax,%r13
mov    %r15,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %rbp,0x50(%rsp)
mov    %rbp,%rcx
mov    %r12,0x48(%rsp)
mov    %r12,%r8
mov    0x2c(%rsp),%r12d
call   10a0 <normalize_front@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
call   1030 <get_extreme_sols@plt>
mov    %rax,0x40(%rsp)
mov    %ebx,0x14(%rsp)
movslq %ebx,%rax
xorps  %xmm0,%xmm0
mov    %rax,0x18(%rsp)
test   %eax,%eax
je     127f <generalized_spread_original+0xff>
mov    0x18(%rsp),%rax
cmp    $0x2,%rax
mov    $0x1,%ebx
cmovae %rax,%rbx
xorps  %xmm0,%xmm0
xor    %ebp,%ebp
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
mov    (%r15,%rbp,8),%rdi
mov    %r14d,%esi
mov    %r13,%rdx
mov    %r12d,%ecx
call   1070 <dist_nearest_point@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1240 <generalized_spread_original+0xc0>
movsd  %xmm0,0x8(%rsp)
mov    %r15,0x30(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x14(%rsp),%xmm0
movsd  %xmm0,0x38(%rsp)
test   %r14d,%r14d
mov    0x40(%rsp),%r15
xorpd  %xmm0,%xmm0
je     12ef <generalized_spread_original+0x16f>
movslq %r14d,%rbx
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
movsd  %xmm0,0x20(%rsp)
mov    (%r15,%rbp,8),%rdi
mov    %r14d,%esi
mov    %r13,%rdx
mov    %r12d,%ecx
call   1070 <dist_nearest_point@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x20(%rsp),%xmm0
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    12b0 <generalized_spread_original+0x130>
movsd  %xmm0,0x20(%rsp)
mov    %r12d,%ebp
movsd  0x8(%rsp),%xmm0
divsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
cmpl   $0x0,0x14(%rsp)
je     137c <generalized_spread_original+0x1fc>
mov    0x18(%rsp),%rax
cmp    $0x2,%rax
mov    $0x1,%r12d
cmovae %rax,%r12
xorpd  %xmm1,%xmm1
xor    %r15d,%r15d
mov    0x30(%rsp),%rbx
movsd  %xmm1,0x18(%rsp)
mov    (%rbx,%r15,8),%rdi
mov    %r14d,%esi
mov    %r13,%rdx
mov    %ebp,%ecx
call   1070 <dist_nearest_point@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
subsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1060 <fabs@plt>
movsd  0x18(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm1
add    $0x1,%r15
cmp    %r15,%r12
jne    1330 <generalized_spread_original+0x1b0>
jmp    1385 <generalized_spread_original+0x205>
xorpd  %xmm1,%xmm1
mov    0x30(%rsp),%rbx
movsd  0x20(%rsp),%xmm0
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm2
movsd  0x38(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%rsp)
mov    %r13,%rdi
mov    %ebp,%esi
call   1040 <free_matrix@plt>
mov    %rbx,%rdi
mov    0x14(%rsp),%esi
call   1040 <free_matrix@plt>
mov    0x40(%rsp),%rdi
mov    %r14d,%esi
call   1040 <free_matrix@plt>
mov    0x50(%rsp),%rdi
call   1050 <free_vector@plt>
mov    0x48(%rsp),%rdi
call   1050 <free_vector@plt>
movsd  0x18(%rsp),%xmm0
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @generalized_spread_original(double** %0, i32 %1, double** %2, i32 %3, i32 %4) {
%6 = alloca double**
%7 = alloca i32
%8 = alloca double**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double*
%17 = alloca double*
%18 = alloca double**
%19 = alloca double**
%20 = alloca double**
store double** %0, double*** %6
store i32 %1, i32* %7
store double** %2, double*** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%21 = load double**, double*** %8
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = call double* @get_min_values(double** %21, i32 %22, i32 %23)
store double* %24, double** %16
%25 = load double**, double*** %8
%26 = load i32, i32* %9
%27 = load i32, i32* %10
%28 = call double* @get_max_values(double** %25, i32 %26, i32 %27)
store double* %28, double** %17
%29 = load double**, double*** %6
%30 = load i32, i32* %7
%31 = load i32, i32* %10
%32 = load double*, double** %16
%33 = load double*, double** %17
%34 = call double** @normalize_front(double** %29, i32 %30, i32 %31, double* %32, double* %33)
store double** %34, double*** %19
%35 = load double**, double*** %8
%36 = load i32, i32* %9
%37 = load i32, i32* %10
%38 = load double*, double** %16
%39 = load double*, double** %17
%40 = call double** @normalize_front(double** %35, i32 %36, i32 %37, double* %38, double* %39)
store double** %40, double*** %20
%41 = load double**, double*** %20
%42 = load i32, i32* %9
%43 = load i32, i32* %10
%44 = call double** @get_extreme_sols(double** %41, i32 %42, i32 %43)
store double** %44, double*** %18
store double 0.000000e+00, double* %14
store i64 0, i64* %11
br label %45
45: ; preds = %62, %5
%46 = load i64, i64* %11
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = icmp ult i64 %46, %48
br i1 %49, label %50, label %65
50: ; preds = %45
%51 = load double**, double*** %20
%52 = load i64, i64* %11
%53 = getelementptr inbounds double*, double** %51, i64 %52
%54 = load double*, double** %53
%55 = load i32, i32* %10
%56 = load double**, double*** %19
%57 = load i32, i32* %7
%58 = call i64 @dist_nearest_point(double* %54, i32 %55, double** %56, i32 %57)
%59 = sitofp i64 %58 to double
%60 = load double, double* %14
%61 = fadd double %60, %59
store double %61, double* %14
br label %62
62: ; preds = %50
%63 = load i64, i64* %11
%64 = add i64 %63, 1
store i64 %64, i64* %11
br label %45
65: ; preds = %45
%66 = load double, double* %14
%67 = load i32, i32* %9
%68 = sitofp i32 %67 to double
%69 = fdiv double %66, %68
store double %69, double* %14
store double 0.000000e+00, double* %13
store i64 0, i64* %11
br label %70
70: ; preds = %87, %65
%71 = load i64, i64* %11
%72 = load i32, i32* %10
%73 = sext i32 %72 to i64
%74 = icmp ult i64 %71, %73
br i1 %74, label %75, label %90
75: ; preds = %70
%76 = load double**, double*** %18
%77 = load i64, i64* %11
%78 = getelementptr inbounds double*, double** %76, i64 %77
%79 = load double*, double** %78
%80 = load i32, i32* %10
%81 = load double**, double*** %19
%82 = load i32, i32* %7
%83 = call i64 @dist_nearest_point(double* %79, i32 %80, double** %81, i32 %82)
%84 = sitofp i64 %83 to double
%85 = load double, double* %13
%86 = fadd double %85, %84
store double %86, double* %13
br label %87
87: ; preds = %75
%88 = load i64, i64* %11
%89 = add i64 %88, 1
store i64 %89, i64* %11
br label %70
90: ; preds = %70
store double 0.000000e+00, double* %12
store i64 0, i64* %11
br label %91
91: ; preds = %113, %90
%92 = load i64, i64* %11
%93 = load i32, i32* %9
%94 = sext i32 %93 to i64
%95 = icmp ult i64 %92, %94
br i1 %95, label %96, label %116
96: ; preds = %91
%97 = load double**, double*** %20
%98 = load i64, i64* %11
%99 = getelementptr inbounds double*, double** %97, i64 %98
%100 = load double*, double** %99
%101 = load i32, i32* %10
%102 = load double**, double*** %19
%103 = load i32, i32* %7
%104 = call i64 @dist_nearest_point(double* %100, i32 %101, double** %102, i32 %103)
%105 = sitofp i64 %104 to double
%106 = load double, double* %14
%107 = fsub double %105, %106
%108 = fptosi double %107 to i64
%109 = call i64 @fabs(i64 %108)
%110 = sitofp i64 %109 to double
%111 = load double, double* %12
%112 = fadd double %111, %110
store double %112, double* %12
br label %113
113: ; preds = %96
%114 = load i64, i64* %11
%115 = add i64 %114, 1
store i64 %115, i64* %11
br label %91
116: ; preds = %91
%117 = load double, double* %12
%118 = load double, double* %13
%119 = fadd double %117, %118
%120 = load double, double* %13
%121 = load i32, i32* %9
%122 = sitofp i32 %121 to double
%123 = load double, double* %14
%124 = call double @llvm.fmuladd.f64(double %122, double %123, double %120)
%125 = fdiv double %119, %124
store double %125, double* %15
%126 = load double**, double*** %19
%127 = bitcast double** %126 to i8**
%128 = load i32, i32* %7
%129 = call i32 @free_matrix(i8** %127, i32 %128)
%130 = load double**, double*** %20
%131 = bitcast double** %130 to i8**
%132 = load i32, i32* %9
%133 = call i32 @free_matrix(i8** %131, i32 %132)
%134 = load double**, double*** %18
%135 = bitcast double** %134 to i8**
%136 = load i32, i32* %10
%137 = call i32 @free_matrix(i8** %135, i32 %136)
%138 = load double*, double** %16
%139 = call i32 @free_vector(double* %138)
%140 = load double*, double** %17
%141 = call i32 @free_vector(double* %140)
%142 = load double, double* %15
ret double %142
}

LLVM IR (-O2):
define double @generalized_spread_original(double** %0, i32 %1, double** %2, i32 %3, i32 %4) {
%6 = tail call double* @get_min_values(double** %2, i32 %3, i32 %4)
%7 = tail call double* @get_max_values(double** %2, i32 %3, i32 %4)
%8 = tail call double** @normalize_front(double** %0, i32 %1, i32 %4, double* %6, double* %7)
%9 = tail call double** @normalize_front(double** %2, i32 %3, i32 %4, double* %6, double* %7)
%10 = tail call double** @get_extreme_sols(double** %9, i32 %3, i32 %4)
%11 = sext i32 %3 to i64
%12 = icmp eq i32 %3, 0
br i1 %12, label %25, label %13
13: ; preds = %5
%14 = call i64 @llvm.umax.i64(i64 %11, i64 1)
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ %23, %15 ], [ 0, %13 ]
%17 = phi double [ %22, %15 ], [ 0.000000e+00, %13 ]
%18 = getelementptr inbounds double*, double** %9, i64 %16
%19 = load double*, double** %18
%20 = tail call i64 @dist_nearest_point(double* %19, i32 %4, double** %8, i32 %1)
%21 = sitofp i64 %20 to double
%22 = fadd double %17, %21
%23 = add nuw i64 %16, 1
%24 = icmp eq i64 %23, %14
br i1 %24, label %25, label %15
25: ; preds = %15, %5
%26 = phi double [ 0.000000e+00, %5 ], [ %22, %15 ]
%27 = sitofp i32 %3 to double
%28 = fdiv double %26, %27
%29 = icmp eq i32 %4, 0
br i1 %29, label %32, label %30
30: ; preds = %25
%31 = sext i32 %4 to i64
br label %36
32: ; preds = %36, %25
%33 = phi double [ 0.000000e+00, %25 ], [ %43, %36 ]
br i1 %12, label %60, label %34
34: ; preds = %32
%35 = call i64 @llvm.umax.i64(i64 %11, i64 1)
br label %46
36: ; preds = %30, %36
%37 = phi i64 [ %44, %36 ], [ 0, %30 ]
%38 = phi double [ %43, %36 ], [ 0.000000e+00, %30 ]
%39 = getelementptr inbounds double*, double** %10, i64 %37
%40 = load double*, double** %39
%41 = tail call i64 @dist_nearest_point(double* %40, i32 %4, double** %8, i32 %1)
%42 = sitofp i64 %41 to double
%43 = fadd double %38, %42
%44 = add nuw i64 %37, 1
%45 = icmp eq i64 %44, %31
br i1 %45, label %32, label %36
46: ; preds = %34, %46
%47 = phi i64 [ %58, %46 ], [ 0, %34 ]
%48 = phi double [ %57, %46 ], [ 0.000000e+00, %34 ]
%49 = getelementptr inbounds double*, double** %9, i64 %47
%50 = load double*, double** %49
%51 = tail call i64 @dist_nearest_point(double* %50, i32 %4, double** %8, i32 %1)
%52 = sitofp i64 %51 to double
%53 = fsub double %52, %28
%54 = fptosi double %53 to i64
%55 = tail call i64 @fabs(i64 %54)
%56 = sitofp i64 %55 to double
%57 = fadd double %48, %56
%58 = add nuw i64 %47, 1
%59 = icmp eq i64 %58, %35
br i1 %59, label %60, label %46
60: ; preds = %46, %32
%61 = phi double [ 0.000000e+00, %32 ], [ %57, %46 ]
%62 = fadd double %33, %61
%63 = tail call double @llvm.fmuladd.f64(double %27, double %28, double %33)
%64 = fdiv double %62, %63
%65 = bitcast double** %8 to i8**
%66 = tail call i32 @free_matrix(i8** %65, i32 %1)
%67 = bitcast double** %9 to i8**
%68 = tail call i32 @free_matrix(i8** %67, i32 %3)
%69 = bitcast double** %10 to i8**
%70 = tail call i32 @free_matrix(i8** %69, i32 %4)
%71 = tail call i32 @free_vector(double* %6)
%72 = tail call i32 @free_vector(double* %7)
ret double %64
}