#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__ sin(double const);
void fhtsinHalfTblFloat(float *dst, unsigned int n) {
  const double twopi_over_n = 6.283185307179586476925286766559 / n;
  for (unsigned int i = 0; i < n; ++i)
    dst[i] = (float)sin(twopi_over_n * i);
}


x86 assembly (clang, -O0):
<fhtsinHalfTblFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  0xed1(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1180 <fhtsinHalfTblFloat+0x70>
movsd  -0x18(%rbp),%xmm0
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
cvtsi2ss %rax,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <fhtsinHalfTblFloat+0x2f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fhtsinHalfTblFloat>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     11db <fhtsinHalfTblFloat+0xcb>
mov    %rdi,%r14
mov    %esi,%r15d
cvtsi2sd %r15,%xmm0
movsd  0xecd(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
cmp    $0x1,%esi
jne    114d <fhtsinHalfTblFloat+0x3d>
xor    %ebx,%ebx
test   $0x1,%r15b
jne    11ba <fhtsinHalfTblFloat+0xaa>
jmp    11db <fhtsinHalfTblFloat+0xcb>
mov    %r15d,%r12d
and    $0xfffffffe,%r12d
xor    %ebx,%ebx
movsd  %xmm0,(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  (%rsp),%xmm0
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,(%r14,%rbx,4)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  (%rsp),%xmm0
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0x4(%r14,%rbx,4)
add    $0x2,%rbx
cmp    %r12,%rbx
jne    1160 <fhtsinHalfTblFloat+0x50>
movsd  (%rsp),%xmm0
test   $0x1,%r15b
je     11db <fhtsinHalfTblFloat+0xcb>
mov    %ebx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @fhtsinHalfTblFloat(float* nocapture writeonly %0, i32 %1) {
%3 = uitofp i32 %1 to double
%4 = fdiv double 0x401921FB54442D18, %3
%5 = icmp eq i32 %1, 0
br i1 %5, label %22, label %6
6: ; preds = %2
%7 = zext i32 %1 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %1, 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 = trunc i64 %13 to i32
%17 = uitofp i32 %16 to double
%18 = fmul double %4, %17
%19 = tail call i64 @sin(double %18)
%20 = sitofp i64 %19 to float
%21 = getelementptr inbounds float, float* %0, i64 %13
store float %20, float* %21
br label %22
22: ; preds = %15, %12, %2
ret void
23: ; preds = %23, %10
%24 = phi i64 [ 0, %10 ], [ %39, %23 ]
%25 = phi i64 [ 0, %10 ], [ %40, %23 ]
%26 = trunc i64 %24 to i32
%27 = uitofp i32 %26 to double
%28 = fmul double %4, %27
%29 = tail call i64 @sin(double %28)
%30 = sitofp i64 %29 to float
%31 = getelementptr inbounds float, float* %0, i64 %24
store float %30, float* %31
%32 = or i64 %24, 1
%33 = trunc i64 %32 to i32
%34 = uitofp i32 %33 to double
%35 = fmul double %4, %34
%36 = tail call i64 @sin(double %35)
%37 = sitofp i64 %36 to float
%38 = getelementptr inbounds float, float* %0, i64 %32
store float %37, float* %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
}