// File: /workspace/github_c_makefile_star2_O2/kkanellis[P]matvec-sparse/mmio.c
// Function: mm_read_mtx_crd
int mm_read_mtx_crd(char *fname, int *M, int *N, int *nz, int **I, int **J, 
        double **val, MM_typecode *matcode)
{
    int ret_code;
    FILE *f;

    if (strcmp(fname, "stdin") == 0) f=stdin;
    else
    if ((f = fopen(fname, "r")) == NULL)
        return MM_COULD_NOT_READ_FILE;


    if ((ret_code = mm_read_banner(f, matcode)) != 0)
        return ret_code;

    if (!(mm_is_valid(*matcode) && mm_is_sparse(*matcode) && 
            mm_is_matrix(*matcode)))
        return MM_UNSUPPORTED_TYPE;

    if ((ret_code = mm_read_mtx_crd_size(f, M, N, nz)) != 0)
        return ret_code;


    *I = (int *)  malloc(*nz * sizeof(int));
    *J = (int *)  malloc(*nz * sizeof(int));
    *val = NULL;

    if (mm_is_complex(*matcode))
    {
        *val = (double *) malloc(*nz * 2 * sizeof(double));
        ret_code = mm_read_mtx_crd_data(f, *M, *N, *nz, *I, *J, *val, 
                *matcode);
        if (ret_code != 0) return ret_code;
    }
    else if (mm_is_real(*matcode))
    {
        *val = (double *) malloc(*nz * sizeof(double));
        ret_code = mm_read_mtx_crd_data(f, *M, *N, *nz, *I, *J, *val, 
                *matcode);
        if (ret_code != 0) return ret_code;
    }

    else if (mm_is_pattern(*matcode))
    {
        ret_code = mm_read_mtx_crd_data(f, *M, *N, *nz, *I, *J, *val, 
                *matcode);
        if (ret_code != 0) return ret_code;
    }

    if (f != stdin) fclose(f);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r12
movq %r8, %rbp
movq %rcx, %r13
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x1657(%rip), %rsi      # 0x316c
callq 0x10e0
testl %eax, %eax
je 0x1b37
leaq 0x1603(%rip), %rsi      # 0x3128
movq %rbx, %rdi
callq 0x1130
testq %rax, %rax
jne 0x1b41
pushq $0xb
popq %rbp
jmp 0x1b67
movq 0x349a(%rip), %rax      # 0x4fd8
movq (%rax), %rax
movq %r14, %rbx
movq %r13, 0x10(%rsp)
movq %rbp, 0x8(%rsp)
movq 0x58(%rsp), %r13
movq %rax, %r14
movq %rax, %rdi
movq %r13, %rsi
callq 0x1457
testl %eax, %eax
je 0x1b78
movl %eax, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x1831
pushq $0xf
popq %rbp
testl %eax, %eax
je 0x1b67
cmpb $0x43, 0x1(%r13)
jne 0x1b67
cmpb $0x4d, (%r13)
jne 0x1b67
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x1787
testl %eax, %eax
jne 0x1b65
movq 0x50(%rsp), %r15
movslq (%rbx), %r13
leaq (,%r13,4), %rbx
movq %rbx, %rdi
callq 0x1100
movq 0x8(%rsp), %rbp
movq %rax, (%rbp)
movq %rbx, %rdi
callq 0x1100
movq %rax, (%r12)
andq $0x0, (%r15)
movq 0x58(%rsp), %rdx
movzbl 0x2(%rdx), %eax
cmpl $0x52, %eax
je 0x1c35
cmpl $0x50, %eax
je 0x1c1f
cmpl $0x43, %eax
movq %r14, %rbx
jne 0x1c6b
movq %r13, %rdi
shlq $0x4, %rdi
movq %rdx, %r14
callq 0x1100
movq %rax, (%r15)
movq (%rbp), %r8
movq (%r12), %r9
movq %rbx, %rdi
movl %r13d, %ecx
pushq %r14
jmp 0x1c59
movq (%rbp), %r8
movq (%r12), %r9
movq %r14, %rbx
movq %r14, %rdi
movl %r13d, %ecx
pushq %rdx
pushq $0x0
jmp 0x1c5a
movq %r13, %rdi
shlq $0x3, %rdi
callq 0x1100
movq %rax, (%r15)
movq (%rbp), %r8
movq (%r12), %r9
movq %r14, %rbx
movq %r14, %rdi
movl %r13d, %ecx
pushq 0x58(%rsp)
pushq %rax
callq 0x1959
addq $0x10, %rsp
testl %eax, %eax
jne 0x1b65
movq 0x3366(%rip), %rax      # 0x4fd8
xorl %ebp, %ebp
cmpq (%rax), %rbx
je 0x1b67
movq %rbx, %rdi
callq 0x1080
jmp 0x1b67