#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 cos(unsigned int);
float sin(unsigned int);
int simple_circplot_coordinates(short *pair_table, float *x, float *y) {
  unsigned int length = (unsigned int)pair_table[0];
  unsigned int i;
  float d = 2 * 3.141592654 / length;
  for (i = 0; i < length; i++) {
    x[i] = cos(i * d - 3.141592654 / 2);
    y[i] = sin(i * d - 3.141592654 / 2);
  }
  return length;
}


x86 assembly (clang, -O0):
<simple_circplot_coordinates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movswl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  0xeb2(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11f0 <simple_circplot_coordinates+0xd0>
mov    -0x20(%rbp),%eax
cvtsi2ss %rax,%xmm0
movss  -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7d(%rip),%xmm1
movsd  %xmm1,-0x30(%rbp)
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%edi
call   1040 <cos@plt>
movsd  -0x30(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
cvtsi2ss %rax,%xmm0
movss  -0x24(%rbp),%xmm2
mulss  %xmm2,%xmm0
cvtss2sd %xmm0,%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%edi
call   1030 <sin@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1162 <simple_circplot_coordinates+0x42>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_circplot_coordinates>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movswl (%rdi),%r14d
test   %r14d,%r14d
je     1270 <simple_circplot_coordinates+0x150>
mov    %rdx,%r15
mov    %rsi,%r12
cvtsi2sd %r14,%xmm0
movsd  0xeb2(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
cmp    $0x2,%r14d
mov    $0x1,%ebp
cmovae %r14d,%ebp
cmp    $0x1,%r14w
jne    117e <simple_circplot_coordinates+0x5e>
xor    %ebx,%ebx
test   $0x1,%bpl
jne    122f <simple_circplot_coordinates+0x10f>
jmp    1270 <simple_circplot_coordinates+0x150>
mov    %rbp,0x10(%rsp)
and    $0xfffffffe,%ebp
xor    %ebx,%ebx
movss  %xmm0,0xc(%rsp)
xchg   %ax,%ax
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe5c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r13
mov    %r13d,%edi
call   1040 <cos@plt>
movss  %xmm0,(%r12,%rbx,4)
mov    %r13d,%edi
call   1030 <sin@plt>
movss  %xmm0,(%r15,%rbx,4)
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xe1a(%rip),%xmm0
cvttsd2si %xmm0,%r13
mov    %r13d,%edi
call   1040 <cos@plt>
movss  %xmm0,0x4(%r12,%rbx,4)
mov    %r13d,%edi
call   1030 <sin@plt>
movss  %xmm0,0x4(%r15,%rbx,4)
add    $0x2,%rbx
cmp    %rbp,%rbx
jne    1190 <simple_circplot_coordinates+0x70>
movss  0xc(%rsp),%xmm0
mov    0x10(%rsp),%rbp
test   $0x1,%bpl
je     1270 <simple_circplot_coordinates+0x150>
mov    %ebx,%eax
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
addsd  0xdb9(%rip),%xmm0
cvttsd2si %xmm0,%r13
mov    %r13d,%edi
call   1040 <cos@plt>
movss  %xmm0,(%r12,%rbx,4)
mov    %r13d,%edi
call   1030 <sin@plt>
movss  %xmm0,(%r15,%rbx,4)
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @simple_circplot_coordinates(i16* %0, float* %1, float* %2) {
%4 = alloca i16*
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
store i16* %0, i16** %4
store float* %1, float** %5
store float* %2, float** %6
%10 = load i16*, i16** %4
%11 = getelementptr inbounds i16, i16* %10, i64 0
%12 = load i16, i16* %11
%13 = sext i16 %12 to i32
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = uitofp i32 %14 to double
%16 = fdiv double 0x401921FB54524550, %15
%17 = fptrunc double %16 to float
store float %17, float* %9
store i32 0, i32* %8
br label %18
18: ; preds = %47, %3
%19 = load i32, i32* %8
%20 = load i32, i32* %7
%21 = icmp ult i32 %19, %20
br i1 %21, label %22, label %50
22: ; preds = %18
%23 = load i32, i32* %8
%24 = uitofp i32 %23 to float
%25 = load float, float* %9
%26 = fmul float %24, %25
%27 = fpext float %26 to double
%28 = fsub double %27, 0x3FF921FB54524550
%29 = fptoui double %28 to i32
%30 = call float @cos(i32 %29)
%31 = load float*, float** %5
%32 = load i32, i32* %8
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds float, float* %31, i64 %33
store float %30, float* %34
%35 = load i32, i32* %8
%36 = uitofp i32 %35 to float
%37 = load float, float* %9
%38 = fmul float %36, %37
%39 = fpext float %38 to double
%40 = fsub double %39, 0x3FF921FB54524550
%41 = fptoui double %40 to i32
%42 = call float @sin(i32 %41)
%43 = load float*, float** %6
%44 = load i32, i32* %8
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds float, float* %43, i64 %45
store float %42, float* %46
br label %47
47: ; preds = %22
%48 = load i32, i32* %8
%49 = add i32 %48, 1
store i32 %49, i32* %8
br label %18
50: ; preds = %18
%51 = load i32, i32* %7
ret i32 %51
}

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