#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*/ fill(double *);
int /*<<< orphan*/ fillVal(double *);
int /*<<< orphan*/ initMat(int *, int *);
int /*<<< orphan*/ initOut(double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ spmv(double *, int *, int *, double *, double *);
int /*<<< orphan*/ srand48(long);
int main() {
  double nzval[1666];
  double x[494];
  double y[494];
  int colind[1666];
  int rowptr[494 + 1];
  int i;
  srand48(8650341L);
  fillVal(nzval);
  fill(x);
  initMat(colind, rowptr);
  initOut(y);
  spmv(nzval, colind, rowptr, x, y);
  printf("\n");
  for (i = 0; i < 494; i++) {
    printf("%d ", y[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x74e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x83fe65,%edi
call   1090 <srand48@plt>
lea    -0x3420(%rbp),%rdi
call   1030 <fillVal@plt>
lea    -0x4390(%rbp),%rdi
call   1080 <fill@plt>
lea    -0x6d10(%rbp),%rdi
lea    -0x74d0(%rbp),%rsi
call   1060 <initMat@plt>
lea    -0x5300(%rbp),%rdi
call   1050 <initOut@plt>
lea    -0x3420(%rbp),%rdi
lea    -0x6d10(%rbp),%rsi
lea    -0x74d0(%rbp),%rdx
lea    -0x4390(%rbp),%rcx
lea    -0x5300(%rbp),%r8
call   1070 <spmv@plt>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x74d4(%rbp)
cmpl   $0x1ee,-0x74d4(%rbp)
jge    1245 <main+0xd5>
movslq -0x74d4(%rbp),%rax
movsd  -0x5300(%rbp,%rax,8),%xmm0
ff ff
lea    0xdd8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x74d4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74d4(%rbp)
jmp    1203 <main+0x93>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x74e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x74c0,%rsp
mov    $0x83fe65,%edi
call   10a0 <srand48@plt>
lea    0x40b0(%rsp),%r14
mov    %r14,%rdi
call   1040 <fillVal@plt>
lea    0x1730(%rsp),%r15
mov    %r15,%rdi
call   1090 <fill@plt>
lea    0x26a0(%rsp),%r13
lea    0xf70(%rsp),%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   1070 <initMat@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <initOut@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
call   1080 <spmv@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
lea    0xdf9(%rip),%r14
nopw   0x0(%rax,%rax,1)
movsd  (%rsp,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x1ee,%rbx
jne    1210 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x74c0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1666 x double]
%3 = alloca [494 x double]
%4 = alloca [494 x double]
%5 = alloca [1666 x i32]
%6 = alloca [495 x i32]
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @srand48(i64 8650341)
%9 = getelementptr inbounds [1666 x double], [1666 x double]* %2, i64 0, i64 0
%10 = call i32 @fillVal(double* %9)
%11 = getelementptr inbounds [494 x double], [494 x double]* %3, i64 0, i64 0
%12 = call i32 @fill(double* %11)
%13 = getelementptr inbounds [1666 x i32], [1666 x i32]* %5, i64 0, i64 0
%14 = getelementptr inbounds [495 x i32], [495 x i32]* %6, i64 0, i64 0
%15 = call i32 @initMat(i32* %13, i32* %14)
%16 = getelementptr inbounds [494 x double], [494 x double]* %4, i64 0, i64 0
%17 = call i32 @initOut(double* %16)
%18 = getelementptr inbounds [1666 x double], [1666 x double]* %2, i64 0, i64 0
%19 = getelementptr inbounds [1666 x i32], [1666 x i32]* %5, i64 0, i64 0
%20 = getelementptr inbounds [495 x i32], [495 x i32]* %6, i64 0, i64 0
%21 = getelementptr inbounds [494 x double], [494 x double]* %3, i64 0, i64 0
%22 = getelementptr inbounds [494 x double], [494 x double]* %4, i64 0, i64 0
%23 = call i32 @spmv(double* %18, i32* %19, i32* %20, double* %21, double* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %25
25: ; preds = %34, %0
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 494
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [494 x double], [494 x double]* %4, i64 0, i64 %30
%32 = load double, double* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %25
37: ; preds = %25
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [1666 x double]
%2 = alloca [494 x double]
%3 = alloca [494 x double]
%4 = alloca [1666 x i32]
%5 = alloca [495 x i32]
%6 = bitcast [1666 x double]* %1 to i8*
%7 = bitcast [494 x double]* %2 to i8*
%8 = bitcast [494 x double]* %3 to i8*
%9 = bitcast [1666 x i32]* %4 to i8*
%10 = bitcast [495 x i32]* %5 to i8*
%11 = tail call i32 @srand48(i64 8650341)
%12 = getelementptr inbounds [1666 x double], [1666 x double]* %1, i64 0, i64 0
%13 = call i32 @fillVal(double* %12)
%14 = getelementptr inbounds [494 x double], [494 x double]* %2, i64 0, i64 0
%15 = call i32 @fill(double* %14)
%16 = getelementptr inbounds [1666 x i32], [1666 x i32]* %4, i64 0, i64 0
%17 = getelementptr inbounds [495 x i32], [495 x i32]* %5, i64 0, i64 0
%18 = call i32 @initMat(i32* %16, i32* %17)
%19 = getelementptr inbounds [494 x double], [494 x double]* %3, i64 0, i64 0
%20 = call i32 @initOut(double* %19)
%21 = call i32 @spmv(double* %12, i32* %16, i32* %17, double* %14, double* %19)
%22 = call i32 @putchar(i32 10)
br label %23
23: ; preds = %0, %23
%24 = phi i64 [ 0, %0 ], [ %28, %23 ]
%25 = getelementptr inbounds [494 x double], [494 x double]* %3, i64 0, i64 %24
%26 = load double, double* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %26)
%28 = add nuw nsw i64 %24, 1
%29 = icmp eq i64 %28, 494
br i1 %29, label %30, label %23
30: ; preds = %23
%31 = call i32 @putchar(i32 10)
ret i32 0
}