#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 cos(int);
void init_particles(double *x, double *y, double *z, int n) {
  for (int i = 0; i < n; i++) {
    x[i] = cos(i + 0.1);
    y[i] = cos(i + 0.2);
    z[i] = cos(i + 0.3);
  }
}


x86 assembly (clang, -O0):
<init_particles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bd <init_particles+0xad>
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  0xec9(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112e <init_particles+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_particles>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %ecx,%ecx
jle    1197 <init_particles+0x87>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %ecx,%r13d
xor    %ebx,%ebx
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  0xebb(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0xea6(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
addsd  0xe91(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cos@plt>
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1130 <init_particles+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @init_particles(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %42, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %45
14: ; preds = %10
%15 = load i32, i32* %9
%16 = sitofp i32 %15 to double
%17 = fadd double %16, 1.000000e-01
%18 = fptosi double %17 to i32
%19 = call double @cos(i32 %18)
%20 = load double*, double** %5
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
store double %19, double* %23
%24 = load i32, i32* %9
%25 = sitofp i32 %24 to double
%26 = fadd double %25, 2.000000e-01
%27 = fptosi double %26 to i32
%28 = call double @cos(i32 %27)
%29 = load double*, double** %6
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
%33 = load i32, i32* %9
%34 = sitofp i32 %33 to double
%35 = fadd double %34, 3.000000e-01
%36 = fptosi double %35 to i32
%37 = call double @cos(i32 %36)
%38 = load double*, double** %7
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
store double %37, double* %41
br label %42
42: ; preds = %14
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %10
45: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @init_particles(double* nocapture writeonly %0, double* nocapture writeonly %1, double* nocapture writeonly %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %9
8: ; preds = %9, %4
ret void
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %25, %9 ]
%11 = trunc i64 %10 to i32
%12 = sitofp i32 %11 to double
%13 = fadd double %12, 1.000000e-01
%14 = fptosi double %13 to i32
%15 = tail call double @cos(i32 %14)
%16 = getelementptr inbounds double, double* %0, i64 %10
store double %15, double* %16
%17 = fadd double %12, 2.000000e-01
%18 = fptosi double %17 to i32
%19 = tail call double @cos(i32 %18)
%20 = getelementptr inbounds double, double* %1, i64 %10
store double %19, double* %20
%21 = fadd double %12, 3.000000e-01
%22 = fptosi double %21 to i32
%23 = tail call double @cos(i32 %22)
%24 = getelementptr inbounds double, double* %2, i64 %10
store double %23, double* %24
%25 = add nuw nsw i64 %10, 1
%26 = icmp eq i64 %25, %7
br i1 %26, label %8, label %9
}