#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
void compute0(double *vx, double *vy, double *vz, size_t size, double *x,
              double *time_spent) {
  clock_t begin, end;
  begin = clock();
  size_t i;
  for (i = 0; i < size; i++) {
    *x += vx[i] + vy[i] + vz[i];
  }
  end = clock();
  *time_spent += (double)(end - begin) / CLOCKS_PER_SEC;
}


x86 assembly (clang, -O0):
<compute0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1195 <compute0+0x85>
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x48(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x48(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1143 <compute0+0x33>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
sub    -0x38(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e34(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute0>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r12
mov    %rcx,%r15
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rbp
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,(%rsp)
test   %r15,%r15
je     11c4 <compute0+0xb4>
movsd  (%r12),%xmm0
cmp    $0x1,%r15
jne    1151 <compute0+0x41>
xor    %eax,%eax
jmp    11a2 <compute0+0x92>
mov    %r15,%rcx
and    $0xfffffffffffffffe,%rcx
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movsd  0x0(%rbp,%rax,8),%xmm1
addsd  (%rbx,%rax,8),%xmm1
addsd  0x0(%r13,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r12)
movsd  0x8(%rbp,%rax,8),%xmm0
addsd  0x8(%rbx,%rax,8),%xmm0
addsd  0x8(%r13,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r12)
add    $0x2,%rax
cmp    %rax,%rcx
jne    1160 <compute0+0x50>
test   $0x1,%r15b
je     11c4 <compute0+0xb4>
movsd  0x0(%rbp,%rax,8),%xmm1
addsd  (%rbx,%rax,8),%xmm1
addsd  0x0(%r13,%rax,8),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r12)
xor    %eax,%eax
call   1030 <clock@plt>
sub    (%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2e0a(%rip),%rax
divsd  (%rax),%xmm0
addsd  (%r14),%xmm0
movsd  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @compute0(double* %0, double* %1, double* %2, i64 %3, double* %4, double* %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i64
%11 = alloca double*
%12 = alloca double*
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
store double* %0, double** %7
store double* %1, double** %8
store double* %2, double** %9
store i64 %3, i64* %10
store double* %4, double** %11
store double* %5, double** %12
%16 = call i64 (...) @clock()
store i64 %16, i64* %13
store i64 0, i64* %15
br label %17
17: ; preds = %39, %6
%18 = load i64, i64* %15
%19 = load i64, i64* %10
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %42
21: ; preds = %17
%22 = load double*, double** %7
%23 = load i64, i64* %15
%24 = getelementptr inbounds double, double* %22, i64 %23
%25 = load double, double* %24
%26 = load double*, double** %8
%27 = load i64, i64* %15
%28 = getelementptr inbounds double, double* %26, i64 %27
%29 = load double, double* %28
%30 = fadd double %25, %29
%31 = load double*, double** %9
%32 = load i64, i64* %15
%33 = getelementptr inbounds double, double* %31, i64 %32
%34 = load double, double* %33
%35 = fadd double %30, %34
%36 = load double*, double** %11
%37 = load double, double* %36
%38 = fadd double %37, %35
store double %38, double* %36
br label %39
39: ; preds = %21
%40 = load i64, i64* %15
%41 = add i64 %40, 1
store i64 %41, i64* %15
br label %17
42: ; preds = %17
%43 = call i64 (...) @clock()
store i64 %43, i64* %14
%44 = load i64, i64* %14
%45 = load i64, i64* %13
%46 = sub nsw i64 %44, %45
%47 = sitofp i64 %46 to double
%48 = load double, double* @CLOCKS_PER_SEC
%49 = fdiv double %47, %48
%50 = load double*, double** %12
%51 = load double, double* %50
%52 = fadd double %51, %49
store double %52, double* %50
ret void
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @compute0(double* nocapture %0, double* nocapture %1, double* nocapture %2, i64 %3, double* nocapture %4, double* nocapture %5) {
%7 = tail call i64 (...) @clock()
%8 = icmp eq i64 %3, 0
br i1 %8, label %55, label %9
9: ; preds = %6
%10 = load double, double* %4
%11 = and i64 %3, 1
%12 = icmp eq i64 %3, 1
br i1 %12, label %41, label %13
13: ; preds = %9
%14 = and i64 %3, -2
br label %15
15: ; preds = %15, %13
%16 = phi double [ %10, %13 ], [ %37, %15 ]
%17 = phi i64 [ 0, %13 ], [ %38, %15 ]
%18 = phi i64 [ 0, %13 ], [ %39, %15 ]
%19 = getelementptr inbounds double, double* %0, i64 %17
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %1, i64 %17
%22 = load double, double* %21
%23 = fadd double %20, %22
%24 = getelementptr inbounds double, double* %2, i64 %17
%25 = load double, double* %24
%26 = fadd double %23, %25
%27 = fadd double %16, %26
store double %27, double* %4
%28 = or i64 %17, 1
%29 = getelementptr inbounds double, double* %0, i64 %28
%30 = load double, double* %29
%31 = getelementptr inbounds double, double* %1, i64 %28
%32 = load double, double* %31
%33 = fadd double %30, %32
%34 = getelementptr inbounds double, double* %2, i64 %28
%35 = load double, double* %34
%36 = fadd double %33, %35
%37 = fadd double %27, %36
store double %37, double* %4
%38 = add nuw i64 %17, 2
%39 = add i64 %18, 2
%40 = icmp eq i64 %39, %14
br i1 %40, label %41, label %15
41: ; preds = %15, %9
%42 = phi double [ %10, %9 ], [ %37, %15 ]
%43 = phi i64 [ 0, %9 ], [ %38, %15 ]
%44 = icmp eq i64 %11, 0
br i1 %44, label %55, label %45
45: ; preds = %41
%46 = getelementptr inbounds double, double* %0, i64 %43
%47 = load double, double* %46
%48 = getelementptr inbounds double, double* %1, i64 %43
%49 = load double, double* %48
%50 = fadd double %47, %49
%51 = getelementptr inbounds double, double* %2, i64 %43
%52 = load double, double* %51
%53 = fadd double %50, %52
%54 = fadd double %42, %53
store double %54, double* %4
br label %55
55: ; preds = %45, %41, %6
%56 = tail call i64 (...) @clock()
%57 = sub nsw i64 %56, %7
%58 = sitofp i64 %57 to double
%59 = load double, double* @CLOCKS_PER_SEC
%60 = fdiv double %58, %59
%61 = load double, double* %5
%62 = fadd double %61, %60
store double %62, double* %5
ret void
}