#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 _sum_row(double *, int, int);
int /*<<< orphan*/ _update_step(double, double, double, double, double, double,
                                int);
void _update_sparse_speedtest(double *C, double *sumC, double *X, double *sumX,
                              int *I, int *J, int n, int n_idx, int n_step) {
  int iter;
  int k;
  int i = 0;
  int j = 3;
  double tmp1 = _sum_row(X, n, i) - X[i * n + j];
  double tmp2 = _sum_row(X, n, j) - X[j * n + i];
  for (iter = 0; iter < n_step; iter++) {
    for (k = 0; k < n_idx; k++) {
      _update_step(X[i * n + j], tmp1, tmp2, C[i * n + j] + C[j * n + i],
                   sumC[i], sumC[j], 1);
    }
  }
}


x86 assembly (clang, -O0):
<_update_sparse_speedtest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x3,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x10(%rbp),%esi
mov    -0x3c(%rbp),%edx
call   1030 <_sum_row@plt>
mov    -0x18(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x10(%rbp),%esi
mov    -0x40(%rbp),%edx
call   1030 <_sum_row@plt>
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    1262 <_update_sparse_speedtest+0x142>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    124f <_update_sparse_speedtest+0x12f>
mov    -0x18(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm3
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm3
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm4
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm5
mov    $0x1,%edi
call   1040 <_update_step@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11c5 <_update_sparse_speedtest+0xa5>
jmp    1254 <_update_sparse_speedtest+0x134>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b2 <_update_sparse_speedtest+0x92>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_update_sparse_speedtest>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x50(%rsp),%r12d
xor    %ebp,%ebp
mov    %rdx,%rdi
mov    %r12d,%esi
xor    %edx,%edx
call   1030 <_sum_row@plt>
subsd  0x18(%r14),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r14,%rdi
mov    %r12d,%esi
mov    $0x3,%edx
call   1030 <_sum_row@plt>
cmpl   $0x0,0x60(%rsp)
jle    11ea <_update_sparse_speedtest+0xca>
lea    (%r12,%r12,2),%eax
movslq %eax,%r13
subsd  (%r14,%r13,8),%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    1199 <_update_sparse_speedtest+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
cmp    0x60(%rsp),%ebp
je     11ea <_update_sparse_speedtest+0xca>
cmpl   $0x0,0x58(%rsp)
jle    1190 <_update_sparse_speedtest+0x70>
mov    0x58(%rsp),%r12d
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x18(%r14),%xmm0
movsd  0x18(%rbx),%xmm3
addsd  (%rbx,%r13,8),%xmm3
movsd  (%r15),%xmm4
movsd  0x18(%r15),%xmm5
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mov    $0x1,%edi
call   1040 <_update_step@plt>
add    $0xffffffff,%r12d
jne    11b0 <_update_sparse_speedtest+0x90>
jmp    1190 <_update_sparse_speedtest+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_update_sparse_speedtest(double* %0, double* %1, double* %2, double* %3, i32* %4, i32* %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca double
%24 = alloca double
store double* %0, double** %10
store double* %1, double** %11
store double* %2, double** %12
store double* %3, double** %13
store i32* %4, i32** %14
store i32* %5, i32** %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
store i32 0, i32* %21
store i32 3, i32* %22
%25 = load double*, double** %12
%26 = load i32, i32* %16
%27 = load i32, i32* %21
%28 = call double @_sum_row(double* %25, i32 %26, i32 %27)
%29 = load double*, double** %12
%30 = load i32, i32* %21
%31 = load i32, i32* %16
%32 = mul nsw i32 %30, %31
%33 = load i32, i32* %22
%34 = add nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %29, i64 %35
%37 = load double, double* %36
%38 = fsub double %28, %37
store double %38, double* %23
%39 = load double*, double** %12
%40 = load i32, i32* %16
%41 = load i32, i32* %22
%42 = call double @_sum_row(double* %39, i32 %40, i32 %41)
%43 = load double*, double** %12
%44 = load i32, i32* %22
%45 = load i32, i32* %16
%46 = mul nsw i32 %44, %45
%47 = load i32, i32* %21
%48 = add nsw i32 %46, %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %43, i64 %49
%51 = load double, double* %50
%52 = fsub double %42, %51
store double %52, double* %24
store i32 0, i32* %19
br label %53
53: ; preds = %108, %9
%54 = load i32, i32* %19
%55 = load i32, i32* %18
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %111
57: ; preds = %53
store i32 0, i32* %20
br label %58
58: ; preds = %104, %57
%59 = load i32, i32* %20
%60 = load i32, i32* %17
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %107
62: ; preds = %58
%63 = load double*, double** %12
%64 = load i32, i32* %21
%65 = load i32, i32* %16
%66 = mul nsw i32 %64, %65
%67 = load i32, i32* %22
%68 = add nsw i32 %66, %67
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %63, i64 %69
%71 = load double, double* %70
%72 = load double, double* %23
%73 = load double, double* %24
%74 = load double*, double** %10
%75 = load i32, i32* %21
%76 = load i32, i32* %16
%77 = mul nsw i32 %75, %76
%78 = load i32, i32* %22
%79 = add nsw i32 %77, %78
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %74, i64 %80
%82 = load double, double* %81
%83 = load double*, double** %10
%84 = load i32, i32* %22
%85 = load i32, i32* %16
%86 = mul nsw i32 %84, %85
%87 = load i32, i32* %21
%88 = add nsw i32 %86, %87
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds double, double* %83, i64 %89
%91 = load double, double* %90
%92 = fadd double %82, %91
%93 = load double*, double** %11
%94 = load i32, i32* %21
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double, double* %96
%98 = load double*, double** %11
%99 = load i32, i32* %22
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %98, i64 %100
%102 = load double, double* %101
%103 = call i32 @_update_step(double %71, double %72, double %73, double %92, double %97, double %102, i32 1)
br label %104
104: ; preds = %62
%105 = load i32, i32* %20
%106 = add nsw i32 %105, 1
store i32 %106, i32* %20
br label %58
107: ; preds = %58
br label %108
108: ; preds = %107
%109 = load i32, i32* %19
%110 = add nsw i32 %109, 1
store i32 %110, i32* %19
br label %53
111: ; preds = %53
ret void
}

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