#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 */
int /*<<< orphan*/ assert(float *);
float cos(unsigned int);
void cpuCalculation(float *pCpuArray) {
  assert(pCpuArray);
  unsigned int i = 0;
  for (i = 0; i < 1000000; i++) {
    pCpuArray[i] = pCpuArray[i] * 43 + 90 * (i - 3);
    pCpuArray[i] = cos(i * 0.1);
  }
}


x86 assembly (clang, -O0):
<cpuCalculation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf4240,-0xc(%rbp)
jae    11bb <cpuCalculation+0x9b>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %ecx,%edx
movss  (%rax,%rcx,4),%xmm0
imul   $0x5a,%edx,%edx
add    $0xfffffef2,%edx
cvtsi2ss %rdx,%xmm1
movss  0xe8c(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xe77(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%edi
call   1040 <cos@plt>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1143 <cpuCalculation+0x23>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpuCalculation>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <assert@plt>
mov    $0xfffffef2,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  (%r14,%rbx,4),%xmm1
mulss  0xea8(%rip),%xmm1
addss  %xmm0,%xmm1
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movss  %xmm1,(%r14,%rbx,4)
mulsd  0xe94(%rip),%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <cos@plt>
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
add    $0x5a,%ebp
cmp    $0xf4240,%rbx
jne    1140 <cpuCalculation+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @cpuCalculation(float* %0) {
%2 = alloca float*
%3 = alloca i32
store float* %0, float** %2
%4 = load float*, float** %2
%5 = call i32 @assert(float* %4)
store i32 0, i32* %3
store i32 0, i32* %3
br label %6
6: ; preds = %33, %1
%7 = load i32, i32* %3
%8 = icmp ult i32 %7, 1000000
br i1 %8, label %9, label %36
9: ; preds = %6
%10 = load float*, float** %2
%11 = load i32, i32* %3
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds float, float* %10, i64 %12
%14 = load float, float* %13
%15 = load i32, i32* %3
%16 = sub i32 %15, 3
%17 = mul i32 90, %16
%18 = uitofp i32 %17 to float
%19 = call float @llvm.fmuladd.f32(float %14, float 4.300000e+01, float %18)
%20 = load float*, float** %2
%21 = load i32, i32* %3
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds float, float* %20, i64 %22
store float %19, float* %23
%24 = load i32, i32* %3
%25 = uitofp i32 %24 to double
%26 = fmul double %25, 1.000000e-01
%27 = fptoui double %26 to i32
%28 = call float @cos(i32 %27)
%29 = load float*, float** %2
%30 = load i32, i32* %3
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
store float %28, float* %32
br label %33
33: ; preds = %9
%34 = load i32, i32* %3
%35 = add i32 %34, 1
store i32 %35, i32* %3
br label %6
36: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @cpuCalculation(float* %0) {
%2 = tail call i32 @assert(float* %0)
br label %3
3: ; preds = %1, %3
%4 = phi i64 [ 0, %1 ], [ %17, %3 ]
%5 = getelementptr inbounds float, float* %0, i64 %4
%6 = load float, float* %5
%7 = trunc i64 %4 to i32
%8 = mul i32 %7, 90
%9 = add i32 %8, -270
%10 = uitofp i32 %9 to float
%11 = tail call float @llvm.fmuladd.f32(float %6, float 4.300000e+01, float %10)
store float %11, float* %5
%12 = trunc i64 %4 to i32
%13 = uitofp i32 %12 to double
%14 = fmul double %13, 1.000000e-01
%15 = fptoui double %14 to i32
%16 = tail call float @cos(i32 %15)
store float %16, float* %5
%17 = add nuw nsw i64 %4, 1
%18 = icmp eq i64 %17, 1000000
br i1 %18, label %19, label %3
19: ; preds = %3
ret void
}