// File: /workspace/github_c_makefile_star2_O1/inflex[P]ripMIME/mime.c
// Function: MIME_handle_multipart
int MIME_handle_multipart( FFGET_FILE *f, char *unpackdir, struct MIMEH_header_info *h, int current_recursion_level, struct SS_object *ss )
{
    int result = 0;
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_multipart:DEBUG: Decoding multipart/embedded \n",FL);
    // If there is no filename, then we have a "standard"
    // embedded message, which can be just read off as a
    // continuous stream (simply with new boundaries
    //
    if (( h->content_transfer_encoding != _CTRANS_ENCODING_B64)&&( h->filename[0] == '\0' ))
    {
        char *p;

        // If this is a simple 'wrapped' RFC822 email which has no encoding applied to it
        //      (ie, it's just the existing email with a new set of headers around it
        //      then rather than saving it to a file, we'll just peel off these outter
        //      layer of headers and get into the core of the message.  This is why we
        //      call unpack_stage2() because this function just reads the next set of
        //      headers and decodes.
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_multipart:DEBUG: Non base64 encoding AND no filename, embedded message\n",FL);
        h->boundary_located = 0;
        result = MIME_unpack_stage2(f, unpackdir, h, current_recursion_level , ss);
        p = BS_top();
        if (p) PLD_strncpy(h->boundary, p,sizeof(h->boundary));
    } else {
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_multipart:DEBUG: Embedded message has a filename, decoding to file %s",FL,h->filename);
        result = MIME_decode_encoding( f, unpackdir, h, ss );
        if (result == 0)
        {
            // Because we're calling MIME_unpack_single again [ie, recursively calling it
            // we need to now adjust the input-filename so that it correctly is prefixed
            // with the directory we unpacked to.

            snprintf(scratch,sizeof(scratch),"%s/%s",unpackdir, h->filename);
            snprintf(h->filename,sizeof(h->filename),"%s",scratch);

            //result = MIME_unpack_single( unpackdir, h->filename, current_recursion_level +1, ss);
            result = MIME_unpack_single( unpackdir, h->filename, current_recursion_level, ss );
        }

    } // else-if transfer-encoding != B64 && filename was empty
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_multipart:DEBUG: done handling '%s' result = %d",FL,h->filename, result);
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r14
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
cmpl $0x0, 0x1b010(%rip)     # 0x21300
jle 0x630c
leaq 0xdc79(%rip), %rdi      # 0x13f72
leaq 0xc0df(%rip), %rsi      # 0x123df
movl $0x9f3, %edx            # imm = 0x9F3
xorl %eax, %eax
callq 0xc960
cmpl $0x64, 0x166f8(%rbx)
je 0x6322
cmpb $0x0, 0x5efd(%rbx)
je 0x63c0
cmpl $0x0, 0x1afd7(%rip)     # 0x21300
jle 0x634c
leaq 0x5efd(%rbx), %rcx
leaq 0xdcd4(%rip), %rdi      # 0x1400d
leaq 0xc09f(%rip), %rsi      # 0x123df
movl $0xa08, %edx            # imm = 0xA08
xorl %eax, %eax
callq 0xc960
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x5888
movl %eax, %r12d
testl %eax, %eax
jne 0x6421
leaq 0x5efd(%rbx), %r12
leaq 0x1e3ea(%rip), %r13     # 0x24760
leaq 0xc08f(%rip), %rdx      # 0x1240c
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x2140
leaq 0x11cf4(%rip), %rdx     # 0x1808d
movl $0x1001, %esi           # imm = 0x1001
movq %r12, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x2140
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
movq %r14, %rcx
callq 0x5fde
movl %eax, %r12d
jmp 0x6421
cmpl $0x0, 0x1af39(%rip)     # 0x21300
jle 0x63e3
leaq 0xdbe3(%rip), %rdi      # 0x13fb3
leaq 0xc008(%rip), %rsi      # 0x123df
movl $0xa02, %edx            # imm = 0xA02
xorl %eax, %eax
callq 0xc960
movl $0x0, 0x59f8(%rbx)
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl %ebp, %ecx
movq %r14, %r8
callq 0x6463
movl %eax, %r12d
callq 0xd613
testq %rax, %rax
je 0x6421
leaq 0x31fe(%rbx), %rdi
movl $0x27f7, %edx           # imm = 0x27F7
movq %rax, %rsi
callq 0xbfb6
cmpl $0x0, 0x1aed8(%rip)     # 0x21300
jle 0x6451
addq $0x5efd, %rbx           # imm = 0x5EFD
leaq 0xdc2d(%rip), %rdi      # 0x14065
leaq 0xbfa0(%rip), %rsi      # 0x123df
movl $0xa18, %edx            # imm = 0xA18
movq %rbx, %rcx
movl %r12d, %r8d
xorl %eax, %eax
callq 0xc960
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq