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


x86 assembly (clang, -O0):
<shubert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jg     11e9 <shubert+0xd9>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xeaa(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe5e(%rip),%xmm1
addsd  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <shubert+0x29>
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shubert>:
push   %rbx
sub    $0x20,%rsp
cvtss2sd %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movaps %xmm2,%xmm0
addsd  %xmm2,%xmm0
addsd  0xec6(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm0
addsd  0xeaa(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movd   %ebx,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
cvtdq2ps %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe87(%rip),%xmm0
addsd  0xe87(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
mulsd  0xe67(%rip),%xmm0
addsd  0xe67(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movd   %ebx,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
paddd  %xmm0,%xmm0
cvtdq2ps %xmm0,%xmm0
addps  0x10(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe3b(%rip),%xmm0
addsd  0xe23(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
mulsd  0xe1b(%rip),%xmm0
addsd  0xe03(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movd   %ebx,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
movdqa %xmm0,%xmm1
paddd  %xmm0,%xmm1
paddd  %xmm0,%xmm1
cvtdq2ps %xmm1,%xmm0
addps  0x10(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xddf(%rip),%xmm0
addsd  0xdcf(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
mulsd  0xdbf(%rip),%xmm0
addsd  0xdaf(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movd   %ebx,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
pslld  $0x2,%xmm0
cvtdq2ps %xmm0,%xmm0
addps  0x10(%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xd8a(%rip),%xmm0
addsd  0xd7a(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
mulsd  0xd6a(%rip),%xmm0
addsd  0xd5a(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movd   %ebx,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
movdqa %xmm0,%xmm1
pslld  $0x2,%xmm1
paddd  %xmm0,%xmm1
cvtdq2ps %xmm1,%xmm1
addps  0x10(%rsp),%xmm1
movaps %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
mulss  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

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

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