#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 bessel_fourier_kernel(double theta[], double m, double zero, double rho,
                           double out[], int ix) {
  int i;
  for (i = ix; i--;) {
    out[i] = cos(m * theta[i]) * sin(zero * (cos(theta[i]) - rho));
  }
}


x86 assembly (clang, -O0):
<bessel_fourier_kernel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x30(%rbp)
cmp    $0x0,%eax
je     11c8 <bessel_fourier_kernel+0xa8>
movsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1148 <bessel_fourier_kernel+0x28>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bessel_fourier_kernel>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edx,%edx
je     1257 <bessel_fourier_kernel+0x137>
mov    %edx,%r15d
mov    %rsi,%r14
movapd %xmm0,%xmm3
mov    %rdi,%r13
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x20(%rsp)
movslq %edx,%rbp
test   $0x1,%r15b
movsd  %xmm0,0x10(%rsp)
je     11ab <bessel_fourier_kernel+0x8b>
lea    -0x1(%rbp),%r12
movsd  -0x8(%r13,%rbp,8),%xmm0
mulsd  %xmm3,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  -0x8(%r13,%rbp,8),%xmm0
call   1040 <cos@plt>
subsd  0x20(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm3
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,-0x8(%r14,%rbp,8)
mov    %r12,%rbp
cmp    $0x1,%r15d
je     1257 <bessel_fourier_kernel+0x137>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  -0x8(%r13,%rbp,8),%xmm0
mulsd  %xmm3,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  -0x8(%r13,%rbp,8),%xmm0
call   1040 <cos@plt>
subsd  0x20(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,-0x8(%r14,%rbp,8)
lea    -0x2(%rbp),%rbx
movsd  -0x10(%r13,%rbp,8),%xmm0
mulsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  -0x10(%r13,%rbp,8),%xmm0
call   1040 <cos@plt>
subsd  0x20(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm3
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,-0x10(%r14,%rbp,8)
mov    %rbx,%rbp
test   %ebx,%ebx
jne    11c0 <bessel_fourier_kernel+0xa0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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