// File: /workspace/github_c_makefile_star2_O3/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, 0x1b0cd(%rip)     # 0x21300
jle 0x624f
leaq 0xdd66(%rip), %rdi      # 0x13fa2
leaq 0xc19c(%rip), %rsi      # 0x123df
movl $0x9f3, %edx            # imm = 0x9F3
xorl %eax, %eax
callq 0xc84f
cmpl $0x64, 0x166f8(%rbx)
jne 0x6260
movl 0x1b0a2(%rip), %eax     # 0x21300
jmp 0x6273
cmpb $0x0, 0x5efd(%rbx)
movl 0x1b093(%rip), %eax     # 0x21300
je 0x630c
testl %eax, %eax
jle 0x6298
leaq 0x5efd(%rbx), %rcx
leaq 0xddb8(%rip), %rdi      # 0x1403d
leaq 0xc153(%rip), %rsi      # 0x123df
movl $0xa08, %edx            # imm = 0xA08
xorl %eax, %eax
callq 0xc84f
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x580c
movl %eax, %r12d
testl %eax, %eax
jne 0x6368
leaq 0x5efd(%rbx), %r12
leaq 0x1e49e(%rip), %r13     # 0x24760
leaq 0xc143(%rip), %rdx      # 0x1240c
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x2140
leaq 0x11d7b(%rip), %rdx     # 0x18060
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 0x5f1a
movl %eax, %r12d
jmp 0x6368
testl %eax, %eax
jle 0x632a
leaq 0xdccc(%rip), %rdi      # 0x13fe3
leaq 0xc0c1(%rip), %rsi      # 0x123df
movl $0xa02, %edx            # imm = 0xA02
xorl %eax, %eax
callq 0xc84f
movl $0x0, 0x59f8(%rbx)
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl %ebp, %ecx
movq %r14, %r8
callq 0x63aa
movl %eax, %r12d
callq 0xd483
testq %rax, %rax
je 0x6368
leaq 0x31fe(%rbx), %rdi
movl $0x27f7, %edx           # imm = 0x27F7
movq %rax, %rsi
callq 0xbede
cmpl $0x0, 0x1af91(%rip)     # 0x21300
jle 0x6398
addq $0x5efd, %rbx           # imm = 0x5EFD
leaq 0xdd16(%rip), %rdi      # 0x14095
leaq 0xc059(%rip), %rsi      # 0x123df
movl $0xa18, %edx            # imm = 0xA18
movq %rbx, %rcx
movl %r12d, %r8d
xorl %eax, %eax
callq 0xc84f
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq