#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 fourier_fup(double x, int n) {
  int m, mmax, kmax;
  double y, psin, k2, psin1, t;
  mmax = 20;
  psin = 1;
  t = x / 2;
  psin1 = sin(t) / t;
  psin = pow(psin1, n);
  t = x;
  for (m = 1; m < mmax; m++) {
    t = t / 2;
    psin1 = sin(t) / t;
    psin = psin * psin1;
  }
  y = psin;
  return y;
}


x86 assembly (clang, -O0):
<fourier_fup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movl   $0x14,-0x14(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeaf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e4 <fourier_fup+0xc4>
movsd  -0x40(%rbp),%xmm0
movsd  0xe56(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1191 <fourier_fup+0x71>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fourier_fup>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movsd  0xed1(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1030 <sin@plt>
divsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1040 <pow@plt>
movsd  %xmm0,(%rsp)
mov    $0x12,%ebx
nopl   (%rax)
movsd  0x8(%rsp),%xmm0
mulsd  0xe92(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <sin@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm2
divsd  %xmm2,%xmm1
mulsd  (%rsp),%xmm1
test   %ebx,%ebx
je     11c5 <fourier_fup+0xa5>
movapd %xmm2,%xmm0
mulsd  0xe64(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,(%rsp)
call   1030 <sin@plt>
divsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
add    $0xfffffffe,%ebx
movsd  %xmm1,(%rsp)
jmp    1160 <fourier_fup+0x40>
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @fourier_fup(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
store i32 20, i32* %6
store double 1.000000e+00, double* %9
%13 = load double, double* %3
%14 = fdiv double %13, 2.000000e+00
store double %14, double* %12
%15 = load double, double* %12
%16 = call double @sin(double %15)
%17 = load double, double* %12
%18 = fdiv double %16, %17
store double %18, double* %11
%19 = load double, double* %11
%20 = load i32, i32* %4
%21 = call double @pow(double %19, i32 %20)
store double %21, double* %9
%22 = load double, double* %3
store double %22, double* %12
store i32 1, i32* %5
br label %23
23: ; preds = %37, %2
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %40
27: ; preds = %23
%28 = load double, double* %12
%29 = fdiv double %28, 2.000000e+00
store double %29, double* %12
%30 = load double, double* %12
%31 = call double @sin(double %30)
%32 = load double, double* %12
%33 = fdiv double %31, %32
store double %33, double* %11
%34 = load double, double* %9
%35 = load double, double* %11
%36 = fmul double %34, %35
store double %36, double* %9
br label %37
37: ; preds = %27
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %23
40: ; preds = %23
%41 = load double, double* %9
store double %41, double* %8
%42 = load double, double* %8
ret double %42
}

LLVM IR (-O2):
define double @fourier_fup(double %0, i32 %1) {
%3 = fmul double %0, 5.000000e-01
%4 = tail call double @sin(double %3)
%5 = fdiv double %4, %3
%6 = tail call double @pow(double %5, i32 %1)
br label %7
7: ; preds = %16, %2
%8 = phi double [ %0, %2 ], [ %17, %16 ]
%9 = phi i32 [ 1, %2 ], [ %21, %16 ]
%10 = phi double [ %6, %2 ], [ %20, %16 ]
%11 = fmul double %8, 5.000000e-01
%12 = tail call double @sin(double %11)
%13 = fdiv double %12, %11
%14 = fmul double %10, %13
%15 = icmp eq i32 %9, 19
br i1 %15, label %22, label %16
16: ; preds = %7
%17 = fmul double %11, 5.000000e-01
%18 = tail call double @sin(double %17)
%19 = fdiv double %18, %17
%20 = fmul double %14, %19
%21 = add nuw nsw i32 %9, 2
br label %7
22: ; preds = %7
ret double %14
}