#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    11a6 <calcKs+0x76>
mov    -0x1c(%rbp),%edi
add    $0x1,%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,%rbx
add    $0x2,%ebp
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 = %23, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 64
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load i32, i32* %5
%12 = add nsw i32 1, %11
%13 = call i32 @sin(i32 %12)
%14 = call double @fabs(i32 %13)
store double %14, double* %3
%15 = load double, double* %3
%16 = load double, double* %4
%17 = fmul double %15, %16
%18 = fptoui double %17 to i32
%19 = load i32*, i32** %2
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
br label %23
23: ; preds = %10
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %7
26: ; preds = %7
%27 = load i32*, i32** %2
ret i32* %27
}

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 ], [ %12, %3 ]
%5 = or i64 %4, 1
%6 = trunc i64 %5 to i32
%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 = add nuw nsw i64 %4, 2
%13 = trunc i64 %12 to i32
%14 = tail call i32 @sin(i32 %13)
%15 = tail call double @fabs(i32 %14)
%16 = fmul double %2, %15
%17 = fptoui double %16 to i32
%18 = getelementptr inbounds i32, i32* %0, i64 %5
store i32 %17, i32* %18
%19 = icmp eq i64 %12, 64
br i1 %19, label %20, label %3
20: ; preds = %3
ret i32* %0
}