// File: /workspace/github_c_makefile_star2_O0/inflex[P]ripMIME/mime.c
// Function: MIME_read_raw
size_t MIME_read_raw( char *src_mpname, char *dest_mpname, size_t rw_buffer_size )
{
    size_t readcount, writecount;
    size_t fsize=-1;
    char *rw_buffer;
    int fin;
    int fout;

    rw_buffer = NULL;

    if (*src_mpname == '\0') {
        fin = STDIN_FILENO;
    } else {
        fin = open(src_mpname, O_RDONLY);
        if (fin == -1) {
            LOGGER_log("%s:%d:MIME_read_raw:ERROR: Cannot open '%s' for reading (%s)", FL, src_mpname, strerror(errno));
            return -1;
        }
    }

    rw_buffer = malloc( (rw_buffer_size +1) *sizeof(char) );
    if ( !rw_buffer )
    {
        LOGGER_log("%s:%d:MIME_read:ERROR: could not allocate %d of memory for file read buffer\n",FL, rw_buffer_size );
        return -1;
    }

    /* open up our input file */
    fout = open(dest_mpname,O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
    if (fout == -1) {
        LOGGER_log("%s:%d:MIME_read_raw:ERROR: Cannot open '%s' for writing. (%s)",FL, dest_mpname, strerror(errno));
        return -1;
    }

    fsize=0;
    /* while there is more data, consume it */
    do {
        readcount = read( fin, rw_buffer, rw_buffer_size );
        if (readcount > 0) {
            writecount = write( fout, rw_buffer, readcount );
            if (writecount == -1) {
                LOGGER_log("%s:%d:MIME_read_raw:ERROR: While attempting to write data to '%s' (%s)", FL, dest_mpname, strerror(errno));
                return -1;
            }
            if ( readcount != writecount )
            {
                LOGGER_log("%s:%d:MIME_read_raw:ERROR: Attempted to write %d bytes, but only managed %d to file '%s'",FL, readcount, writecount, dest_mpname );
            }
            fsize += writecount;
        }
    } while (readcount > 0);

    if ((*src_mpname != '\0')&&(readcount >= 0)) {
        close(fin);
    }
    if (readcount == -1) {
        LOGGER_log("%s:%d:MIME_read_raw:ERROR: read() '%s'",FL, strerror(errno));
        return -1;
    }
    close(fout);
    if ( rw_buffer != NULL ) free( rw_buffer );
    return (size_t)(fsize);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $-0x1, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x6569
movl $0x0, -0x44(%rbp)
jmp 0x65c3
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x2320
movl %eax, -0x44(%rbp)
cmpl $-0x1, -0x44(%rbp)
jne 0x65c1
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
callq 0x2050
movl (%rax), %edi
callq 0x23a0
movq -0x50(%rbp), %rcx
movq %rax, %r8
leaq 0x13ff7(%rip), %rdi     # 0x1a598
leaq 0x12f27(%rip), %rsi     # 0x194cf
movl $0x793, %edx            # imm = 0x793
movb $0x0, %al
callq 0x117c0
movq $-0x1, -0x8(%rbp)
jmp 0x67ac
jmp 0x65c3
movq -0x20(%rbp), %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x2290
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x660a
movq -0x20(%rbp), %rcx
leaq 0x13feb(%rip), %rdi     # 0x1a5d5
leaq 0x12ede(%rip), %rsi     # 0x194cf
movl $0x79b, %edx            # imm = 0x79B
movb $0x0, %al
callq 0x117c0
movq $-0x1, -0x8(%rbp)
jmp 0x67ac
movq -0x18(%rbp), %rdi
movl $0x41, %esi
movl $0x180, %edx            # imm = 0x180
movb $0x0, %al
callq 0x2320
movl %eax, -0x48(%rbp)
cmpl $-0x1, -0x48(%rbp)
jne 0x666a
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
callq 0x2050
movl (%rax), %edi
callq 0x23a0
movq -0x58(%rbp), %rcx
movq %rax, %r8
leaq 0x13fd8(%rip), %rdi     # 0x1a622
leaq 0x12e7e(%rip), %rsi     # 0x194cf
movl $0x7a2, %edx            # imm = 0x7A2
movb $0x0, %al
callq 0x117c0
movq $-0x1, -0x8(%rbp)
jmp 0x67ac
movq $0x0, -0x38(%rbp)
movl -0x44(%rbp), %edi
movq -0x40(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x21a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jbe 0x672a
movl -0x48(%rbp), %edi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x20d0
movq %rax, -0x30(%rbp)
cmpq $-0x1, -0x30(%rbp)
jne 0x66ee
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
callq 0x2050
movl (%rax), %edi
callq 0x23a0
movq -0x60(%rbp), %rcx
movq %rax, %r8
leaq 0x13f92(%rip), %rdi     # 0x1a660
leaq 0x12dfa(%rip), %rsi     # 0x194cf
movl $0x7ad, %edx            # imm = 0x7AD
movb $0x0, %al
callq 0x117c0
movq $-0x1, -0x8(%rbp)
jmp 0x67ac
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x671e
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x18(%rbp), %r9
leaq 0x13f9c(%rip), %rdi     # 0x1a6a7
leaq 0x12dbd(%rip), %rsi     # 0x194cf
movl $0x7b2, %edx            # imm = 0x7B2
movb $0x0, %al
callq 0x117c0
movq -0x30(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x672c
cmpq $0x0, -0x28(%rbp)
ja 0x6672
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x6752
cmpq $0x0, -0x28(%rbp)
jb 0x6752
movl -0x44(%rbp), %edi
callq 0x2180
cmpq $-0x1, -0x28(%rbp)
jne 0x678c
callq 0x2050
movl (%rax), %edi
callq 0x23a0
movq %rax, %rcx
leaq 0x13f91(%rip), %rdi     # 0x1a700
leaq 0x12d59(%rip), %rsi     # 0x194cf
movl $0x7bc, %edx            # imm = 0x7BC
movb $0x0, %al
callq 0x117c0
movq $-0x1, -0x8(%rbp)
jmp 0x67ac
movl -0x48(%rbp), %edi
callq 0x2180
cmpq $0x0, -0x40(%rbp)
je 0x67a4
movq -0x40(%rbp), %rdi
callq 0x2030
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)