#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 */
double fabs(double);
double pow(double, double);
double sin(int /*<<< orphan*/);
int /*<<< orphan*/ sqrt(double);
double nc_schaffer(double x, double y) {
  int i;
  int a;
  double b;
  double res;
  double temp1, temp2;
  double t1[2], t2[2];
  t1[0] = x;
  t1[1] = y;
  for (i = 0; i < 2; i++) {
    if (fabs(t1[i]) >= 0.5) {
      res = 2.0 * t1[i];
      a = res;
      b = fabs(res - a);
      if (b < 0.5) {
        t2[i] = a / 2.0;
      } else {
        if (res <= 0.0) {
          t2[i] = (a - 1.0) / 2.0;
        } else {
          t2[i] = (a + 1.0) / 2.0;
        }
      }
    } else {
      t2[i] = t1[i];
    }
  }
  temp1 = pow((sin(sqrt(pow(t2[0], 2.0) + pow(t2[1], 2.0)))), 2.0);
  temp2 = 1.0 + 0.001 * (pow(t2[0], 2.0) + pow(t2[1], 2.0));
  res = 0.5 + (temp1 - 0.5) / (pow(temp2, 2.0));
  return (res);
}


x86 assembly (clang, -O0):
<nc_schaffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    1293 <nc_schaffer+0x163>
movslq -0x14(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm0
movaps 0xea5(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe79(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     126c <nc_schaffer+0x13c>
movslq -0x14(%rbp),%rax
movsd  0xe6b(%rip),%xmm0
mulsd  -0x50(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvttsd2si -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
subsd  %xmm1,%xmm0
movaps 0xe5b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe2a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1201 <nc_schaffer+0xd1>
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xe1a(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
jmp    1267 <nc_schaffer+0x137>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     123b <nc_schaffer+0x10b>
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xdfc(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xde0(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
jmp    1262 <nc_schaffer+0x132>
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xdd0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xdb4(%rip),%xmm1
divsd  %xmm1,%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
jmp    1267 <nc_schaffer+0x137>
jmp    1280 <nc_schaffer+0x150>
movslq -0x14(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm0
movslq -0x14(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
jmp    1285 <nc_schaffer+0x155>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <nc_schaffer+0x30>
movsd  -0x60(%rbp),%xmm0
movsd  0xd68(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xd51(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1030 <sin@plt>
movsd  0xd2c(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xd15(%rip),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xcfe(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xced(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xce9(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xcbb(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xcad(%rip),%xmm1
call   1040 <pow@plt>
movsd  -0x68(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  0xc8f(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nc_schaffer>:
sub    $0x18,%rsp
movapd %xmm1,%xmm4
movapd 0xed0(%rip),%xmm1
andpd  %xmm0,%xmm1
ucomisd 0xed4(%rip),%xmm1
jb     119e <nc_schaffer+0x7e>
addsd  %xmm0,%xmm0
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
andpd  0xea6(%rip),%xmm2
movsd  0xeae(%rip),%xmm3
ucomisd %xmm2,%xmm3
jbe    1176 <nc_schaffer+0x56>
movsd  0xea0(%rip),%xmm0
mulsd  %xmm1,%xmm0
jmp    119e <nc_schaffer+0x7e>
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jae    118a <nc_schaffer+0x6a>
movsd  0xe98(%rip),%xmm0
jmp    1192 <nc_schaffer+0x72>
movsd  0xe86(%rip),%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe72(%rip),%xmm0
movapd 0xe5a(%rip),%xmm1
andpd  %xmm4,%xmm1
ucomisd 0xe5e(%rip),%xmm1
jb     1214 <nc_schaffer+0xf4>
addsd  %xmm4,%xmm4
cvttpd2dq %xmm4,%xmm1
cvtdq2pd %xmm1,%xmm1
movapd %xmm4,%xmm2
subsd  %xmm1,%xmm2
andpd  0xe30(%rip),%xmm2
movsd  0xe38(%rip),%xmm3
ucomisd %xmm2,%xmm3
jbe    11ec <nc_schaffer+0xcc>
movsd  0xe2a(%rip),%xmm4
mulsd  %xmm1,%xmm4
jmp    1214 <nc_schaffer+0xf4>
xorpd  %xmm2,%xmm2
ucomisd %xmm4,%xmm2
jae    1200 <nc_schaffer+0xe0>
movsd  0xe22(%rip),%xmm4
jmp    1208 <nc_schaffer+0xe8>
movsd  0xe10(%rip),%xmm4
addsd  %xmm1,%xmm4
mulsd  0xdfc(%rip),%xmm4
mulsd  %xmm0,%xmm0
mulsd  %xmm4,%xmm4
addsd  %xmm0,%xmm4
movapd %xmm4,(%rsp)
movapd %xmm4,%xmm0
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1030 <sin@plt>
mulsd  %xmm0,%xmm0
movapd (%rsp),%xmm1
mulsd  0xde2(%rip),%xmm1
addsd  0xdd2(%rip),%xmm1
addsd  0xdda(%rip),%xmm0
mulsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
addsd  0xdaa(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @nc_schaffer(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca [2 x double]
%12 = alloca [2 x double]
store double %0, double* %3
store double %1, double* %4
%13 = load double, double* %3
%14 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
store double %13, double* %14
%15 = load double, double* %4
%16 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 1
store double %15, double* %16
store i32 0, i32* %5
br label %17
17: ; preds = %79, %2
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %82
20: ; preds = %17
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 %22
%24 = load double, double* %23
%25 = call double @llvm.fabs.f64(double %24)
%26 = fcmp oge double %25, 5.000000e-01
br i1 %26, label %27, label %70
27: ; preds = %20
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 %29
%31 = load double, double* %30
%32 = fmul double 2.000000e+00, %31
store double %32, double* %8
%33 = load double, double* %8
%34 = fptosi double %33 to i32
store i32 %34, i32* %6
%35 = load double, double* %8
%36 = load i32, i32* %6
%37 = sitofp i32 %36 to double
%38 = fsub double %35, %37
%39 = call double @llvm.fabs.f64(double %38)
store double %39, double* %7
%40 = load double, double* %7
%41 = fcmp olt double %40, 5.000000e-01
br i1 %41, label %42, label %49
42: ; preds = %27
%43 = load i32, i32* %6
%44 = sitofp i32 %43 to double
%45 = fdiv double %44, 2.000000e+00
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 %47
store double %45, double* %48
br label %69
49: ; preds = %27
%50 = load double, double* %8
%51 = fcmp ole double %50, 0.000000e+00
br i1 %51, label %52, label %60
52: ; preds = %49
%53 = load i32, i32* %6
%54 = sitofp i32 %53 to double
%55 = fsub double %54, 1.000000e+00
%56 = fdiv double %55, 2.000000e+00
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 %58
store double %56, double* %59
br label %68
60: ; preds = %49
%61 = load i32, i32* %6
%62 = sitofp i32 %61 to double
%63 = fadd double %62, 1.000000e+00
%64 = fdiv double %63, 2.000000e+00
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 %66
store double %64, double* %67
br label %68
68: ; preds = %60, %52
br label %69
69: ; preds = %68, %42
br label %78
70: ; preds = %20
%71 = load i32, i32* %5
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 %72
%74 = load double, double* %73
%75 = load i32, i32* %5
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 %76
store double %74, double* %77
br label %78
78: ; preds = %70, %69
br label %79
79: ; preds = %78
%80 = load i32, i32* %5
%81 = add nsw i32 %80, 1
store i32 %81, i32* %5
br label %17
82: ; preds = %17
%83 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 0
%84 = load double, double* %83
%85 = call double @pow(double %84, double 2.000000e+00)
%86 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 1
%87 = load double, double* %86
%88 = call double @pow(double %87, double 2.000000e+00)
%89 = fadd double %85, %88
%90 = call i32 @sqrt(double %89)
%91 = call double @sin(i32 %90)
%92 = call double @pow(double %91, double 2.000000e+00)
store double %92, double* %9
%93 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 0
%94 = load double, double* %93
%95 = call double @pow(double %94, double 2.000000e+00)
%96 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 1
%97 = load double, double* %96
%98 = call double @pow(double %97, double 2.000000e+00)
%99 = fadd double %95, %98
%100 = call double @llvm.fmuladd.f64(double 1.000000e-03, double %99, double 1.000000e+00)
store double %100, double* %10
%101 = load double, double* %9
%102 = fsub double %101, 5.000000e-01
%103 = load double, double* %10
%104 = call double @pow(double %103, double 2.000000e+00)
%105 = fdiv double %102, %104
%106 = fadd double 5.000000e-01, %105
store double %106, double* %8
%107 = load double, double* %8
ret double %107
}

LLVM IR (-O2):
define double @nc_schaffer(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = fcmp ult double %3, 5.000000e-01
br i1 %4, label %22, label %5
5: ; preds = %2
%6 = fmul double %0, 2.000000e+00
%7 = fptosi double %6 to i32
%8 = sitofp i32 %7 to double
%9 = fsub double %6, %8
%10 = tail call double @llvm.fabs.f64(double %9)
%11 = fcmp olt double %10, 5.000000e-01
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = fmul double %8, 5.000000e-01
br label %22
14: ; preds = %5
%15 = fcmp ugt double %6, 0.000000e+00
br i1 %15, label %19, label %16
16: ; preds = %14
%17 = fadd double %8, -1.000000e+00
%18 = fmul double %17, 5.000000e-01
br label %22
19: ; preds = %14
%20 = fadd double %8, 1.000000e+00
%21 = fmul double %20, 5.000000e-01
br label %22
22: ; preds = %2, %16, %19, %12
%23 = phi double [ %13, %12 ], [ %21, %19 ], [ %18, %16 ], [ %0, %2 ]
%24 = tail call double @llvm.fabs.f64(double %1)
%25 = fcmp ult double %24, 5.000000e-01
br i1 %25, label %43, label %26
26: ; preds = %22
%27 = fmul double %1, 2.000000e+00
%28 = fptosi double %27 to i32
%29 = sitofp i32 %28 to double
%30 = fsub double %27, %29
%31 = tail call double @llvm.fabs.f64(double %30)
%32 = fcmp olt double %31, 5.000000e-01
br i1 %32, label %41, label %33
33: ; preds = %26
%34 = fcmp ugt double %27, 0.000000e+00
br i1 %34, label %38, label %35
35: ; preds = %33
%36 = fadd double %29, -1.000000e+00
%37 = fmul double %36, 5.000000e-01
br label %43
38: ; preds = %33
%39 = fadd double %29, 1.000000e+00
%40 = fmul double %39, 5.000000e-01
br label %43
41: ; preds = %26
%42 = fmul double %29, 5.000000e-01
br label %43
43: ; preds = %22, %41, %38, %35
%44 = phi double [ %42, %41 ], [ %40, %38 ], [ %37, %35 ], [ %1, %22 ]
%45 = fmul double %23, %23
%46 = fmul double %44, %44
%47 = fadd double %45, %46
%48 = tail call i32 @sqrt(double %47)
%49 = tail call double @sin(i32 %48)
%50 = fmul double %49, %49
%51 = tail call double @llvm.fmuladd.f64(double %47, double 1.000000e-03, double 1.000000e+00)
%52 = fadd double %50, -5.000000e-01
%53 = fmul double %51, %51
%54 = fdiv double %52, %53
%55 = fadd double %54, 5.000000e-01
ret double %55
}