#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 M_PI;
double cos(double);
double sin(double);
double tan(double);
double sf_bwbp(int n, double f1f, double f2f) {
  int k;
  double ctt;
  double sfr, sfi;
  double parg;
  double sparg;
  double cparg;
  double a, b, c;
  ctt = 1.0 / tan(M_PI * (f2f - f1f) / 2.0);
  sfr = 1.0;
  sfi = 0.0;
  for (k = 0; k < n; ++k) {
    parg = M_PI * (double)(2 * k + 1) / (double)(2 * n);
    sparg = ctt + sin(parg);
    cparg = cos(parg);
    a = (sfr + sfi) * (sparg - cparg);
    b = sfr * sparg;
    c = -sfi * cparg;
    sfr = b - c;
    sfi = a - b - c;
  }
  return (1.0 / sfr);
}


x86 assembly (clang, -O0):
<sf_bwbp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    0x2e9c(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea2(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <tan@plt>
movaps %xmm0,%xmm1
movsd  0xe86(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe75(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1291 <sf_bwbp+0x161>
mov    0x2e36(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
subsd  -0x50(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119f <sf_bwbp+0x6f>
movsd  0xd67(%rip),%xmm0
divsd  -0x30(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sf_bwbp>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebx
mov    0x2ea7(%rip),%r14
subsd  %xmm0,%xmm1
mulsd  (%r14),%xmm1
mulsd  0xeae(%rip),%xmm1
movapd %xmm1,%xmm0
call   1040 <tan@plt>
movsd  0xea5(%rip),%xmm2
test   %ebx,%ebx
jle    1236 <sf_bwbp+0x106>
movsd  0xe95(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
lea    (%rbx,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
movsd  0xe6f(%rip),%xmm2
mov    $0x1,%ebp
xchg   %ax,%ax
movapd %xmm0,0x30(%rsp)
movsd  %xmm2,0x28(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  (%r14),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1030 <sin@plt>
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0x28(%rsp),%xmm2
movapd 0x30(%rsp),%xmm4
movapd %xmm4,%xmm1
addsd  %xmm2,%xmm1
movsd  0x20(%rsp),%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm0,%xmm3
mulsd  %xmm1,%xmm3
movapd %xmm4,%xmm1
xorpd  0xdfe(%rip),%xmm1
mulsd  %xmm0,%xmm1
subsd  %xmm2,%xmm3
subsd  %xmm1,%xmm2
subsd  %xmm1,%xmm3
movapd %xmm3,%xmm1
add    $0x2,%ebp
movapd %xmm3,%xmm0
add    $0xffffffff,%ebx
jne    11a0 <sf_bwbp+0x70>
movsd  0xdca(%rip),%xmm0
divsd  %xmm2,%xmm0
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @sf_bwbp(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
%17 = load double, double* @M_PI
%18 = load double, double* %6
%19 = load double, double* %5
%20 = fsub double %18, %19
%21 = fmul double %17, %20
%22 = fdiv double %21, 2.000000e+00
%23 = call double @tan(double %22)
%24 = fdiv double 1.000000e+00, %23
store double %24, double* %8
store double 1.000000e+00, double* %9
store double 0.000000e+00, double* %10
store i32 0, i32* %7
br label %25
25: ; preds = %68, %3
%26 = load i32, i32* %7
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %71
29: ; preds = %25
%30 = load double, double* @M_PI
%31 = load i32, i32* %7
%32 = mul nsw i32 2, %31
%33 = add nsw i32 %32, 1
%34 = sitofp i32 %33 to double
%35 = fmul double %30, %34
%36 = load i32, i32* %4
%37 = mul nsw i32 2, %36
%38 = sitofp i32 %37 to double
%39 = fdiv double %35, %38
store double %39, double* %11
%40 = load double, double* %8
%41 = load double, double* %11
%42 = call double @sin(double %41)
%43 = fadd double %40, %42
store double %43, double* %12
%44 = load double, double* %11
%45 = call double @cos(double %44)
store double %45, double* %13
%46 = load double, double* %9
%47 = load double, double* %10
%48 = fadd double %46, %47
%49 = load double, double* %12
%50 = load double, double* %13
%51 = fsub double %49, %50
%52 = fmul double %48, %51
store double %52, double* %14
%53 = load double, double* %9
%54 = load double, double* %12
%55 = fmul double %53, %54
store double %55, double* %15
%56 = load double, double* %10
%57 = fneg double %56
%58 = load double, double* %13
%59 = fmul double %57, %58
store double %59, double* %16
%60 = load double, double* %15
%61 = load double, double* %16
%62 = fsub double %60, %61
store double %62, double* %9
%63 = load double, double* %14
%64 = load double, double* %15
%65 = fsub double %63, %64
%66 = load double, double* %16
%67 = fsub double %65, %66
store double %67, double* %10
br label %68
68: ; preds = %29
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %25
71: ; preds = %25
%72 = load double, double* %9
%73 = fdiv double 1.000000e+00, %72
ret double %73
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @sf_bwbp(i32 %0, double %1, double %2) {
%4 = load double, double* @M_PI
%5 = fsub double %2, %1
%6 = fmul double %5, %4
%7 = fmul double %6, 5.000000e-01
%8 = tail call double @tan(double %7)
%9 = fdiv double 1.000000e+00, %8
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %38
11: ; preds = %3
%12 = shl nuw nsw i32 %0, 1
%13 = sitofp i32 %12 to double
br label %14
14: ; preds = %11, %14
%15 = phi i32 [ 0, %11 ], [ %36, %14 ]
%16 = phi double [ 1.000000e+00, %11 ], [ %33, %14 ]
%17 = phi double [ 0.000000e+00, %11 ], [ %35, %14 ]
%18 = load double, double* @M_PI
%19 = shl nuw nsw i32 %15, 1
%20 = or i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = fmul double %18, %21
%23 = fdiv double %22, %13
%24 = tail call double @sin(double %23)
%25 = fadd double %9, %24
%26 = tail call double @cos(double %23)
%27 = fadd double %17, %16
%28 = fsub double %25, %26
%29 = fmul double %27, %28
%30 = fmul double %16, %25
%31 = fneg double %17
%32 = fmul double %26, %31
%33 = fsub double %30, %32
%34 = fsub double %29, %30
%35 = fsub double %34, %32
%36 = add nuw nsw i32 %15, 1
%37 = icmp eq i32 %36, %0
br i1 %37, label %38, label %14
38: ; preds = %14, %3
%39 = phi double [ 1.000000e+00, %3 ], [ %33, %14 ]
%40 = fdiv double 1.000000e+00, %39
ret double %40
}