// File: /workspace/github_c_makefile_star2_O0/inflex[P]ripMIME/mime.c
// Function: MIME_handle_rfc822
int MIME_handle_rfc822( FFGET_FILE *f, char *unpackdir, struct MIMEH_header_info *h, int current_recursion_level, struct SS_object *ss )
{
    /** Decode a RFC822 encoded stream of data from *f  **/
    int result = 0;
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_rfc822:DEBUG: Decoding RFC822 message\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
     **/
    DMIME LOGGER_log("%s:%d:MIME_handle_rfc822:DEBUG: Filename='%s', encoding = %d",FL, h->filename, h->content_transfer_encoding);

    //  if ((0)&&( h->content_transfer_encoding != _CTRANS_ENCODING_B64)&&( h->filename[0] == '0' )) 20041217-1635:PLD:
    if (( h->content_transfer_encoding != _CTRANS_ENCODING_B64)&&( h->filename[0] == '\0' ))
    {
        /** Handle a simple plain text wrapped RFC822 email with no encoding applied to it **/
        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.
        DMIME LOGGER_log("%s:%d:MIME_handle_rfc822: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 {
        /** ...else... if the section has a filename or B64 type encoding, we need to put it through extra decoding **/
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_rfc822:DEBUG: Embedded message has a filename, decoding to file %s",FL,h->filename);
        result = MIME_decode_encoding( f, unpackdir, h, ss );
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_rfc822:DEBUG: Result of extracting %s is %d",FL,h->filename, result);
        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. **/

            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_rfc822:DEBUG: Now attempting to extract contents of '%s'",FL,h->filename);
            snprintf(scratch,sizeof(scratch),"%s/%s",unpackdir, h->filename);
            snprintf(h->filename,sizeof(h->filename),"%s",scratch);

            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_rfc822:DEBUG: Now attempting to extract contents of '%s'",FL,scratch);
            result = MIME_unpack_single( unpackdir, scratch, current_recursion_level, ss );
            result = 0;
        }
    } /** else-if transfer-encoding != B64 && filename was empty **/
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_handle_rfc822:DEBUG: done handling '%s' result = %d",FL,h->filename, result);
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x1, 0x1edd7(%rip)     # 0x276f0
jl 0x8935
leaq 0x1267c(%rip), %rdi     # 0x1af9e
leaq 0x10ba6(%rip), %rsi     # 0x194cf
movl $0xa33, %edx            # imm = 0xA33
movb $0x0, %al
callq 0x117c0
cmpl $0x1, 0x1edb4(%rip)     # 0x276f0
jl 0x896e
movq -0x18(%rbp), %rcx
addq $0x5efd, %rcx           # imm = 0x5EFD
movq -0x18(%rbp), %rax
movl 0x166f8(%rax), %r8d
leaq 0x1267c(%rip), %rdi     # 0x1afd7
leaq 0x10b6d(%rip), %rsi     # 0x194cf
movl $0xa38, %edx            # imm = 0xA38
movb $0x0, %al
callq 0x117c0
movq -0x18(%rbp), %rax
cmpl $0x64, 0x166f8(%rax)
je 0x8a09
movq -0x18(%rbp), %rax
movsbl 0x5efd(%rax), %eax
cmpl $0x0, %eax
jne 0x8a09
cmpl $0x1, 0x1ed5a(%rip)     # 0x276f0
jl 0x89b2
leaq 0x12675(%rip), %rdi     # 0x1b014
leaq 0x10b29(%rip), %rsi     # 0x194cf
movl $0xa46, %edx            # imm = 0xA46
movb $0x0, %al
callq 0x117c0
movq -0x18(%rbp), %rax
movl $0x0, 0x59f8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %r8
callq 0x7e40
movl %eax, -0x2c(%rbp)
callq 0x12b70
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x8a04
movq -0x18(%rbp), %rdi
addq $0x31fe, %rdi           # imm = 0x31FE
movq -0x38(%rbp), %rsi
movl $0x27f7, %edx           # imm = 0x27F7
callq 0x10640
jmp 0x8b54
cmpl $0x1, 0x1ece0(%rip)     # 0x276f0
jl 0x8a37
movq -0x18(%rbp), %rcx
addq $0x5efd, %rcx           # imm = 0x5EFD
leaq 0x12647(%rip), %rdi     # 0x1b06b
leaq 0x10aa4(%rip), %rsi     # 0x194cf
movl $0xa4d, %edx            # imm = 0xA4D
movb $0x0, %al
callq 0x117c0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x6e60
movl %eax, -0x2c(%rbp)
cmpl $0x1, 0x1ec9a(%rip)     # 0x276f0
jl 0x8a81
movq -0x18(%rbp), %rcx
addq $0x5efd, %rcx           # imm = 0x5EFD
movl -0x2c(%rbp), %r8d
leaq 0x12652(%rip), %rdi     # 0x1b0c0
leaq 0x10a5a(%rip), %rsi     # 0x194cf
movl $0xa4f, %edx            # imm = 0xA4F
movb $0x0, %al
callq 0x117c0
cmpl $0x0, -0x2c(%rbp)
jne 0x8b52
cmpl $0x1, 0x1ec5e(%rip)     # 0x276f0
jl 0x8ab9
movq -0x18(%rbp), %rcx
addq $0x5efd, %rcx           # imm = 0x5EFD
leaq 0x12658(%rip), %rdi     # 0x1b0fe
leaq 0x10a22(%rip), %rsi     # 0x194cf
movl $0xa55, %edx            # imm = 0xA55
movb $0x0, %al
callq 0x117c0
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
addq $0x5efd, %r8            # imm = 0x5EFD
leaq 0x22081(%rip), %rdi     # 0x2ab50
movl $0x400, %esi            # imm = 0x400
leaq 0x10a21(%rip), %rdx     # 0x194fc
movb $0x0, %al
callq 0x2130
movq -0x18(%rbp), %rdi
addq $0x5efd, %rdi           # imm = 0x5EFD
movl $0x1001, %esi           # imm = 0x1001
leaq 0x164b1(%rip), %rdx     # 0x1efaa
leaq 0x22050(%rip), %rcx     # 0x2ab50
movb $0x0, %al
callq 0x2130
cmpl $0x1, 0x1ebe2(%rip)     # 0x276f0
jl 0x8b31
leaq 0x125e7(%rip), %rdi     # 0x1b0fe
leaq 0x109b1(%rip), %rsi     # 0x194cf
movl $0xa59, %edx            # imm = 0xA59
leaq 0x22026(%rip), %rcx     # 0x2ab50
movb $0x0, %al
callq 0x117c0
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %edx
movq -0x28(%rbp), %rcx
leaq 0x2200d(%rip), %rsi     # 0x2ab50
callq 0x78b0
movl %eax, -0x2c(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x8b54
cmpl $0x1, 0x1eb95(%rip)     # 0x276f0
jl 0x8b86
movq -0x18(%rbp), %rcx
addq $0x5efd, %rcx           # imm = 0x5EFD
movl -0x2c(%rbp), %r8d
leaq 0x125d6(%rip), %rdi     # 0x1b149
leaq 0x10955(%rip), %rsi     # 0x194cf
movl $0xa5e, %edx            # imm = 0xA5E
movb $0x0, %al
callq 0x117c0
movl -0x2c(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop