// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x2e86(%rip), %rsi      # 0x4128
callq 0x1130
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x12bd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x149e
movq -0x40(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x14b0
cmpl $0x0, %eax
je 0x12fb
leaq 0x2d2e(%rip), %rdi      # 0x4004
movb $0x0, %al
callq 0x10a0
movq -0x10(%rbp), %rsi
leaq 0x2d58(%rip), %rdi      # 0x4040
movb $0x0, %al
callq 0x10a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x149e
movsbl -0x42(%rbp), %eax
cmpl $0x52, %eax
jne 0x1316
movsbl -0x44(%rbp), %eax
cmpl $0x4d, %eax
jne 0x1316
movsbl -0x43(%rbp), %eax
cmpl $0x43, %eax
je 0x1366
movq 0x4cdb(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x2d28(%rip), %rsi      # 0x404f
movb $0x0, %al
callq 0x10f0
movq 0x4cc3(%rip), %rax      # 0x5ff8
movq (%rax), %rax
movq %rax, -0x78(%rbp)
leaq -0x44(%rbp), %rdi
callq 0x1880
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0x2d26(%rip), %rsi      # 0x4079
movb $0x0, %al
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x149e
movq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x4c(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x1a60
cmpl $0x0, %eax
je 0x13a4
movq 0x4c71(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x2d02(%rip), %rsi      # 0x4093
movb $0x0, %al
callq 0x10f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x149e
movl -0x48(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x4c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x50(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movslq -0x50(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1110
movq %rax, -0x68(%rbp)
movslq -0x50(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1110
movq %rax, -0x70(%rbp)
movslq -0x50(%rbp), %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x70(%rbp), %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x148e
movq -0x40(%rbp), %rdi
movq -0x68(%rbp), %rdx
movslq -0x54(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq -0x70(%rbp), %rcx
movslq -0x54(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rcx
movq -0x60(%rbp), %r8
movslq -0x54(%rbp), %rax
shlq $0x3, %rax
addq %rax, %r8
leaq 0x2c72(%rip), %rsi      # 0x40cc
movb $0x0, %al
callq 0x1060
movq -0x68(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x70(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x141a
movq -0x40(%rbp), %rdi
callq 0x1080
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)