#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 cos(double);
double sin(double);
void genSinCosArray(int n, double *phis, double *ca, double *sa) {
  for (int i = 0; i < n; i++) {
    double phi = phis[i];
    ca[i] = cos(phi);
    sa[i] = sin(phi);
  }
}


x86 assembly (clang, -O0):
<genSinCosArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1198 <genSinCosArray+0x78>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <cos@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
call   1030 <sin@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <genSinCosArray+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genSinCosArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11d4 <genSinCosArray+0xb4>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%r13d
cmp    $0x1,%edi
jne    1148 <genSinCosArray+0x28>
xor    %ebx,%ebx
jmp    11a8 <genSinCosArray+0x88>
mov    %r13d,%ebp
and    $0xfffffffe,%ebp
xor    %ebx,%ebx
movsd  (%r12,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,(%r15,%rbx,8)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x8(%r12,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x8(%r15,%rbx,8)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%r14,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%rbp
jne    1150 <genSinCosArray+0x30>
test   $0x1,%r13b
je     11d4 <genSinCosArray+0xb4>
movsd  (%r12,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,(%r15,%rbx,8)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,(%r14,%rbx,8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @genSinCosArray(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store i32 0, i32* %9
br label %11
11: ; preds = %33, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %36
15: ; preds = %11
%16 = load double*, double** %6
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
store double %20, double* %10
%21 = load double, double* %10
%22 = call double @cos(double %21)
%23 = load double*, double** %7
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
store double %22, double* %26
%27 = load double, double* %10
%28 = call double @sin(double %27)
%29 = load double*, double** %8
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
br label %33
33: ; preds = %15
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %11
36: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @genSinCosArray(i32 %0, double* nocapture %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %22
6: ; preds = %4
%7 = zext i32 %0 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %0, 1
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = and i64 %7, 4294967294
br label %23
12: ; preds = %23, %6
%13 = phi i64 [ 0, %6 ], [ %39, %23 ]
%14 = icmp eq i64 %8, 0
br i1 %14, label %22, label %15
15: ; preds = %12
%16 = getelementptr inbounds double, double* %1, i64 %13
%17 = load double, double* %16
%18 = tail call double @cos(double %17)
%19 = getelementptr inbounds double, double* %2, i64 %13
store double %18, double* %19
%20 = tail call double @sin(double %17)
%21 = getelementptr inbounds double, double* %3, i64 %13
store double %20, double* %21
br label %22
22: ; preds = %15, %12, %4
ret void
23: ; preds = %23, %10
%24 = phi i64 [ 0, %10 ], [ %39, %23 ]
%25 = phi i64 [ 0, %10 ], [ %40, %23 ]
%26 = getelementptr inbounds double, double* %1, i64 %24
%27 = load double, double* %26
%28 = tail call double @cos(double %27)
%29 = getelementptr inbounds double, double* %2, i64 %24
store double %28, double* %29
%30 = tail call double @sin(double %27)
%31 = getelementptr inbounds double, double* %3, i64 %24
store double %30, double* %31
%32 = or i64 %24, 1
%33 = getelementptr inbounds double, double* %1, i64 %32
%34 = load double, double* %33
%35 = tail call double @cos(double %34)
%36 = getelementptr inbounds double, double* %2, i64 %32
store double %35, double* %36
%37 = tail call double @sin(double %34)
%38 = getelementptr inbounds double, double* %3, i64 %32
store double %37, double* %38
%39 = add nuw nsw i64 %24, 2
%40 = add i64 %25, 2
%41 = icmp eq i64 %40, %11
br i1 %41, label %12, label %23
}