#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(float);
double sin(float);
void makect(int nc, int *ip, float *c) {
  int nch, j;
  float delta;
  ip[1] = nc;
  if (nc > 1) {
    nch = nc >> 1;
    delta = atan(1.0) / nch;
    c[0] = 0.5;
    c[nch] = 0.5 * cos(delta * nch);
    for (j = 1; j <= nch - 1; j++) {
      c[j] = 0.5 * cos(delta * j);
      c[nc - j] = 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    1253 <makect+0x123>
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsd  0xea0(%rip),%xmm0
call   1040 <atan@plt>
cltd
idivl  -0x1c(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movss  0xe8a(%rip),%xmm0
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
mulss  %xmm1,%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe58(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     124e <makect+0x11e>
movss  -0x24(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
mulss  %xmm1,%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xe0d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x24(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
mulss  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xdda(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c4 <makect+0x94>
jmp    1253 <makect+0x123>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makect>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,0x4(%rsi)
cmp    $0x2,%edi
jl     1216 <makect+0xe6>
mov    %rdx,%r15
mov    %edi,%r14d
mov    %edi,%ebx
shr    %ebx
movsd  0xea6(%rip),%xmm0
call   1040 <atan@plt>
cltd
idiv   %ebx
cvtsi2ss %eax,%xmm1
movl   $0x3f000000,(%r15)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  %xmm1,0x8(%rsp)
mulss  %xmm1,%xmm0
call   1050 <cos@plt>
mulsd  0xe7d(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15,%rbx,4)
cmp    $0x4,%r14d
jb     1216 <makect+0xe6>
cmp    $0x3,%ebx
mov    $0x2,%r12d
cmovae %ebx,%r12d
mov    %r14d,%eax
lea    (%r15,%rax,4),%rbx
add    $0xfffffffffffffffc,%rbx
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
call   1050 <cos@plt>
movsd  0xe28(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15,%rbp,4)
movss  0xc(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0xe07(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
add    $0x1,%rbp
add    $0xfffffffffffffffc,%rbx
cmp    %rbp,%r12
jne    11c0 <makect+0x90>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @makect(i32 %0, i32* nocapture writeonly %1, float* 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 %39
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 float
store float 5.000000e-01, float* %2
%11 = sitofp i32 %7 to float
%12 = fmul float %11, %10
%13 = tail call double @cos(float %12)
%14 = fmul double %13, 5.000000e-01
%15 = fptrunc double %14 to float
%16 = zext i32 %7 to i64
%17 = getelementptr inbounds float, float* %2, i64 %16
store float %15, float* %17
%18 = icmp ugt i32 %0, 3
br i1 %18, label %19, label %39
19: ; preds = %6
%20 = zext i32 %0 to i64
%21 = call i32 @llvm.umax.i32(i32 %7, i32 2)
%22 = zext i32 %21 to i64
br label %23
23: ; preds = %19, %23
%24 = phi i64 [ 1, %19 ], [ %37, %23 ]
%25 = trunc i64 %24 to i32
%26 = sitofp i32 %25 to float
%27 = fmul float %10, %26
%28 = tail call double @cos(float %27)
%29 = fmul double %28, 5.000000e-01
%30 = fptrunc double %29 to float
%31 = getelementptr inbounds float, float* %2, i64 %24
store float %30, float* %31
%32 = tail call double @sin(float %27)
%33 = fmul double %32, 5.000000e-01
%34 = fptrunc double %33 to float
%35 = sub nsw i64 %20, %24
%36 = getelementptr inbounds float, float* %2, i64 %35
store float %34, float* %36
%37 = add nuw nsw i64 %24, 1
%38 = icmp eq i64 %37, %22
br i1 %38, label %39, label %23
39: ; preds = %23, %6, %3
ret void
}