// File: /workspace/github_c_makefile_star2_O1/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 0x14e3(%rip), %rsi      # 0x316c
callq 0x10e0
testl %eax, %eax
je 0x1cad
leaq 0x148f(%rip), %rsi      # 0x3128
movq %rbx, %rdi
callq 0x1120
testq %rax, %rax
jne 0x1cb7
movl $0xb, %ebp
jmp 0x1cdd
movq 0x3324(%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 0x1555
testl %eax, %eax
je 0x1cee
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 0x19a8
movl $0xf, %ebp
testl %eax, %eax
je 0x1cdd
cmpb $0x43, 0x1(%r13)
jne 0x1cdd
cmpb $0x4d, (%r13)
jne 0x1cdd
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x18fb
testl %eax, %eax
jne 0x1cdb
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)
movq $0x0, (%r15)
movq 0x58(%rsp), %rdx
movzbl 0x2(%rdx), %eax
cmpl $0x52, %eax
je 0x1db0
cmpl $0x50, %eax
je 0x1d9a
cmpl $0x43, %eax
movq %r14, %rbx
jne 0x1de6
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 0x1dd4
movq (%rbp), %r8
movq (%r12), %r9
movq %r14, %rbx
movq %r14, %rdi
movl %r13d, %ecx
pushq %rdx
pushq $0x0
jmp 0x1dd5
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 0x1ad7
addq $0x10, %rsp
testl %eax, %eax
jne 0x1cdb
movq 0x31eb(%rip), %rax      # 0x4fd8
xorl %ebp, %ebp
cmpq (%rax), %rbx
je 0x1cdd
movq %rbx, %rdi
callq 0x1080
jmp 0x1cdd