#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*/ srand48(int);
void horizontal_sum_cpu(double *m, double *s) {
  int i, j;
  srand48(1);
  for (j = 0; j < 700; j++) {
    for (i = 400 - 1; i >= 0; i--) {
      if (i == 400 - 1)
        s[i + j * 400] = m[i + j * 400];
      else
        s[i + j * 400] = s[i + 1 + j * 400] + m[i + j * 400];
    }
  }
}


x86 assembly (clang, -O0):
<horizontal_sum_cpu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1030 <srand48@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2bc,-0x18(%rbp)
jge    1202 <horizontal_sum_cpu+0xf2>
movl   $0x18f,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11ef <horizontal_sum_cpu+0xdf>
cmpl   $0x18f,-0x14(%rbp)
jne    1191 <horizontal_sum_cpu+0x81>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   $0x190,-0x18(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   $0x190,-0x18(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11dc <horizontal_sum_cpu+0xcc>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   $0x190,-0x18(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   $0x190,-0x18(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   $0x190,-0x18(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11e1 <horizontal_sum_cpu+0xd1>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1145 <horizontal_sum_cpu+0x35>
jmp    11f4 <horizontal_sum_cpu+0xe4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1131 <horizontal_sum_cpu+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<horizontal_sum_cpu>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%edi
call   1030 <srand48@plt>
xor    %eax,%eax
mov    %rbx,%rcx
mov    %r14,%rdx
nopl   0x0(%rax)
imul   $0xc80,%rax,%rsi
movsd  0xc78(%rbx,%rsi,1),%xmm0
movsd  %xmm0,0xc78(%r14,%rsi,1)
mov    $0x18f,%esi
nop
movsd  (%rdx,%rsi,8),%xmm0
addsd  -0x8(%rcx,%rsi,8),%xmm0
movsd  %xmm0,-0x8(%rdx,%rsi,8)
addsd  -0x10(%rcx,%rsi,8),%xmm0
movsd  %xmm0,-0x10(%rdx,%rsi,8)
addsd  -0x18(%rcx,%rsi,8),%xmm0
movsd  %xmm0,-0x18(%rdx,%rsi,8)
add    $0xfffffffffffffffd,%rsi
jne    1150 <horizontal_sum_cpu+0x40>
add    $0x1,%rax
add    $0xc80,%rdx
add    $0xc80,%rcx
cmp    $0x2bc,%rax
jne    1130 <horizontal_sum_cpu+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @horizontal_sum_cpu(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
store double* %0, double** %3
store double* %1, double** %4
%7 = call i32 @srand48(i32 1)
store i32 0, i32* %6
br label %8
8: ; preds = %65, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 700
br i1 %10, label %11, label %68
11: ; preds = %8
store i32 399, i32* %5
br label %12
12: ; preds = %61, %11
%13 = load i32, i32* %5
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %64
15: ; preds = %12
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 399
br i1 %17, label %18, label %34
18: ; preds = %15
%19 = load double*, double** %3
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = mul nsw i32 %21, 400
%23 = add nsw i32 %20, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %19, i64 %24
%26 = load double, double* %25
%27 = load double*, double** %4
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = mul nsw i32 %29, 400
%31 = add nsw i32 %28, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %27, i64 %32
store double %26, double* %33
br label %60
34: ; preds = %15
%35 = load double*, double** %4
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
%38 = load i32, i32* %6
%39 = mul nsw i32 %38, 400
%40 = add nsw i32 %37, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %35, i64 %41
%43 = load double, double* %42
%44 = load double*, double** %3
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = mul nsw i32 %46, 400
%48 = add nsw i32 %45, %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %44, i64 %49
%51 = load double, double* %50
%52 = fadd double %43, %51
%53 = load double*, double** %4
%54 = load i32, i32* %5
%55 = load i32, i32* %6
%56 = mul nsw i32 %55, 400
%57 = add nsw i32 %54, %56
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %53, i64 %58
store double %52, double* %59
br label %60
60: ; preds = %34, %18
br label %61
61: ; preds = %60
%62 = load i32, i32* %5
%63 = add nsw i32 %62, -1
store i32 %63, i32* %5
br label %12
64: ; preds = %12
br label %65
65: ; preds = %64
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %8
68: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @horizontal_sum_cpu(double* nocapture %0, double* nocapture %1) {
%3 = tail call i32 @srand48(i32 1)
br label %4
4: ; preds = %41, %2
%5 = phi i64 [ 0, %2 ], [ %42, %41 ]
%6 = mul nuw nsw i64 %5, 400
%7 = add nuw nsw i64 %6, 399
%8 = getelementptr inbounds double, double* %1, i64 %7
%9 = getelementptr inbounds double, double* %0, i64 %7
%10 = load double, double* %9
store double %10, double* %8
br label %11
11: ; preds = %11, %4
%12 = phi i64 [ 398, %4 ], [ %39, %11 ]
%13 = add nuw nsw i64 %12, %6
%14 = add nuw nsw i64 %13, 1
%15 = getelementptr inbounds double, double* %1, i64 %14
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %0, i64 %13
%18 = load double, double* %17
%19 = fadd double %16, %18
%20 = getelementptr inbounds double, double* %1, i64 %13
store double %19, double* %20
%21 = add nsw i64 %12, -1
%22 = add nuw nsw i64 %21, %6
%23 = add i64 %12, %6
%24 = getelementptr inbounds double, double* %1, i64 %23
%25 = load double, double* %24
%26 = getelementptr inbounds double, double* %0, i64 %22
%27 = load double, double* %26
%28 = fadd double %25, %27
%29 = getelementptr inbounds double, double* %1, i64 %22
store double %28, double* %29
%30 = add nsw i64 %12, -2
%31 = add nuw nsw i64 %30, %6
%32 = add nuw nsw i64 %31, 1
%33 = getelementptr inbounds double, double* %1, i64 %32
%34 = load double, double* %33
%35 = getelementptr inbounds double, double* %0, i64 %31
%36 = load double, double* %35
%37 = fadd double %34, %36
%38 = getelementptr inbounds double, double* %1, i64 %31
store double %37, double* %38
%39 = add nsw i64 %12, -3
%40 = icmp eq i64 %30, 0
br i1 %40, label %41, label %11
41: ; preds = %11
%42 = add nuw nsw i64 %5, 1
%43 = icmp eq i64 %42, 700
br i1 %43, label %44, label %4
44: ; preds = %41
ret void
}