// File: /workspace/github_c_makefile_star2_O1/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 0x1d31(%rip), %rsi      # 0x3128
callq 0x1120
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x1531
movq %rax, %rbx
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x1555
testl %eax, %eax
je 0x1442
leaq 0x1bdf(%rip), %rdi      # 0x3004
xorl %eax, %eax
callq 0x10a0
leaq 0x1c0d(%rip), %rdi      # 0x3040
movq %r15, %rsi
xorl %eax, %eax
callq 0x10a0
jmp 0x1531
cmpb $0x52, 0xa(%rsp)
jne 0x1542
cmpb $0x4d, 0x8(%rsp)
jne 0x1542
cmpb $0x43, 0x9(%rsp)
jne 0x1542
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0xc(%rsp), %rcx
movq %rbx, %rdi
callq 0x18fb
testl %eax, %eax
jne 0x154e
movq 0x60(%rsp), %rbp
movl 0x14(%rsp), %eax
movl %eax, (%r14)
movl 0x10(%rsp), %eax
movl %eax, (%r13)
movslq 0xc(%rsp), %r14
movl %r14d, (%r12)
leaq (,%r14,4), %r15
movq %r15, %rdi
callq 0x1100
movq %rax, %r12
movq %r15, %rdi
callq 0x1100
movq %rax, %r13
shlq $0x3, %r14
movq %r14, %rdi
callq 0x1100
movq %rax, %r14
movq 0x18(%rsp), %rax
movq %r14, (%rax)
movq 0x20(%rsp), %rax
movq %r12, (%rax)
movq %r13, (%rbp)
cmpl $0x0, 0xc(%rsp)
jle 0x1527
leaq 0x1bde(%rip), %r15      # 0x30cc
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x1050
decl (%r12)
decl (%r13)
incq %rbp
movslq 0xc(%rsp), %rax
addq $0x8, %r14
addq $0x4, %r13
addq $0x4, %r12
cmpq %rax, %rbp
jl 0x14f0
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
leaq 0x8(%rsp), %rdi
callq 0x1190
jmp 0x1531
callq 0x11d9
jmp 0x1531