// File: /workspace/github_c_makefile_star2_O2/kkanellis[P]matvec-sparse/mmio.c
// Function: mm_read_unsymmetric_sparse
int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_, int *nz_,
                double **val_, int **I_, int **J_)
{
    FILE *f;
    MM_typecode matcode;
    int M, N, nz;
    int i;
    double *val;
    int *I, *J;
 
    if ((f = fopen(fname, "r")) == NULL)
            return -1;
 
 
    if (mm_read_banner(f, &matcode) != 0)
    {
        printf("mm_read_unsymetric: Could not process Matrix Market banner ");
        printf(" in file [%s]\n", fname);
        return -1;
    }
 
 
 
    if ( !(mm_is_real(matcode) && mm_is_matrix(matcode) &&
            mm_is_sparse(matcode)))
    {
        fprintf(stderr, "Sorry, this application does not support ");
        fprintf(stderr, "Market Market type: [%s]\n",
                mm_typecode_to_str(matcode));
        return -1;
    }
 
    /* find out size of sparse matrix: M, N, nz .... */
 
    if (mm_read_mtx_crd_size(f, &M, &N, &nz) !=0)
    {
        fprintf(stderr, "read_unsymmetric_sparse(): could not parse matrix size.\n");
        return -1;
    }
 
    *M_ = M;
    *N_ = N;
    *nz_ = nz;
 
    /* reseve memory for matrices */
 
    I = (int *) malloc(nz * sizeof(int));
    J = (int *) malloc(nz * sizeof(int));
    val = (double *) malloc(nz * sizeof(double));
 
    *val_ = val;
    *I_ = I;
    *J_ = J;
 
    /* NOTE: when reading in doubles, ANSI C requires the use of the "l"  */
    /*   specifier as in "%lg", "%lf", "%le", otherwise errors will occur */
    /*  (ANSI C X3.159-1989, Sec. 4.9.6.2, p. 136 lines 13-15)            */
 
    for (i=0; i<nz; i++)
    {
        fscanf(f, "%d %d %lg\n", &I[i], &J[i], &val[i]);
        I[i]--;  /* adjust from 1-based to 0-based */
        J[i]--;
    }
    fclose(f);
 
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %r15
leaq 0x1e71(%rip), %rsi      # 0x3128
callq 0x1130
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x13e9
movq %rax, %rbx
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x1457
testl %eax, %eax
je 0x1300
leaq 0x1d21(%rip), %rdi      # 0x3004
xorl %eax, %eax
callq 0x10a0
leaq 0x1d4f(%rip), %rdi      # 0x3040
movq %r15, %rsi
xorl %eax, %eax
callq 0x10a0
jmp 0x13e9
cmpb $0x52, 0xa(%rsp)
jne 0x13fa
cmpb $0x4d, 0x8(%rsp)
jne 0x13fa
cmpb $0x43, 0x9(%rsp)
jne 0x13fa
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0xc(%rsp), %rcx
movq %rbx, %rdi
callq 0x1787
testl %eax, %eax
jne 0x1439
movq 0x60(%rsp), %r15
movl 0x14(%rsp), %eax
movl %eax, (%r14)
movl 0x10(%rsp), %eax
movl %eax, (%r13)
movslq 0xc(%rsp), %rbp
movl %ebp, (%r12)
leaq (,%rbp,4), %r14
movq %r14, %rdi
callq 0x1100
movq %rax, %r12
movq %r14, %rdi
callq 0x1100
movq %rax, %r13
movq %rbp, %rdi
shlq $0x3, %rdi
callq 0x1100
movq %rax, %r14
movq 0x18(%rsp), %rax
movq %r14, (%rax)
movq 0x20(%rsp), %rax
movq %r12, (%rax)
movq %r13, (%r15)
xorl %r15d, %r15d
movslq %ebp, %rax
cmpq %rax, %r15
jge 0x13df
movq %rbx, %rdi
leaq 0x1d1a(%rip), %rsi      # 0x30cc
movq %r12, %rdx
movq %r13, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x1050
decl (%r12)
decl (%r13)
incq %r15
movl 0xc(%rsp), %ebp
addq $0x8, %r14
addq $0x4, %r13
addq $0x4, %r12
jmp 0x13a0
movq %rbx, %rdi
callq 0x1080
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3bf7(%rip), %rbx      # 0x4ff8
movq (%rbx), %rcx
leaq 0x1c44(%rip), %rdi      # 0x304f
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
callq 0x1160
movq (%rbx), %rbx
leaq 0x8(%rsp), %rdi
callq 0x16b9
leaq 0x1c4f(%rip), %rsi      # 0x3079
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x10f0
jmp 0x13e9
movq 0x3bb8(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0x1c49(%rip), %rdi      # 0x3093
pushq $0x38
popq %rsi
pushq $0x1
popq %rdx
callq 0x1160
jmp 0x13e9