#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 */
int atan(double);
double cos(double);
double sin(double);
void makect(int nc, int *ip, double *c) {
  int j, nch;
  double delta;
  ip[1] = nc;
  if (nc > 1) {
    nch = nc >> 1;
    delta = atan(1.0) / nch;
    c[0] = cos(delta * nch);
    c[nch] = ((double)0.5) * c[0];
    for (j = 1; j < nch; j++) {
      c[j] = ((double)0.5) * cos(delta * j);
      c[nc - j] = ((double)0.5) * sin(delta * j);
    }
  }
}


x86 assembly (clang, -O0):
<makect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
cmpl   $0x1,-0x4(%rbp)
jle    123b <makect+0x10b>
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x20(%rbp)
movsd  0xea0(%rip),%xmm0
call   1040 <atan@plt>
cltd
idivl  -0x20(%rbp)
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1050 <cos@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe5f(%rip),%xmm0
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1236 <makect+0x106>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe1d(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xdee(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b9 <makect+0x89>
jmp    123b <makect+0x10b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,0x4(%rsi)
cmp    $0x2,%edi
jl     12c3 <makect+0x193>
mov    %rdx,%r15
mov    %edi,%ebp
mov    %edi,%ebx
shr    %ebx
movsd  0xea5(%rip),%xmm0
call   1040 <atan@plt>
cltd
idiv   %ebx
cvtsi2sd %eax,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm1,(%rsp)
mulsd  %xmm1,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,(%r15)
mulsd  0xe7f(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
cmp    $0x4,%ebp
jb     12c3 <makect+0x193>
cmp    $0x3,%ebx
mov    $0x2,%r12d
cmovae %ebx,%r12d
mov    %ebp,%r14d
add    $0xffffffffffffffff,%r12
mov    $0x1,%ebx
cmp    $0x6,%ebp
jb     127a <makect+0x14a>
mov    %r12,%r13
and    $0xfffffffffffffffe,%r13
mov    %r14,0x10(%rsp)
lea    (%r15,%r14,8),%rbp
add    $0xfffffffffffffff8,%rbp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
movsd  0xe09(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0xdec(%rip),%xmm0
movsd  %xmm0,0x0(%rbp)
lea    0x1(%rbx),%r14
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
mulsd  0xdc3(%rip),%xmm0
movsd  %xmm0,0x8(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0xda9(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
add    $0x2,%rbx
add    $0xfffffffffffffff0,%rbp
cmp    %r13,%r14
jne    11e0 <makect+0xb0>
mov    0x10(%rsp),%r14
test   $0x1,%r12b
je     12c3 <makect+0x193>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  (%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1050 <cos@plt>
mulsd  0xd66(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0xd4e(%rip),%xmm0
sub    %rbx,%r14
movsd  %xmm0,(%r15,%r14,8)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @makect(i32 %0, i32* %1, double* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
store i32 %0, i32* %4
store i32* %1, i32** %5
store double* %2, double** %6
%10 = load i32, i32* %4
%11 = load i32*, i32** %5
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32 %10, i32* %12
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %68
15: ; preds = %3
%16 = load i32, i32* %4
%17 = ashr i32 %16, 1
store i32 %17, i32* %8
%18 = call i32 @atan(double 1.000000e+00)
%19 = load i32, i32* %8
%20 = sdiv i32 %18, %19
%21 = sitofp i32 %20 to double
store double %21, double* %9
%22 = load double, double* %9
%23 = load i32, i32* %8
%24 = sitofp i32 %23 to double
%25 = fmul double %22, %24
%26 = call double @cos(double %25)
%27 = load double*, double** %6
%28 = getelementptr inbounds double, double* %27, i64 0
store double %26, double* %28
%29 = load double*, double** %6
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = fmul double 5.000000e-01, %31
%33 = load double*, double** %6
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double %32, double* %36
store i32 1, i32* %7
br label %37
37: ; preds = %64, %15
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %67
41: ; preds = %37
%42 = load double, double* %9
%43 = load i32, i32* %7
%44 = sitofp i32 %43 to double
%45 = fmul double %42, %44
%46 = call double @cos(double %45)
%47 = fmul double 5.000000e-01, %46
%48 = load double*, double** %6
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double %47, double* %51
%52 = load double, double* %9
%53 = load i32, i32* %7
%54 = sitofp i32 %53 to double
%55 = fmul double %52, %54
%56 = call double @sin(double %55)
%57 = fmul double 5.000000e-01, %56
%58 = load double*, double** %6
%59 = load i32, i32* %4
%60 = load i32, i32* %7
%61 = sub nsw i32 %59, %60
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %58, i64 %62
store double %57, double* %63
br label %64
64: ; preds = %41
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
br label %37
67: ; preds = %37
br label %68
68: ; preds = %67, %3
ret void
}

LLVM IR (-O2):
define void @makect(i32 %0, i32* nocapture writeonly %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %0, i32* %4
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %68
6: ; preds = %3
%7 = lshr i32 %0, 1
%8 = tail call i32 @atan(double 1.000000e+00)
%9 = sdiv i32 %8, %7
%10 = sitofp i32 %9 to double
%11 = sitofp i32 %7 to double
%12 = fmul double %11, %10
%13 = tail call double @cos(double %12)
store double %13, double* %2
%14 = fmul double %13, 5.000000e-01
%15 = zext i32 %7 to i64
%16 = getelementptr inbounds double, double* %2, i64 %15
store double %14, double* %16
%17 = icmp ugt i32 %0, 3
br i1 %17, label %18, label %68
18: ; preds = %6
%19 = zext i32 %0 to i64
%20 = call i32 @llvm.umax.i32(i32 %7, i32 2)
%21 = zext i32 %20 to i64
%22 = add nsw i64 %21, -1
%23 = and i64 %22, 1
%24 = icmp ult i32 %0, 6
br i1 %24, label %54, label %25
25: ; preds = %18
%26 = and i64 %22, -2
br label %27
27: ; preds = %27, %25
%28 = phi i64 [ 1, %25 ], [ %51, %27 ]
%29 = phi i64 [ 0, %25 ], [ %52, %27 ]
%30 = trunc i64 %28 to i32
%31 = sitofp i32 %30 to double
%32 = fmul double %10, %31
%33 = tail call double @cos(double %32)
%34 = fmul double %33, 5.000000e-01
%35 = getelementptr inbounds double, double* %2, i64 %28
store double %34, double* %35
%36 = tail call double @sin(double %32)
%37 = fmul double %36, 5.000000e-01
%38 = sub nsw i64 %19, %28
%39 = getelementptr inbounds double, double* %2, i64 %38
store double %37, double* %39
%40 = add nuw nsw i64 %28, 1
%41 = trunc i64 %40 to i32
%42 = sitofp i32 %41 to double
%43 = fmul double %10, %42
%44 = tail call double @cos(double %43)
%45 = fmul double %44, 5.000000e-01
%46 = getelementptr inbounds double, double* %2, i64 %40
store double %45, double* %46
%47 = tail call double @sin(double %43)
%48 = fmul double %47, 5.000000e-01
%49 = sub nsw i64 %19, %40
%50 = getelementptr inbounds double, double* %2, i64 %49
store double %48, double* %50
%51 = add nuw nsw i64 %28, 2
%52 = add i64 %29, 2
%53 = icmp eq i64 %52, %26
br i1 %53, label %54, label %27
54: ; preds = %27, %18
%55 = phi i64 [ 1, %18 ], [ %51, %27 ]
%56 = icmp eq i64 %23, 0
br i1 %56, label %68, label %57
57: ; preds = %54
%58 = trunc i64 %55 to i32
%59 = sitofp i32 %58 to double
%60 = fmul double %10, %59
%61 = tail call double @cos(double %60)
%62 = fmul double %61, 5.000000e-01
%63 = getelementptr inbounds double, double* %2, i64 %55
store double %62, double* %63
%64 = tail call double @sin(double %60)
%65 = fmul double %64, 5.000000e-01
%66 = sub nsw i64 %19, %55
%67 = getelementptr inbounds double, double* %2, i64 %66
store double %65, double* %67
br label %68
68: ; preds = %57, %54, %6, %3
ret void
}