#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 cos(int);
double shubert(double x1, double x2) {
  double sum1 = 0;
  double sum2 = 0;
  int i;
  for (i = 1; i <= 5; i++) {
    sum1 += i * cos((i + 1) * x1 + i);
    sum2 += i * cos((i + 1) * x2 + i);
  }
  return sum1 * sum2;
}


x86 assembly (clang, -O0):
<shubert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jg     11d3 <shubert+0xc3>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x8(%rbp),%xmm2
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x10(%rbp),%xmm2
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1139 <shubert+0x29>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shubert>:
sub    $0x28,%rsp
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  0xed0(%rip),%xmm1
cvttsd2si %xmm1,%edi
call   1030 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
addsd  %xmm0,%xmm0
addsd  0xea8(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe8c(%rip),%xmm0
addsd  0xe8c(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  0xe58(%rip),%xmm0
addsd  0xe58(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe34(%rip),%xmm0
addsd  0xe1c(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
lea    (%rax,%rax,2),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  0xdff(%rip),%xmm0
addsd  0xde7(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
lea    (%rax,%rax,2),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xdd2(%rip),%xmm0
addsd  0xdc2(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
shl    $0x2,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  0xd9d(%rip),%xmm0
addsd  0xd8d(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
shl    $0x2,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xd70(%rip),%xmm0
addsd  0xd60(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
lea    (%rax,%rax,4),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  0xd3b(%rip),%xmm0
addsd  0xd2b(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
lea    (%rax,%rax,4),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x10(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @shubert(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %3
store double %1, double* %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store i32 1, i32* %7
br label %8
8: ; preds = %40, %2
%9 = load i32, i32* %7
%10 = icmp sle i32 %9, 5
br i1 %10, label %11, label %43
11: ; preds = %8
%12 = load i32, i32* %7
%13 = load i32, i32* %7
%14 = add nsw i32 %13, 1
%15 = sitofp i32 %14 to double
%16 = load double, double* %3
%17 = load i32, i32* %7
%18 = sitofp i32 %17 to double
%19 = call double @llvm.fmuladd.f64(double %15, double %16, double %18)
%20 = fptosi double %19 to i32
%21 = call i32 @cos(i32 %20)
%22 = mul nsw i32 %12, %21
%23 = sitofp i32 %22 to double
%24 = load double, double* %5
%25 = fadd double %24, %23
store double %25, double* %5
%26 = load i32, i32* %7
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
%29 = sitofp i32 %28 to double
%30 = load double, double* %4
%31 = load i32, i32* %7
%32 = sitofp i32 %31 to double
%33 = call double @llvm.fmuladd.f64(double %29, double %30, double %32)
%34 = fptosi double %33 to i32
%35 = call i32 @cos(i32 %34)
%36 = mul nsw i32 %26, %35
%37 = sitofp i32 %36 to double
%38 = load double, double* %6
%39 = fadd double %38, %37
store double %39, double* %6
br label %40
40: ; preds = %11
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %8
43: ; preds = %8
%44 = load double, double* %5
%45 = load double, double* %6
%46 = fmul double %44, %45
ret double %46
}

LLVM IR (-O2):
define double @shubert(double %0, double %1) {
%3 = tail call double @llvm.fmuladd.f64(double %0, double 2.000000e+00, double 1.000000e+00)
%4 = fptosi double %3 to i32
%5 = tail call i32 @cos(i32 %4)
%6 = sitofp i32 %5 to double
%7 = tail call double @llvm.fmuladd.f64(double %1, double 2.000000e+00, double 1.000000e+00)
%8 = fptosi double %7 to i32
%9 = tail call i32 @cos(i32 %8)
%10 = sitofp i32 %9 to double
%11 = tail call double @llvm.fmuladd.f64(double %0, double 3.000000e+00, double 2.000000e+00)
%12 = fptosi double %11 to i32
%13 = tail call i32 @cos(i32 %12)
%14 = shl nsw i32 %13, 1
%15 = sitofp i32 %14 to double
%16 = fadd double %6, %15
%17 = tail call double @llvm.fmuladd.f64(double %1, double 3.000000e+00, double 2.000000e+00)
%18 = fptosi double %17 to i32
%19 = tail call i32 @cos(i32 %18)
%20 = shl nsw i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = fadd double %10, %21
%23 = tail call double @llvm.fmuladd.f64(double %0, double 4.000000e+00, double 3.000000e+00)
%24 = fptosi double %23 to i32
%25 = tail call i32 @cos(i32 %24)
%26 = mul nsw i32 %25, 3
%27 = sitofp i32 %26 to double
%28 = fadd double %16, %27
%29 = tail call double @llvm.fmuladd.f64(double %1, double 4.000000e+00, double 3.000000e+00)
%30 = fptosi double %29 to i32
%31 = tail call i32 @cos(i32 %30)
%32 = mul nsw i32 %31, 3
%33 = sitofp i32 %32 to double
%34 = fadd double %22, %33
%35 = tail call double @llvm.fmuladd.f64(double %0, double 5.000000e+00, double 4.000000e+00)
%36 = fptosi double %35 to i32
%37 = tail call i32 @cos(i32 %36)
%38 = shl nsw i32 %37, 2
%39 = sitofp i32 %38 to double
%40 = fadd double %28, %39
%41 = tail call double @llvm.fmuladd.f64(double %1, double 5.000000e+00, double 4.000000e+00)
%42 = fptosi double %41 to i32
%43 = tail call i32 @cos(i32 %42)
%44 = shl nsw i32 %43, 2
%45 = sitofp i32 %44 to double
%46 = fadd double %34, %45
%47 = tail call double @llvm.fmuladd.f64(double %0, double 6.000000e+00, double 5.000000e+00)
%48 = fptosi double %47 to i32
%49 = tail call i32 @cos(i32 %48)
%50 = mul nsw i32 %49, 5
%51 = sitofp i32 %50 to double
%52 = fadd double %40, %51
%53 = tail call double @llvm.fmuladd.f64(double %1, double 6.000000e+00, double 5.000000e+00)
%54 = fptosi double %53 to i32
%55 = tail call i32 @cos(i32 %54)
%56 = mul nsw i32 %55, 5
%57 = sitofp i32 %56 to double
%58 = fadd double %46, %57
%59 = fmul double %52, %58
ret double %59
}