// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x1dd9(%rip), %rsi      # 0x4179
callq 0x10e0
cmpl $0x0, %eax
jne 0x23ba
movq 0x3c1f(%rip), %rax      # 0x5fd0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x23e2
movq -0x10(%rbp), %rdi
leaq 0x1dbb(%rip), %rsi      # 0x4180
callq 0x1130
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x23e0
movl $0x11, -0x4(%rbp)
jmp 0x25ae
jmp 0x23e2
movq -0x38(%rbp), %rdi
leaq 0x1d95(%rip), %rsi      # 0x4182
leaq 0x1cf2(%rip), %rdx      # 0x40e6
movb $0x0, %al
callq 0x10f0
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x18(%rbp), %rdi
callq 0x1880
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x1df4(%rip), %rsi      # 0x420e
movb $0x0, %al
callq 0x10f0
movq -0x38(%rbp), %rdi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
leaq 0x1d15(%rip), %rsi      # 0x414b
movb $0x0, %al
callq 0x10f0
movq 0x18(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x50, %eax
jne 0x2491
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x248c
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x1cd4(%rip), %rsi      # 0x414e
movb $0x0, %al
callq 0x10f0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2451
jmp 0x258e
movq 0x18(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x52, %eax
jne 0x24f2
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x24ed
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq 0x10(%rbp), %rax
movslq -0x3c(%rbp), %rsi
movsd (%rax,%rsi,8), %xmm0
leaq 0x1cab(%rip), %rsi      # 0x4186
movb $0x1, %al
callq 0x10f0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x24a5
jmp 0x258c
movq 0x18(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x43, %eax
jne 0x2568
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x2566
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq 0x10(%rbp), %rax
movl -0x3c(%rbp), %esi
shll %esi
movslq %esi, %rsi
movsd (%rax,%rsi,8), %xmm0
movq 0x10(%rbp), %rax
movl -0x3c(%rbp), %esi
shll %esi
addl $0x1, %esi
movslq %esi, %rsi
movsd (%rax,%rsi,8), %xmm1
leaq 0x1c41(%rip), %rsi      # 0x4195
movb $0x2, %al
callq 0x10f0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2506
jmp 0x258a
movq -0x38(%rbp), %rax
movq 0x3a5d(%rip), %rcx      # 0x5fd0
cmpq (%rcx), %rax
je 0x2581
movq -0x38(%rbp), %rdi
callq 0x1080
movl $0xf, -0x4(%rbp)
jmp 0x25ae
jmp 0x258c
jmp 0x258e
movq -0x38(%rbp), %rax
movq 0x3a37(%rip), %rcx      # 0x5fd0
cmpq (%rcx), %rax
je 0x25a7
movq -0x38(%rbp), %rdi
callq 0x1080
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)