#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_bwbs(int n, double f1f, double f2f) {
  int k;
  double tt;
  double sfr, sfi;
  double parg;
  double sparg;
  double cparg;
  double a, b, c;
  tt = 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 = tt + 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_bwbs>:
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>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe84(%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    1282 <sf_bwbs+0x152>
mov    0x2e45(%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    1190 <sf_bwbs+0x60>
movsd  0xd76(%rip),%xmm0
divsd  -0x30(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sf_bwbs>:
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  %xmm0,0x10(%rsp)
movsd  0xe9f(%rip),%xmm2
test   %ebx,%ebx
jle    1236 <sf_bwbs+0x106>
lea    (%rbx,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
movsd  0xe7b(%rip),%xmm2
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
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_bwbs+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_bwbs(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)
store double %23, double* %8
store double 1.000000e+00, double* %9
store double 0.000000e+00, double* %10
store i32 0, i32* %7
br label %24
24: ; preds = %67, %3
%25 = load i32, i32* %7
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %70
28: ; preds = %24
%29 = load double, double* @M_PI
%30 = load i32, i32* %7
%31 = mul nsw i32 2, %30
%32 = add nsw i32 %31, 1
%33 = sitofp i32 %32 to double
%34 = fmul double %29, %33
%35 = load i32, i32* %4
%36 = mul nsw i32 2, %35
%37 = sitofp i32 %36 to double
%38 = fdiv double %34, %37
store double %38, double* %11
%39 = load double, double* %8
%40 = load double, double* %11
%41 = call double @sin(double %40)
%42 = fadd double %39, %41
store double %42, double* %12
%43 = load double, double* %11
%44 = call double @cos(double %43)
store double %44, double* %13
%45 = load double, double* %9
%46 = load double, double* %10
%47 = fadd double %45, %46
%48 = load double, double* %12
%49 = load double, double* %13
%50 = fsub double %48, %49
%51 = fmul double %47, %50
store double %51, double* %14
%52 = load double, double* %9
%53 = load double, double* %12
%54 = fmul double %52, %53
store double %54, double* %15
%55 = load double, double* %10
%56 = fneg double %55
%57 = load double, double* %13
%58 = fmul double %56, %57
store double %58, double* %16
%59 = load double, double* %15
%60 = load double, double* %16
%61 = fsub double %59, %60
store double %61, double* %9
%62 = load double, double* %14
%63 = load double, double* %15
%64 = fsub double %62, %63
%65 = load double, double* %16
%66 = fsub double %64, %65
store double %66, double* %10
br label %67
67: ; preds = %28
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %24
70: ; preds = %24
%71 = load double, double* %9
%72 = fdiv double 1.000000e+00, %71
ret double %72
}

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