#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 */
int /*<<< orphan*/ cf_cal(double *, double *, int, double *, double *, double *,
                          double *, int);
int /*<<< orphan*/ rastrigin_func(double *, double *, int, double *, double *,
                                  int);
int /*<<< orphan*/ schwefel_func(double *, double *, int, double *, double *,
                                 int);
int /*<<< orphan*/ weierstrass_func(double *, double *, int, double *, double *,
                                    int);
void cf04(double *x, double *f, int nx, double *Os, double *Mr, int r_flag) {
  int i, cf_num = 3;
  double fit[3];
  double delta[3] = {20, 20, 20};
  double bias[3] = {0, 100, 200};
  i = 0;
  schwefel_func(x, &fit[i], nx, &Os[i * nx], &Mr[i * nx * nx], r_flag);
  fit[i] = 1000 * fit[i] / 4e+3;
  i = 1;
  rastrigin_func(x, &fit[i], nx, &Os[i * nx], &Mr[i * nx * nx], r_flag);
  fit[i] = 1000 * fit[i] / 1e+3;
  i = 2;
  weierstrass_func(x, &fit[i], nx, &Os[i * nx], &Mr[i * nx * nx], r_flag);
  fit[i] = 1000 * fit[i] / 400;
  cf_cal(x, f, nx, Os, delta, bias, fit, cf_num);
}


x86 assembly (clang, -O0):
<cf04>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x3,-0x34(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xeaf(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xea9(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x80(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x30(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
mov    -0x2c(%rbp),%r9d
call   1030 <schwefel_func@plt>
movslq -0x30(%rbp),%rax
movsd  0xdf9(%rip),%xmm0
mulsd  -0x50(%rbp,%rax,8),%xmm0
movsd  0xdf3(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0x30(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
movl   $0x1,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x30(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
mov    -0x2c(%rbp),%r9d
call   1060 <rastrigin_func@plt>
movslq -0x30(%rbp),%rax
movsd  0xd7f(%rip),%xmm0
mulsd  -0x50(%rbp,%rax,8),%xmm0
movsd  0xd71(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0x30(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
movl   $0x2,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x30(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
mov    -0x2c(%rbp),%r9d
call   1040 <weierstrass_func@plt>
movslq -0x30(%rbp),%rax
movsd  0xd05(%rip),%xmm0
mulsd  -0x50(%rbp,%rax,8),%xmm0
movsd  0xcef(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0x30(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    -0x70(%rbp),%r8
lea    -0x90(%rbp),%r9
lea    -0x50(%rbp),%r10
mov    -0x34(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1050 <cf_cal@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cf04>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9d,%r13d
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rsi,0x18(%rsp)
mov    %rdi,%rbx
mov    0xec8(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
mov    0xed0(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rsp,%rsi
call   1030 <schwefel_func@plt>
movsd  (%rsp),%xmm0
mulsd  0xe5a(%rip),%xmm0
divsd  0xe5a(%rip),%xmm0
movsd  %xmm0,(%rsp)
lea    0x8(%rsp),%rsi
movslq %ebp,%r12
lea    (%r15,%r12,8),%rcx
mov    %r12d,%eax
imul   %eax,%eax
lea    (%r14,%rax,8),%r8
mov    %rbx,%rdi
mov    %r12d,%edx
mov    %r13d,%r9d
call   1060 <rastrigin_func@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xe1b(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%rsi
lea    (%r12,%r12,1),%eax
cltq
lea    (%r15,%rax,8),%rcx
imul   %r12d,%eax
cltq
lea    (%r14,%rax,8),%r8
mov    %rbx,%rdi
mov    %r12d,%edx
mov    %r13d,%r9d
call   1040 <weierstrass_func@plt>
movsd  0xdde(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0xde0(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0x40(%rsp),%r8
lea    0x20(%rsp),%r9
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
mov    %r12d,%edx
mov    %r15,%rcx
push   $0x3
lea    0x8(%rsp),%rax
push   %rax
call   1050 <cf_cal@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.cf04.delta = [3 x double] [double 2.000000e+01, double 2.000000e+01, double 2.000000e+01]
@__const.cf04.bias = [3 x double] [double 0.000000e+00, double 1.000000e+02, double 2.000000e+02]
define void @cf04(double* %0, double* %1, i32 %2, double* %3, double* %4, i32 %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [3 x double]
%16 = alloca [3 x double]
%17 = alloca [3 x double]
store double* %0, double** %7
store double* %1, double** %8
store i32 %2, i32* %9
store double* %3, double** %10
store double* %4, double** %11
store i32 %5, i32* %12
store i32 3, i32* %14
%18 = bitcast [3 x double]* %16 to i8*
%19 = bitcast [3 x double]* %17 to i8*
store i32 0, i32* %13
%20 = load double*, double** %7
%21 = load i32, i32* %13
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %22
%24 = load i32, i32* %9
%25 = load double*, double** %10
%26 = load i32, i32* %13
%27 = load i32, i32* %9
%28 = mul nsw i32 %26, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %25, i64 %29
%31 = load double*, double** %11
%32 = load i32, i32* %13
%33 = load i32, i32* %9
%34 = mul nsw i32 %32, %33
%35 = load i32, i32* %9
%36 = mul nsw i32 %34, %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %31, i64 %37
%39 = load i32, i32* %12
%40 = call i32 @schwefel_func(double* %20, double* %23, i32 %24, double* %30, double* %38, i32 %39)
%41 = load i32, i32* %13
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %42
%44 = load double, double* %43
%45 = fmul double 1.000000e+03, %44
%46 = fdiv double %45, 4.000000e+03
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %48
store double %46, double* %49
store i32 1, i32* %13
%50 = load double*, double** %7
%51 = load i32, i32* %13
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %52
%54 = load i32, i32* %9
%55 = load double*, double** %10
%56 = load i32, i32* %13
%57 = load i32, i32* %9
%58 = mul nsw i32 %56, %57
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %55, i64 %59
%61 = load double*, double** %11
%62 = load i32, i32* %13
%63 = load i32, i32* %9
%64 = mul nsw i32 %62, %63
%65 = load i32, i32* %9
%66 = mul nsw i32 %64, %65
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %61, i64 %67
%69 = load i32, i32* %12
%70 = call i32 @rastrigin_func(double* %50, double* %53, i32 %54, double* %60, double* %68, i32 %69)
%71 = load i32, i32* %13
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %72
%74 = load double, double* %73
%75 = fmul double 1.000000e+03, %74
%76 = fdiv double %75, 1.000000e+03
%77 = load i32, i32* %13
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %78
store double %76, double* %79
store i32 2, i32* %13
%80 = load double*, double** %7
%81 = load i32, i32* %13
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %82
%84 = load i32, i32* %9
%85 = load double*, double** %10
%86 = load i32, i32* %13
%87 = load i32, i32* %9
%88 = mul nsw i32 %86, %87
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %85, i64 %89
%91 = load double*, double** %11
%92 = load i32, i32* %13
%93 = load i32, i32* %9
%94 = mul nsw i32 %92, %93
%95 = load i32, i32* %9
%96 = mul nsw i32 %94, %95
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %91, i64 %97
%99 = load i32, i32* %12
%100 = call i32 @weierstrass_func(double* %80, double* %83, i32 %84, double* %90, double* %98, i32 %99)
%101 = load i32, i32* %13
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %102
%104 = load double, double* %103
%105 = fmul double 1.000000e+03, %104
%106 = fdiv double %105, 4.000000e+02
%107 = load i32, i32* %13
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 %108
store double %106, double* %109
%110 = load double*, double** %7
%111 = load double*, double** %8
%112 = load i32, i32* %9
%113 = load double*, double** %10
%114 = getelementptr inbounds [3 x double], [3 x double]* %16, i64 0, i64 0
%115 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%116 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 0
%117 = load i32, i32* %14
%118 = call i32 @cf_cal(double* %110, double* %111, i32 %112, double* %113, double* %114, double* %115, double* %116, i32 %117)
ret void
}

LLVM IR (-O2):
@__const.cf04.delta = [3 x double] [double 2.000000e+01, double 2.000000e+01, double 2.000000e+01]
@__const.cf04.bias = [3 x double] [double 0.000000e+00, double 1.000000e+02, double 2.000000e+02]
define void @cf04(double* %0, double* %1, i32 %2, double* %3, double* %4, i32 %5) {
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = alloca [3 x double]
%10 = bitcast [3 x double]* %7 to i8*
%11 = bitcast [3 x double]* %8 to i8*
%12 = bitcast [3 x double]* %9 to i8*
%13 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%14 = call i32 @schwefel_func(double* %0, double* %13, i32 %2, double* %3, double* %4, i32 %5)
%15 = load double, double* %13
%16 = fmul double %15, 1.000000e+03
%17 = fdiv double %16, 4.000000e+03
store double %17, double* %13
%18 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
%19 = sext i32 %2 to i64
%20 = getelementptr inbounds double, double* %3, i64 %19
%21 = mul nsw i32 %2, %2
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds double, double* %4, i64 %22
%24 = call i32 @rastrigin_func(double* %0, double* %18, i32 %2, double* %20, double* %23, i32 %5)
%25 = load double, double* %18
%26 = fmul double %25, 1.000000e+03
%27 = fdiv double %26, 1.000000e+03
store double %27, double* %18
%28 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
%29 = shl nsw i32 %2, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %3, i64 %30
%32 = mul nsw i32 %29, %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %4, i64 %33
%35 = call i32 @weierstrass_func(double* %0, double* %28, i32 %2, double* %31, double* %34, i32 %5)
%36 = load double, double* %28
%37 = fmul double %36, 1.000000e+03
%38 = fdiv double %37, 4.000000e+02
store double %38, double* %28
%39 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%40 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%41 = call i32 @cf_cal(double* %0, double* %1, i32 %2, double* %3, double* %39, double* %40, double* %13, i32 3)
ret void
}