// File: /workspace/github_c_makefile_star2_O2/inflex[P]ripMIME/mime.c
// Function: MIME_unpack_single_fp
int MIME_unpack_single_fp( char *unpackdir, FILE *fi, int current_recursion_level, struct SS_object *ss )
{
    struct MIMEH_header_info h;
    int result = 0;
    int headers_save_set_here = 0;

    FFGET_FILE f;
    FILE *hf = NULL;
    // Because this MIME module gets used in both CLI and daemon modes
    //  we should check to see that we can report to stderr
    //
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_single_fp:DEBUG: dir=%s level=%d (max = %d)\n",FL, unpackdir, current_recursion_level, glb.max_recursion_level);
    if (current_recursion_level > glb.max_recursion_level)
    {
        LOGGER_log("%s:%d:MIME_unpack_single_fp:WARNING: Current recursion level of %d is greater than permitted %d",FL, current_recursion_level, glb.max_recursion_level);
        //      return -1;
        return MIME_ERROR_RECURSION_LIMIT_REACHED; // 20040305-1302:PLD
        //return 0; // 20040208-1723:PLD
    }
    else h.current_recursion_level = current_recursion_level;
    glb.current_line = 0;
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_single_fp:DEBUG: recursion level checked...%d\n",FL, current_recursion_level);
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_single_fp:DEBUG: DumpHeaders = %d\n",FL, glb.save_headers);
    if ((!hf)&&(glb.save_headers)&&(MIMEH_get_headers_save()==0))
    {
        // Prepend the unpackdir path to the headers file name
        snprintf(scratch,sizeof(scratch),"%s/%s",unpackdir, glb.headersname);
        hf = fopen(scratch,"w");
        if (!hf)
        {
            glb.save_headers = 0;
            LOGGER_log("%s:%d:MIME_unpack_single_fp:ERROR: Cannot open '%s' for writing  (%s)",FL, glb.headersname,strerror(errno));
        }
        else
        {
            headers_save_set_here = 1;
            MIMEH_set_headers_save(hf);
        }
    }

    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_single_fp:DEBUG: Setting up streams to decode\n",FL);
    FFGET_setstream(&f, fi);
    /** Initialize the header record **/
    h.boundary[0] = '\0';
    h.boundary_located = 0;
    h.filename[0] = '\0';
    h.name[0]     = '\0';
    h.content_transfer_encoding = -1;
    h.content_disposition = -1;
    h.content_type = -1;
    h.x_mac = 0;
    SS_init(&(h.ss_filenames));
    SS_init(&(h.ss_names));
    if (MIME_DNORMAL) { SS_set_debug(&(h.ss_filenames), 1); SS_set_debug(&(h.ss_names), 1); }
    if (glb.verbose_defects) {
        int i;
        for (i = 0; i < _MIMEH_DEFECT_ARRAY_SIZE; i++)
        {
            h.defects[i] = 0;
        }
    }

    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_single_fp:DEBUG: preparing to decode, calling stage2...\n",FL);
    // 20040318-0001:PLD
    result = MIME_unpack_stage2(&f, unpackdir, &h, current_recursion_level +1, ss);
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_single_fp:DEBUG: done decoding ( in stage2 ) result=%d, to %s\n",FL, result, unpackdir);
    //  fclose(fi); 20040208-1726:PLD
    if ( headers_save_set_here > 0 )
    {
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_single_fp:DEBUG: Closing header file.\n",FL);
        fflush(stdout);
        MIMEH_set_headers_nosave();
        fclose(hf);
    }

    if (glb.verbose_defects) MIMEH_dump_defects(&h);
    /** Flush out the string stacks **/
    SS_done(&(h.ss_filenames));
    SS_done(&(h.ss_names));
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_single_fp:DEBUG: Done. Result=%d Recursion=%d\n",FL, result, current_recursion_level);
    return result;
    //  return status; // 20040305-1318:PLD
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1adc8, %rsp          # imm = 0x1ADC8
movq %rcx, %r15
movl %edx, %ebx
movq %rsi, %r13
movq %rdi, %r14
cmpl $0x0, 0x1929a(%rip)     # 0x20300
jle 0x708f
movl 0x19ae1(%rip), %r9d     # 0x20b50
leaq 0xccce(%rip), %rdi      # 0x13d44
leaq 0xa362(%rip), %rsi      # 0x113df
movl $0xc6d, %edx            # imm = 0xC6D
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0xc2a1
movl 0x19aba(%rip), %r8d     # 0x20b50
cmpl %ebx, %r8d
jge 0x70c2
leaq 0xcce1(%rip), %rdi      # 0x13d83
leaq 0xa336(%rip), %rsi      # 0x113df
movl $0xc70, %edx            # imm = 0xC70
movl %ebx, %ecx
xorl %eax, %eax
callq 0xc2a1
movl $0xf0, %r15d
jmp 0x7316
andl $0x0, 0x19a57(%rip)     # 0x20b20
movl %ebx, 0x1ac14(%rsp)
cmpl $0x0, 0x19229(%rip)     # 0x20300
jle 0x711e
leaq 0xcd03(%rip), %rdi      # 0x13de3
leaq 0xa2f8(%rip), %rsi      # 0x113df
movl $0xc77, %edx            # imm = 0xC77
movl %ebx, %ecx
xorl %eax, %eax
callq 0xc2a1
cmpl $0x0, 0x19204(%rip)     # 0x20300
jle 0x711e
movl 0x19a14(%rip), %ecx     # 0x20b18
leaq 0xcd19(%rip), %rdi      # 0x13e24
leaq 0xa2cd(%rip), %rsi      # 0x113df
movl $0xc78, %edx            # imm = 0xC78
xorl %eax, %eax
callq 0xc2a1
cmpl $0x0, 0x199f3(%rip)     # 0x20b18
je 0x7134
callq 0x7cdf
testl %eax, %eax
je 0x732b
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
cmpl $0x0, 0x191b4(%rip)     # 0x20300
jle 0x7168
leaq 0xcd4a(%rip), %rdi      # 0x13e9f
leaq 0xa283(%rip), %rsi      # 0x113df
movl $0xc8a, %edx            # imm = 0xC8A
xorl %eax, %eax
callq 0xc2a1
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x7573
xorl %r12d, %r12d
leaq 0x17f48(%rsp), %r13
movb %r12b, -0x12cca(%r13)
andl $0x0, -0x104d0(%r13)
movb %r12b, -0xffcb(%r13)
movb %r12b, -0xefca(%r13)
orl $-0x1, 0x830(%r13)
orl $-0x1, 0x1238(%r13)
orl $-0x1, -0x136d0(%r13)
andl $0x0, 0x2e64(%r13)
movq %r13, %rdi
callq 0x30fc
leaq 0x18360(%rsp), %rbp
movq %rbp, %rdi
callq 0x30fc
cmpl %r12d, 0x19124(%rip)    # 0x20300
jle 0x71f8
pushq $0x1
popq %r12
movq %r13, %rdi
movl %r12d, %esi
callq 0x3112
movq %rbp, %rdi
movl %r12d, %esi
callq 0x3112
cmpl $0x0, 0x190f9(%rip)     # 0x202f8
je 0x7216
xorl %eax, %eax
cmpq $0x64, %rax
je 0x7216
andl $0x0, 0x1ac18(%rsp,%rax,4)
incq %rax
jmp 0x7203
cmpl $0x0, 0x190e3(%rip)     # 0x20300
jle 0x7239
leaq 0xccba(%rip), %rdi      # 0x13ee0
leaq 0xa1b2(%rip), %rsi      # 0x113df
movl $0xca0, %edx            # imm = 0xCA0
xorl %eax, %eax
callq 0xc2a1
leal 0x1(%rbx), %ecx
leaq 0x10(%rsp), %rdi
leaq 0x2080(%rsp), %rdx
movq %r14, %rsi
movq %r15, %r8
callq 0x61b4
movl %eax, %r15d
cmpl $0x0, 0x190a2(%rip)     # 0x20300
jle 0x7280
leaq 0xccc4(%rip), %rdi      # 0x13f2b
leaq 0xa171(%rip), %rsi      # 0x113df
movl $0xca3, %edx            # imm = 0xCA3
movl %r15d, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0xc2a1
cmpb $0x0, 0x8(%rsp)
je 0x72c7
cmpl $0x0, 0x19072(%rip)     # 0x20300
jle 0x72aa
leaq 0xcce5(%rip), %rdi      # 0x13f7c
leaq 0xa141(%rip), %rsi      # 0x113df
movl $0xca7, %edx            # imm = 0xCA7
xorl %eax, %eax
callq 0xc2a1
movq 0x17d1f(%rip), %rax     # 0x1efd0
movq (%rax), %rdi
callq 0x22c0
callq 0x7ccd
movq (%rsp), %rdi
callq 0x20f0
cmpl $0x0, 0x1902a(%rip)     # 0x202f8
je 0x72dd
leaq 0x2080(%rsp), %rdi
callq 0xad07
movq %r13, %rdi
callq 0x3117
movq %rbp, %rdi
callq 0x3117
cmpl $0x0, 0x1900c(%rip)     # 0x20300
jle 0x7316
leaq 0xccb8(%rip), %rdi      # 0x13fb5
leaq 0xa0db(%rip), %rsi      # 0x113df
movl $0xcb1, %edx            # imm = 0xCB1
movl %r15d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0xc2a1
movl %r15d, %eax
addq $0x1adc8, %rsp          # imm = 0x1ADC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c42e(%rip), %r12     # 0x23760
leaq 0xa0d3(%rip), %rdx      # 0x1140c
leaq 0x18fd8(%rip), %r8      # 0x20318
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2140
leaq 0xabd2(%rip), %rsi      # 0x11f2b
movq %r12, %rdi
callq 0x2350
testq %rax, %rax
je 0x737e
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x7ca3
movb $0x1, %al
movq %rax, 0x8(%rsp)
jmp 0x7145
andl $0x0, 0x19793(%rip)     # 0x20b18
callq 0x2060
movl (%rax), %edi
callq 0x23c0
leaq 0xcac1(%rip), %rdi      # 0x13e59
leaq 0xa040(%rip), %rsi      # 0x113df
leaq 0x18f72(%rip), %rcx     # 0x20318
movq $0x0, 0x8(%rsp)
movl $0xc81, %edx            # imm = 0xC81
movq %rax, %r8
xorl %eax, %eax
callq 0xc2a1
jmp 0x713d