#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 */
float sinf(double);
void make_sine_table(float *tbl, size_t size, int sampleRate) {
  for (size_t i = 0; i < size; i++) {
    tbl[i] = sinf(2.0 * 3.14159265358979323846 * (i + 1.0) / (float)size);
  }
}


x86 assembly (clang, -O0):
<make_sine_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11ef <make_sine_table+0xdf>
movaps 0xec0(%rip),%xmm1
movq   -0x20(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xebf(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xeb8(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xeb4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x28(%rbp)
test   %rax,%rax
movss  %xmm0,-0x24(%rbp)
js     11ba <make_sine_table+0xaa>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movsd  -0x30(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
call   1030 <sinf@plt>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112b <make_sine_table+0x1b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_sine_table>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1272 <make_sine_table+0x162>
mov    %rsi,%r14
mov    %rdi,%r15
js     1130 <make_sine_table+0x20>
cvtsi2ss %r14,%xmm0
jmp    1148 <make_sine_table+0x38>
mov    %r14,%rax
shr    %rax
mov    %r14d,%ecx
and    $0x1,%ecx
or     %rax,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
cmp    $0x1,%r14
jne    1163 <make_sine_table+0x53>
xor    %ebx,%ebx
test   $0x1,%r14b
jne    122f <make_sine_table+0x11f>
jmp    1272 <make_sine_table+0x162>
mov    %r14,%r12
and    $0xfffffffffffffffe,%r12
xor    %ebx,%ebx
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movq   %rbx,%xmm1
movdqa 0xe73(%rip),%xmm0
punpckldq %xmm0,%xmm1
movapd 0xe77(%rip),%xmm0
subpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe6f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe6b(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  (%rsp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,(%r15,%rbx,4)
lea    0x1(%rbx),%rax
movq   %rax,%xmm1
punpckldq 0xe1e(%rip),%xmm1
subpd  0xe26(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe22(%rip),%xmm0
mulsd  0xe22(%rip),%xmm0
divsd  (%rsp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,0x4(%r15,%rbx,4)
add    $0x2,%rbx
cmp    %r12,%rbx
jne    1180 <make_sine_table+0x70>
movsd  (%rsp),%xmm0
test   $0x1,%r14b
je     1272 <make_sine_table+0x162>
movq   %rbx,%xmm1
punpckldq 0xdc4(%rip),%xmm1
subpd  0xdcc(%rip),%xmm1
movaps %xmm0,%xmm2
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  0xdc5(%rip),%xmm0
mulsd  0xdc5(%rip),%xmm0
divsd  %xmm2,%xmm0
call   1030 <sinf@plt>
movss  %xmm0,(%r15,%rbx,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @make_sine_table(float* %0, i64 %1, i32 %2) {
%4 = alloca float*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i64
store float* %0, float** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
store i64 0, i64* %7
br label %8
8: ; preds = %25, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %5
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i64, i64* %7
%14 = uitofp i64 %13 to double
%15 = fadd double %14, 1.000000e+00
%16 = fmul double 0x401921FB54442D18, %15
%17 = load i64, i64* %5
%18 = uitofp i64 %17 to float
%19 = fpext float %18 to double
%20 = fdiv double %16, %19
%21 = call float @sinf(double %20)
%22 = load float*, float** %4
%23 = load i64, i64* %7
%24 = getelementptr inbounds float, float* %22, i64 %23
store float %21, float* %24
br label %25
25: ; preds = %12
%26 = load i64, i64* %7
%27 = add i64 %26, 1
store i64 %27, i64* %7
br label %8
28: ; preds = %8
ret void
}

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