#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 sin(double);
void makeweights(int bw, double *weights) {
  int j, k;
  double fudge;
  double tmpsum;
  fudge = M_PI / ((double)(4 * bw));
  for (j = 0; j < 2 * bw; j++) {
    tmpsum = 0.0;
    for (k = 0; k < bw; k++)
      tmpsum += 1. / ((double)(2 * k + 1)) *
                sin((double)((2 * j + 1) * (2 * k + 1)) * fudge);
    tmpsum *= sin((double)(2 * j + 1) * fudge);
    tmpsum *= 2. / ((double)bw);
    weights[j] = tmpsum;
    weights[j + 2 * bw] = tmpsum * sin((double)(2 * j + 1) * fudge);
  }
}


x86 assembly (clang, -O0):
<makeweights>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ec2(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x4(%rbp),%eax
shl    $0x2,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1279 <makeweights+0x169>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d9 <makeweights+0xc9>
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe83(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1164 <makeweights+0x54>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xdf9(%rip),%xmm0
divsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    -0x4(%rbp),%edx
shl    $0x1,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <makeweights+0x34>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeweights>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,0x40(%rsp)
mov    %rdi,0x18(%rsp)
test   %edi,%edi
jle    128a <makeweights+0x17a>
mov    0x2eb1(%rip),%rax
mov    0x18(%rsp),%rdx
lea    0x0(,%rdx,4),%ecx
cvtsi2sd %ecx,%xmm0
movsd  (%rax),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
lea    (%rdx,%rdx,1),%eax
movsd  0xe99(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x38(%rsp)
movslq %eax,%rcx
cmp    $0x2,%ecx
mov    $0x1,%edx
mov    %rcx,%rax
mov    %rcx,0x30(%rsp)
cmovge %ecx,%edx
mov    %rdx,0x28(%rsp)
mov    $0x1,%r12d
mov    $0x2,%ebx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
lea    (%r14,%r14,1),%eax
add    $0x1,%eax
mov    %eax,0x14(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    %r12d,%ebp
mov    $0x1,%r13d
mov    0x18(%rsp),%rax
mov    %eax,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
movsd  0xe28(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
add    $0x2,%r13d
add    %ebx,%ebp
add    $0xffffffff,%r15d
jne    11d0 <makeweights+0xc0>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x14(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <sin@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0x38(%rsp),%xmm1
movsd  %xmm1,(%rsp)
mov    0x40(%rsp),%rbp
movsd  %xmm1,0x0(%rbp,%r14,8)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
mov    0x30(%rsp),%rax
add    %r14,%rax
movsd  %xmm0,0x0(%rbp,%rax,8)
add    $0x1,%r14
add    $0x2,%r12d
add    $0x4,%ebx
cmp    0x28(%rsp),%r14
jne    11a0 <makeweights+0x90>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @makeweights(i32 %0, double* nocapture writeonly %1) {
%3 = load double, double* @M_PI
%4 = shl nsw i32 %0, 2
%5 = sitofp i32 %4 to double
%6 = fdiv double %3, %5
%7 = shl i32 %0, 1
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %47
9: ; preds = %2
%10 = sitofp i32 %0 to double
%11 = fdiv double 2.000000e+00, %10
%12 = sext i32 %7 to i64
%13 = call i32 @llvm.smax.i32(i32 %7, i32 1)
%14 = zext i32 %13 to i64
br label %15
15: ; preds = %34, %9
%16 = phi i64 [ 0, %9 ], [ %45, %34 ]
%17 = trunc i64 %16 to i32
%18 = shl i32 %17, 1
%19 = or i32 %18, 1
br label %20
20: ; preds = %15, %20
%21 = phi double [ 0.000000e+00, %15 ], [ %31, %20 ]
%22 = phi i32 [ 0, %15 ], [ %32, %20 ]
%23 = shl nuw nsw i32 %22, 1
%24 = or i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = fdiv double 1.000000e+00, %25
%27 = mul nsw i32 %24, %19
%28 = sitofp i32 %27 to double
%29 = fmul double %6, %28
%30 = tail call double @sin(double %29)
%31 = tail call double @llvm.fmuladd.f64(double %26, double %30, double %21)
%32 = add nuw nsw i32 %22, 1
%33 = icmp eq i32 %32, %0
br i1 %33, label %34, label %20
34: ; preds = %20
%35 = sitofp i32 %19 to double
%36 = fmul double %6, %35
%37 = tail call double @sin(double %36)
%38 = fmul double %31, %37
%39 = fmul double %11, %38
%40 = getelementptr inbounds double, double* %1, i64 %16
store double %39, double* %40
%41 = tail call double @sin(double %36)
%42 = fmul double %39, %41
%43 = add nsw i64 %16, %12
%44 = getelementptr inbounds double, double* %1, i64 %43
store double %42, double* %44
%45 = add nuw nsw i64 %16, 1
%46 = icmp eq i64 %45, %14
br i1 %46, label %47, label %15
47: ; preds = %34, %2
ret void
}