#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 pow(double, int);
double sin(double);
double f_c(int n, double h, double a) {
  double sum = 0;
  double h1 = h;
  for (n; n > 0; n--) {
    sum = sum + pow(a + h1, 2) * sin(a + h1);
    h1 = h1 + h;
  }
  return 2 * sum;
}


x86 assembly (clang, -O0):
<f_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    11ba <f_c+0x9a>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1147 <f_c+0x27>
movsd  0xe3e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_c>:
test   %edi,%edi
jle    1145 <f_c+0x25>
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebx
test   $0x1,%bl
movsd  %xmm0,0x28(%rsp)
movsd  %xmm1,0x30(%rsp)
jne    1149 <f_c+0x29>
xorpd  %xmm1,%xmm1
mov    %ebx,%ebp
jmp    1189 <f_c+0x69>
xorps  %xmm0,%xmm0
ret
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x28(%rsp),%xmm0
addsd  %xmm0,%xmm0
lea    -0x1(%rbx),%ebp
cmp    $0x1,%ebx
movsd  0x30(%rsp),%xmm2
je     124d <f_c+0x12d>
add    $0xffffffff,%ebp
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
addsd  %xmm2,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x20(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x30(%rsp),%xmm2
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
addsd  0x28(%rsp),%xmm0
add    $0xfffffffe,%ebp
jb     11a0 <f_c+0x80>
addsd  %xmm1,%xmm1
add    $0x38,%rsp
pop    %rbx
pop    %rbp
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @f_c(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
store double 0.000000e+00, double* %7
%9 = load double, double* %5
store double %9, double* %8
%10 = load i32, i32* %4
br label %11
11: ; preds = %28, %3
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %11
%15 = load double, double* %7
%16 = load double, double* %6
%17 = load double, double* %8
%18 = fadd double %16, %17
%19 = call double @pow(double %18, i32 2)
%20 = load double, double* %6
%21 = load double, double* %8
%22 = fadd double %20, %21
%23 = call double @sin(double %22)
%24 = call double @llvm.fmuladd.f64(double %19, double %23, double %15)
store double %24, double* %7
%25 = load double, double* %8
%26 = load double, double* %5
%27 = fadd double %25, %26
store double %27, double* %8
br label %28
28: ; preds = %14
%29 = load i32, i32* %4
%30 = add nsw i32 %29, -1
store i32 %30, i32* %4
br label %11
31: ; preds = %11
%32 = load double, double* %7
%33 = fmul double 2.000000e+00, %32
ret double %33
}

LLVM IR (-O2):
define double @f_c(i32 %0, double %1, double %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %41
5: ; preds = %3
%6 = and i32 %0, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = fadd double %1, %2
%10 = tail call double @pow(double %9, i32 2)
%11 = tail call double @sin(double %9)
%12 = tail call double @llvm.fmuladd.f64(double %10, double %11, double 0.000000e+00)
%13 = fadd double %1, %1
%14 = add nsw i32 %0, -1
br label %15
15: ; preds = %8, %5
%16 = phi double [ %1, %5 ], [ %13, %8 ]
%17 = phi double [ 0.000000e+00, %5 ], [ %12, %8 ]
%18 = phi i32 [ %0, %5 ], [ %14, %8 ]
%19 = phi double [ undef, %5 ], [ %12, %8 ]
%20 = icmp eq i32 %0, 1
br i1 %20, label %38, label %21
21: ; preds = %15, %21
%22 = phi double [ %34, %21 ], [ %16, %15 ]
%23 = phi double [ %33, %21 ], [ %17, %15 ]
%24 = phi i32 [ %35, %21 ], [ %18, %15 ]
%25 = fadd double %22, %2
%26 = tail call double @pow(double %25, i32 2)
%27 = tail call double @sin(double %25)
%28 = tail call double @llvm.fmuladd.f64(double %26, double %27, double %23)
%29 = fadd double %22, %1
%30 = fadd double %29, %2
%31 = tail call double @pow(double %30, i32 2)
%32 = tail call double @sin(double %30)
%33 = tail call double @llvm.fmuladd.f64(double %31, double %32, double %28)
%34 = fadd double %29, %1
%35 = add nsw i32 %24, -2
%36 = add i32 %24, -3
%37 = icmp ult i32 %36, -2
br i1 %37, label %21, label %38
38: ; preds = %21, %15
%39 = phi double [ %19, %15 ], [ %33, %21 ]
%40 = fmul double %39, 2.000000e+00
br label %41
41: ; preds = %38, %3
%42 = phi double [ 0.000000e+00, %3 ], [ %40, %38 ]
ret double %42
}