#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 */
scalar_t__ cos(double);
scalar_t__ sin(double);
void genExp_mem(int bw, double phi, double *expValsR, double *expValsI) {
  int i, expZero;
  expZero = bw - 1;
  for (i = -expZero; i < expZero + 1; i++) {
    expValsR[expZero + i] = (double)cos(((double)i) * phi);
    expValsI[expZero + i] = (double)-sin(((double)i) * phi);
  }
}


x86 assembly (clang, -O0):
<genExp_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
xor    %eax,%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11bc <genExp_mem+0x9c>
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
cvtsi2sd %rax,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
mov    %rax,%rcx
xor    %eax,%eax
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1149 <genExp_mem+0x29>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genExp_mem>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,(%rsp)
mov    $0x1,%r13d
sub    %edi,%r13d
cmp    %edi,%r13d
jge    127e <genExp_mem+0x15e>
mov    %edi,%r12d
movslq %edi,%rbx
movslq %r13d,%rbp
cvtsi2sd %r13d,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
mov    %rdx,%r15
call   1040 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
lea    (%rbx,%rbp,1),%r14
add    $0xffffffffffffffff,%r14
mov    (%rsp),%rax
movsd  %xmm0,(%rax,%r14,8)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
neg    %rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%r15,%r14,8)
movsd  0x8(%rsp),%xmm1
mov    %r12d,%eax
and    $0x7fffffff,%eax
cmp    $0x1,%eax
je     127e <genExp_mem+0x15e>
mov    %r15,%rcx
add    $0xffffffffffffffff,%rbx
add    %rbp,%rbx
add    $0x1,%rbp
mov    (%rsp),%rax
lea    (%rax,%rbx,8),%r15
lea    (%rcx,%rbx,8),%r14
add    $0xffffffff,%r13d
mov    $0x2,%ebx
xchg   %ax,%ax
lea    (%rbx,%r13,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1040 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x8(%r15,%rbx,8)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
neg    %rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x8(%r14,%rbx,8)
lea    0x1(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
neg    %rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x8(%rsp),%xmm1
add    $0x2,%rbp
add    $0x2,%rbx
cmp    %r12d,%ebp
jne    11e0 <genExp_mem+0xc0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @genExp_mem(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 i32
store i32 %0, i32* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %10
%13 = load i32, i32* %10
%14 = sub nsw i32 0, %13
store i32 %14, i32* %9
br label %15
15: ; preds = %46, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %10
%18 = add nsw i32 %17, 1
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %49
20: ; preds = %15
%21 = load i32, i32* %9
%22 = sitofp i32 %21 to double
%23 = load double, double* %6
%24 = fmul double %22, %23
%25 = call i64 @cos(double %24)
%26 = sitofp i64 %25 to double
%27 = load double*, double** %7
%28 = load i32, i32* %10
%29 = load i32, i32* %9
%30 = add nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %27, i64 %31
store double %26, double* %32
%33 = load i32, i32* %9
%34 = sitofp i32 %33 to double
%35 = load double, double* %6
%36 = fmul double %34, %35
%37 = call i64 @sin(double %36)
%38 = sub nsw i64 0, %37
%39 = sitofp i64 %38 to double
%40 = load double*, double** %8
%41 = load i32, i32* %10
%42 = load i32, i32* %9
%43 = add nsw i32 %41, %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %40, i64 %44
store double %39, double* %45
br label %46
46: ; preds = %20
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %15
49: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @genExp_mem(i32 %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = sub i32 1, %0
%6 = icmp slt i32 %5, %0
br i1 %6, label %7, label %52
7: ; preds = %4
%8 = add nsw i32 %0, -1
%9 = sext i32 %5 to i64
%10 = sext i32 %8 to i64
%11 = sitofp i32 %5 to double
%12 = fmul double %11, %1
%13 = tail call i64 @cos(double %12)
%14 = sitofp i64 %13 to double
%15 = add nsw i64 %9, %10
%16 = getelementptr inbounds double, double* %2, i64 %15
store double %14, double* %16
%17 = tail call i64 @sin(double %12)
%18 = sub nsw i64 0, %17
%19 = sitofp i64 %18 to double
%20 = getelementptr inbounds double, double* %3, i64 %15
store double %19, double* %20
%21 = add nsw i64 %9, 1
%22 = and i32 %0, 2147483647
%23 = icmp eq i32 %22, 1
br i1 %23, label %52, label %24
24: ; preds = %7, %24
%25 = phi i64 [ %49, %24 ], [ %21, %7 ]
%26 = trunc i64 %25 to i32
%27 = sitofp i32 %26 to double
%28 = fmul double %27, %1
%29 = tail call i64 @cos(double %28)
%30 = sitofp i64 %29 to double
%31 = add nsw i64 %25, %10
%32 = getelementptr inbounds double, double* %2, i64 %31
store double %30, double* %32
%33 = tail call i64 @sin(double %28)
%34 = sub nsw i64 0, %33
%35 = sitofp i64 %34 to double
%36 = getelementptr inbounds double, double* %3, i64 %31
store double %35, double* %36
%37 = add nsw i64 %25, 1
%38 = trunc i64 %37 to i32
%39 = sitofp i32 %38 to double
%40 = fmul double %39, %1
%41 = tail call i64 @cos(double %40)
%42 = sitofp i64 %41 to double
%43 = add nsw i64 %37, %10
%44 = getelementptr inbounds double, double* %2, i64 %43
store double %42, double* %44
%45 = tail call i64 @sin(double %40)
%46 = sub nsw i64 0, %45
%47 = sitofp i64 %46 to double
%48 = getelementptr inbounds double, double* %3, i64 %43
store double %47, double* %48
%49 = add nsw i64 %25, 2
%50 = trunc i64 %49 to i32
%51 = icmp eq i32 %50, %0
br i1 %51, label %52, label %24
52: ; preds = %7, %24, %4
ret void
}