// File: /workspace/github_c_makefile_star2_O3/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, %r12
movq %rdi, %r14
cmpl $0x0, 0x1a063(%rip)     # 0x21300
jle 0x72c6
movl 0x1a8aa(%rip), %r9d     # 0x21b50
leaq 0xda97(%rip), %rdi      # 0x14d44
leaq 0xb12b(%rip), %rsi      # 0x123df
movl $0xc6d, %edx            # imm = 0xC6D
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0xc84f
movl 0x1a883(%rip), %r8d     # 0x21b50
cmpl %ebx, %r8d
jge 0x72f9
leaq 0xdaaa(%rip), %rdi      # 0x14d83
leaq 0xb0ff(%rip), %rsi      # 0x123df
movl $0xc70, %edx            # imm = 0xC70
movl %ebx, %ecx
xorl %eax, %eax
callq 0xc84f
movl $0xf0, %r15d
jmp 0x755a
movl %ebx, 0x1ac14(%rsp)
movl $0x0, 0x1a816(%rip)     # 0x21b20
cmpl $0x0, 0x19fef(%rip)     # 0x21300
jle 0x7358
leaq 0xdac9(%rip), %rdi      # 0x14de3
leaq 0xb0be(%rip), %rsi      # 0x123df
movl $0xc77, %edx            # imm = 0xC77
movl %ebx, %ecx
xorl %eax, %eax
callq 0xc84f
cmpl $0x0, 0x19fca(%rip)     # 0x21300
jle 0x7358
movl 0x1a7da(%rip), %ecx     # 0x21b18
leaq 0xdadf(%rip), %rdi      # 0x14e24
leaq 0xb093(%rip), %rsi      # 0x123df
movl $0xc78, %edx            # imm = 0xC78
xorl %eax, %eax
callq 0xc84f
cmpl $0x0, 0x1a7b9(%rip)     # 0x21b18
je 0x736e
callq 0x7f4e
testl %eax, %eax
je 0x756f
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
movq %r15, %r13
cmpl $0x0, 0x19f77(%rip)     # 0x21300
jle 0x73a5
leaq 0xdb0d(%rip), %rdi      # 0x14e9f
leaq 0xb046(%rip), %rsi      # 0x123df
movl $0xc8a, %edx            # imm = 0xC8A
xorl %eax, %eax
callq 0xc84f
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x77bb
xorl %r15d, %r15d
leaq 0x17f48(%rsp), %r12
movb %r15b, -0x12cca(%r12)
movl %r15d, -0x104d0(%r12)
movb %r15b, -0xffcb(%r12)
movb %r15b, -0xefca(%r12)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x830(%r12)
movl %eax, 0x1238(%r12)
movl %eax, -0x136d0(%r12)
movl %r15d, 0x2e64(%r12)
movq %r12, %rdi
callq 0x320c
leaq 0x18360(%rsp), %rbp
movq %rbp, %rdi
callq 0x320c
cmpl %r15d, 0x19edf(%rip)    # 0x21300
jle 0x743d
movq %r12, %rdi
movl $0x1, %esi
callq 0x3225
movq %rbp, %rdi
movl $0x1, %esi
callq 0x3225
cmpl $0x0, 0x19eb4(%rip)     # 0x212f8
je 0x745a
leaq 0x1ac18(%rsp), %rdi
movl $0x190, %edx            # imm = 0x190
xorl %esi, %esi
callq 0x2170
cmpl $0x0, 0x19e9f(%rip)     # 0x21300
jle 0x747d
leaq 0xda76(%rip), %rdi      # 0x14ee0
leaq 0xaf6e(%rip), %rsi      # 0x123df
movl $0xca0, %edx            # imm = 0xCA0
xorl %eax, %eax
callq 0xc84f
leal 0x1(%rbx), %ecx
leaq 0x10(%rsp), %rdi
leaq 0x2080(%rsp), %rdx
movq %r14, %rsi
movq %r13, %r8
callq 0x63aa
movl %eax, %r15d
cmpl $0x0, 0x19e5e(%rip)     # 0x21300
jle 0x74c4
leaq 0xda80(%rip), %rdi      # 0x14f2b
leaq 0xaf2d(%rip), %rsi      # 0x123df
movl $0xca3, %edx            # imm = 0xCA3
movl %r15d, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0xc84f
cmpb $0x0, 0x8(%rsp)
je 0x750b
cmpl $0x0, 0x19e2e(%rip)     # 0x21300
jle 0x74ee
leaq 0xdaa1(%rip), %rdi      # 0x14f7c
leaq 0xaefd(%rip), %rsi      # 0x123df
movl $0xca7, %edx            # imm = 0xCA7
xorl %eax, %eax
callq 0xc84f
movq 0x18adb(%rip), %rax     # 0x1ffd0
movq (%rax), %rdi
callq 0x22c0
callq 0x7f36
movq (%rsp), %rdi
callq 0x20f0
cmpl $0x0, 0x19de6(%rip)     # 0x212f8
je 0x7521
leaq 0x2080(%rsp), %rdi
callq 0xb0e9
movq %r12, %rdi
callq 0x322a
movq %rbp, %rdi
callq 0x322a
cmpl $0x0, 0x19dc8(%rip)     # 0x21300
jle 0x755a
leaq 0xda74(%rip), %rdi      # 0x14fb5
leaq 0xae97(%rip), %rsi      # 0x123df
movl $0xcb1, %edx            # imm = 0xCB1
movl %r15d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0xc84f
movl %r15d, %eax
addq $0x1adc8, %rsp          # imm = 0x1ADC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d1ea(%rip), %r13     # 0x24760
leaq 0xae8f(%rip), %rdx      # 0x1240c
leaq 0x19d94(%rip), %r8      # 0x21318
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2140
leaq 0xb98e(%rip), %rsi      # 0x12f2b
movq %r13, %rdi
callq 0x2340
testq %rax, %rax
je 0x75c2
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x7f0c
movb $0x1, %al
movq %rax, 0x8(%rsp)
jmp 0x737f
movl $0x0, 0x1a54c(%rip)     # 0x21b18
callq 0x2060
movl (%rax), %edi
callq 0x23b0
leaq 0xd87a(%rip), %rdi      # 0x14e59
leaq 0xadf9(%rip), %rsi      # 0x123df
leaq 0x19d2b(%rip), %rcx     # 0x21318
movq $0x0, 0x8(%rsp)
movl $0xc81, %edx            # imm = 0xC81
movq %rax, %r8
xorl %eax, %eax
callq 0xc84f
jmp 0x7377