#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 fabs(int /*<<< orphan*/);
double pow(int, int);
int /*<<< orphan*/ sin(int);
unsigned *calcKs(unsigned *k) {
  double s, pwr;
  int i;
  pwr = pow(2, 32);
  for (i = 0; i < 64; i++) {
    s = fabs(sin(1. + i));
    k[i] = (unsigned)(s * pwr);
  }
  return k;
}


x86 assembly (clang, -O0):
<calcKs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x2,%edi
mov    $0x20,%esi
call   1050 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x40,-0x1c(%rbp)
jge    11b5 <calcKs+0x85>
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xe92(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
mov    %eax,%edi
call   1030 <fabs@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <calcKs+0x27>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcKs>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    $0x2,%ebp
mov    $0x2,%edi
mov    $0x20,%esi
call   1050 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1040 <sin@plt>
mov    %eax,%edi
call   1030 <fabs@plt>
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x4(%r14,%rbx,4)
mov    %ebp,%edi
call   1040 <sin@plt>
mov    %eax,%edi
call   1030 <fabs@plt>
mulsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,(%r14,%rbx,4)
add    $0x2,%ebp
add    $0x2,%rbx
cmp    $0x41,%rbx
jne    1160 <calcKs+0x30>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32* @calcKs(i32* %0) {
%2 = alloca i32*
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store i32* %0, i32** %2
%6 = call double @pow(i32 2, i32 32)
store double %6, double* %4
store i32 0, i32* %5
br label %7
7: ; preds = %25, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 64
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load i32, i32* %5
%12 = sitofp i32 %11 to double
%13 = fadd double 1.000000e+00, %12
%14 = fptosi double %13 to i32
%15 = call i32 @sin(i32 %14)
%16 = call double @fabs(i32 %15)
store double %16, double* %3
%17 = load double, double* %3
%18 = load double, double* %4
%19 = fmul double %17, %18
%20 = fptoui double %19 to i32
%21 = load i32*, i32** %2
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
store i32 %20, i32* %24
br label %25
25: ; preds = %10
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %7
28: ; preds = %7
%29 = load i32*, i32** %2
ret i32* %29
}

LLVM IR (-O2):
define i32* @calcKs(i32* returned writeonly %0) {
%2 = tail call double @pow(i32 2, i32 32)
br label %3
3: ; preds = %3, %1
%4 = phi i64 [ 0, %1 ], [ %20, %3 ]
%5 = trunc i64 %4 to i32
%6 = or i32 %5, 1
%7 = tail call i32 @sin(i32 %6)
%8 = tail call double @fabs(i32 %7)
%9 = fmul double %2, %8
%10 = fptoui double %9 to i32
%11 = getelementptr inbounds i32, i32* %0, i64 %4
store i32 %10, i32* %11
%12 = or i64 %4, 1
%13 = trunc i64 %12 to i32
%14 = add nuw nsw i32 %13, 1
%15 = tail call i32 @sin(i32 %14)
%16 = tail call double @fabs(i32 %15)
%17 = fmul double %2, %16
%18 = fptoui double %17 to i32
%19 = getelementptr inbounds i32, i32* %0, i64 %12
store i32 %18, i32* %19
%20 = add nuw nsw i64 %4, 2
%21 = icmp eq i64 %20, 64
br i1 %21, label %22, label %3
22: ; preds = %3
ret i32* %0
}