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

    if (strcmp(fname, "stdout") == 0) 
        f = stdout;
    else
    if ((f = fopen(fname, "w")) == NULL)
        return MM_COULD_NOT_WRITE_FILE;
    
    /* print banner followed by typecode */
    fprintf(f, "%s ", MatrixMarketBanner);
    fprintf(f, "%s\n", mm_typecode_to_str(matcode));

    /* print matrix sizes and nonzeros */
    fprintf(f, "%d %d %d\n", M, N, nz);

    /* print values */
    if (mm_is_pattern(matcode))
        for (i=0; i<nz; i++)
            fprintf(f, "%d %d\n", I[i], J[i]);
    else
    if (mm_is_real(matcode))
        for (i=0; i<nz; i++)
            fprintf(f, "%d %d %20.16g\n", I[i], J[i], val[i]);
    else
    if (mm_is_complex(matcode))
        for (i=0; i<nz; i++)
            fprintf(f, "%d %d %20.16g %20.16g\n", I[i], J[i], val[2*i], 
                        val[2*i+1]);
    else
    {
        if (f != stdout) fclose(f);
        return MM_UNSUPPORTED_TYPE;
    }

    if (f !=stdout) fclose(f);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %r8, %r14
movl %ecx, %r15d
movl %edx, %ebp
movl %esi, %r13d
movq %rdi, %r12
leaq 0x1485(%rip), %rsi      # 0x3179
callq 0x10e0
testl %eax, %eax
je 0x1d1c
leaq 0x147c(%rip), %rsi      # 0x3180
movq %r12, %rdi
callq 0x1130
movq %rax, %r12
testq %rax, %rax
jne 0x1d26
pushq $0x11
popq %rbx
jmp 0x1e6e
movq 0x32ad(%rip), %rax      # 0x4fd0
movq (%rax), %r12
movl %ebp, 0x4(%rsp)
movq 0x40(%rsp), %rbp
leaq 0x144c(%rip), %rsi      # 0x3182
leaq 0x13a9(%rip), %rdx      # 0x30e6
movl %r13d, (%rsp)
xorl %r13d, %r13d
movq %r12, %rdi
xorl %eax, %eax
callq 0x10f0
movq 0x48(%rsp), %rdi
callq 0x16b9
leaq 0x14af(%rip), %rsi      # 0x320e
movq %r12, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x10f0
leaq 0x13d8(%rip), %rsi      # 0x314b
movq %r12, %rdi
movl (%rsp), %edx
movl 0x4(%rsp), %ecx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x10f0
movq 0x48(%rsp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x52, %eax
je 0x1e1b
cmpl $0x50, %eax
je 0x1deb
cmpl $0x43, %eax
jne 0x1e57
xorl %r13d, %r13d
testl %r15d, %r15d
cmovlel %r13d, %r15d
shlq $0x2, %r15
cmpq %r13, %r15
je 0x1e4c
movl (%r14,%r13), %edx
movl (%rbx,%r13), %ecx
movsd (%rbp,%r13,4), %xmm0
movsd 0x8(%rbp,%r13,4), %xmm1
movq %r12, %rdi
leaq 0x13b7(%rip), %rsi      # 0x3195
movb $0x2, %al
callq 0x10f0
addq $0x4, %r13
jmp 0x1db5
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
leaq 0x1353(%rip), %r13      # 0x314e
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x1e4c
movl (%r14,%rbp,4), %edx
movl (%rbx,%rbp,4), %ecx
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x10f0
incq %rbp
jmp 0x1dfd
testl %r15d, %r15d
cmovlel %r13d, %r15d
cmpq %r13, %r15
je 0x1e4c
movl (%r14,%r13,4), %edx
movl (%rbx,%r13,4), %ecx
movsd (%rbp,%r13,8), %xmm0
movq %r12, %rdi
leaq 0x1346(%rip), %rsi      # 0x3186
movb $0x1, %al
callq 0x10f0
incq %r13
jmp 0x1e22
movq 0x317d(%rip), %rax      # 0x4fd0
xorl %ebx, %ebx
jmp 0x1e61
movq 0x3172(%rip), %rax      # 0x4fd0
pushq $0xf
popq %rbx
cmpq (%rax), %r12
je 0x1e6e
movq %r12, %rdi
callq 0x1080
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq