#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 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) / (double)nch;
    c[0] = cos(delta * (double)nch);
    c[nch] = 0.5 * c[0];
    for (j = 1; j < nch; j++) {
      c[j] = 0.5 * cos(delta * (double)j);
      c[nc - j] = 0.5 * sin(delta * (double)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    123c <makect+0x10c>
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x20(%rbp)
movsd  0xea0(%rip),%xmm0
call   1040 <atan@plt>
cvtsi2sdl -0x20(%rbp),%xmm1
divsd  %xmm1,%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  0xe5e(%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    1237 <makect+0x107>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe1c(%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  0xded(%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    11ba <makect+0x8a>
jmp    123c <makect+0x10c>
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>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xe99(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mulsd  %xmm1,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,(%r15)
mulsd  0xe82(%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
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
movsd  0xe11(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0xdf4(%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  0xdcb(%rip),%xmm0
movsd  %xmm0,0x8(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0xdb1(%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  0xd6e(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0xd56(%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 double @atan(double 1.000000e+00)
%19 = load i32, i32* %8
%20 = sitofp i32 %19 to double
%21 = fdiv double %18, %20
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 %67
6: ; preds = %3
%7 = lshr i32 %0, 1
%8 = tail call double @atan(double 1.000000e+00)
%9 = sitofp i32 %7 to double
%10 = fdiv double 0x3FE921FB54442D18, %9
%11 = fmul double %10, %9
%12 = tail call double @cos(double %11)
store double %12, double* %2
%13 = fmul double %12, 5.000000e-01
%14 = zext i32 %7 to i64
%15 = getelementptr inbounds double, double* %2, i64 %14
store double %13, double* %15
%16 = icmp ugt i32 %0, 3
br i1 %16, label %17, label %67
17: ; preds = %6
%18 = zext i32 %0 to i64
%19 = call i32 @llvm.umax.i32(i32 %7, i32 2)
%20 = zext i32 %19 to i64
%21 = add nsw i64 %20, -1
%22 = and i64 %21, 1
%23 = icmp ult i32 %0, 6
br i1 %23, label %53, label %24
24: ; preds = %17
%25 = and i64 %21, -2
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ 1, %24 ], [ %50, %26 ]
%28 = phi i64 [ 0, %24 ], [ %51, %26 ]
%29 = trunc i64 %27 to i32
%30 = sitofp i32 %29 to double
%31 = fmul double %10, %30
%32 = tail call double @cos(double %31)
%33 = fmul double %32, 5.000000e-01
%34 = getelementptr inbounds double, double* %2, i64 %27
store double %33, double* %34
%35 = tail call double @sin(double %31)
%36 = fmul double %35, 5.000000e-01
%37 = sub nsw i64 %18, %27
%38 = getelementptr inbounds double, double* %2, i64 %37
store double %36, double* %38
%39 = add nuw nsw i64 %27, 1
%40 = trunc i64 %39 to i32
%41 = sitofp i32 %40 to double
%42 = fmul double %10, %41
%43 = tail call double @cos(double %42)
%44 = fmul double %43, 5.000000e-01
%45 = getelementptr inbounds double, double* %2, i64 %39
store double %44, double* %45
%46 = tail call double @sin(double %42)
%47 = fmul double %46, 5.000000e-01
%48 = sub nsw i64 %18, %39
%49 = getelementptr inbounds double, double* %2, i64 %48
store double %47, double* %49
%50 = add nuw nsw i64 %27, 2
%51 = add i64 %28, 2
%52 = icmp eq i64 %51, %25
br i1 %52, label %53, label %26
53: ; preds = %26, %17
%54 = phi i64 [ 1, %17 ], [ %50, %26 ]
%55 = icmp eq i64 %22, 0
br i1 %55, label %67, label %56
56: ; preds = %53
%57 = trunc i64 %54 to i32
%58 = sitofp i32 %57 to double
%59 = fmul double %10, %58
%60 = tail call double @cos(double %59)
%61 = fmul double %60, 5.000000e-01
%62 = getelementptr inbounds double, double* %2, i64 %54
store double %61, double* %62
%63 = tail call double @sin(double %59)
%64 = fmul double %63, 5.000000e-01
%65 = sub nsw i64 %18, %54
%66 = getelementptr inbounds double, double* %2, i64 %65
store double %64, double* %66
br label %67
67: ; preds = %56, %53, %6, %3
ret void
}