#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*/ fabs(double);
double sin(int /*<<< orphan*/);
int /*<<< orphan*/ sqrt(int /*<<< orphan*/);
double translate(unsigned short, int);
double schwefel(unsigned short (*pop)[10]) {
  double res = 418.9829 * 10;
  double loop = 0;
  double member = 0;
  for (int i = 0; i < 10; i++) {
    member = translate((*pop)[i], 500);
    loop -= member * sin(sqrt(fabs(member)));
  }
  return res + loop;
}


x86 assembly (clang, -O0):
<schwefel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  0xeac(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    11f6 <schwefel+0xb6>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    $0x1f4,%esi
movzwl (%rax,%rcx,2),%edi
call   1060 <translate@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1170 <schwefel+0x30>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<schwefel>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movzwl (%rdi),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movzwl 0x2(%rbx),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movzwl 0x4(%rbx),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movzwl 0x6(%rbx),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movzwl 0x8(%rbx),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movzwl 0xa(%rbx),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movzwl 0xc(%rbx),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movzwl 0xe(%rbx),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movzwl 0x10(%rbx),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movzwl 0x12(%rbx),%edi
mov    $0x1f4,%esi
call   1060 <translate@plt>
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
addsd  0xc6b(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @schwefel([10 x i16]* %0) {
%2 = alloca [10 x i16]*
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store [10 x i16]* %0, [10 x i16]** %2
store double 0x40B05DD439581062, double* %3
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
store i32 0, i32* %6
br label %7
7: ; preds = %25, %1
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load [10 x i16]*, [10 x i16]** %2
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i16], [10 x i16]* %11, i64 0, i64 %13
%15 = load i16, i16* %14
%16 = call double @translate(i16 zeroext %15, i32 500)
store double %16, double* %5
%17 = load double, double* %5
%18 = load double, double* %5
%19 = call i32 @fabs(double %18)
%20 = call i32 @sqrt(i32 %19)
%21 = call double @sin(i32 %20)
%22 = load double, double* %4
%23 = fneg double %17
%24 = call double @llvm.fmuladd.f64(double %23, double %21, double %22)
store double %24, double* %4
br label %25
25: ; preds = %10
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %7
28: ; preds = %7
%29 = load double, double* %3
%30 = load double, double* %4
%31 = fadd double %29, %30
ret double %31
}

LLVM IR (-O2):
define double @schwefel([10 x i16]* nocapture %0) {
%2 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 0
%3 = load i16, i16* %2
%4 = tail call double @translate(i16 zeroext %3, i32 500)
%5 = tail call i32 @fabs(double %4)
%6 = tail call i32 @sqrt(i32 %5)
%7 = tail call double @sin(i32 %6)
%8 = fneg double %4
%9 = tail call double @llvm.fmuladd.f64(double %8, double %7, double 0.000000e+00)
%10 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 1
%11 = load i16, i16* %10
%12 = tail call double @translate(i16 zeroext %11, i32 500)
%13 = tail call i32 @fabs(double %12)
%14 = tail call i32 @sqrt(i32 %13)
%15 = tail call double @sin(i32 %14)
%16 = fneg double %12
%17 = tail call double @llvm.fmuladd.f64(double %16, double %15, double %9)
%18 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 2
%19 = load i16, i16* %18
%20 = tail call double @translate(i16 zeroext %19, i32 500)
%21 = tail call i32 @fabs(double %20)
%22 = tail call i32 @sqrt(i32 %21)
%23 = tail call double @sin(i32 %22)
%24 = fneg double %20
%25 = tail call double @llvm.fmuladd.f64(double %24, double %23, double %17)
%26 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 3
%27 = load i16, i16* %26
%28 = tail call double @translate(i16 zeroext %27, i32 500)
%29 = tail call i32 @fabs(double %28)
%30 = tail call i32 @sqrt(i32 %29)
%31 = tail call double @sin(i32 %30)
%32 = fneg double %28
%33 = tail call double @llvm.fmuladd.f64(double %32, double %31, double %25)
%34 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 4
%35 = load i16, i16* %34
%36 = tail call double @translate(i16 zeroext %35, i32 500)
%37 = tail call i32 @fabs(double %36)
%38 = tail call i32 @sqrt(i32 %37)
%39 = tail call double @sin(i32 %38)
%40 = fneg double %36
%41 = tail call double @llvm.fmuladd.f64(double %40, double %39, double %33)
%42 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 5
%43 = load i16, i16* %42
%44 = tail call double @translate(i16 zeroext %43, i32 500)
%45 = tail call i32 @fabs(double %44)
%46 = tail call i32 @sqrt(i32 %45)
%47 = tail call double @sin(i32 %46)
%48 = fneg double %44
%49 = tail call double @llvm.fmuladd.f64(double %48, double %47, double %41)
%50 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 6
%51 = load i16, i16* %50
%52 = tail call double @translate(i16 zeroext %51, i32 500)
%53 = tail call i32 @fabs(double %52)
%54 = tail call i32 @sqrt(i32 %53)
%55 = tail call double @sin(i32 %54)
%56 = fneg double %52
%57 = tail call double @llvm.fmuladd.f64(double %56, double %55, double %49)
%58 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 7
%59 = load i16, i16* %58
%60 = tail call double @translate(i16 zeroext %59, i32 500)
%61 = tail call i32 @fabs(double %60)
%62 = tail call i32 @sqrt(i32 %61)
%63 = tail call double @sin(i32 %62)
%64 = fneg double %60
%65 = tail call double @llvm.fmuladd.f64(double %64, double %63, double %57)
%66 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 8
%67 = load i16, i16* %66
%68 = tail call double @translate(i16 zeroext %67, i32 500)
%69 = tail call i32 @fabs(double %68)
%70 = tail call i32 @sqrt(i32 %69)
%71 = tail call double @sin(i32 %70)
%72 = fneg double %68
%73 = tail call double @llvm.fmuladd.f64(double %72, double %71, double %65)
%74 = getelementptr inbounds [10 x i16], [10 x i16]* %0, i64 0, i64 9
%75 = load i16, i16* %74
%76 = tail call double @translate(i16 zeroext %75, i32 500)
%77 = tail call i32 @fabs(double %76)
%78 = tail call i32 @sqrt(i32 %77)
%79 = tail call double @sin(i32 %78)
%80 = fneg double %76
%81 = tail call double @llvm.fmuladd.f64(double %80, double %79, double %73)
%82 = fadd double %81, 0x40B05DD439581062
ret double %82
}