// File: /workspace/github_c_makefile_star2_O1/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, 0x19fa5(%rip)     # 0x21300
jle 0x7384
movl 0x1a7ec(%rip), %r9d     # 0x21b50
leaq 0xd9a9(%rip), %rdi      # 0x14d14
leaq 0xb06d(%rip), %rsi      # 0x123df
movl $0xc6d, %edx            # imm = 0xC6D
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0xc960
movl 0x1a7c5(%rip), %r8d     # 0x21b50
cmpl %ebx, %r8d
jge 0x73b7
leaq 0xd9bc(%rip), %rdi      # 0x14d53
leaq 0xb041(%rip), %rsi      # 0x123df
movl $0xc70, %edx            # imm = 0xC70
movl %ebx, %ecx
xorl %eax, %eax
callq 0xc960
movl $0xf0, %r15d
jmp 0x7618
movl %ebx, 0x1ac14(%rsp)
movl $0x0, 0x1a758(%rip)     # 0x21b20
cmpl $0x0, 0x19f31(%rip)     # 0x21300
jle 0x73ed
leaq 0xd9db(%rip), %rdi      # 0x14db3
leaq 0xb000(%rip), %rsi      # 0x123df
movl $0xc77, %edx            # imm = 0xC77
movl %ebx, %ecx
xorl %eax, %eax
callq 0xc960
cmpl $0x0, 0x19f0c(%rip)     # 0x21300
jle 0x7416
movl 0x1a71c(%rip), %ecx     # 0x21b18
leaq 0xd9f1(%rip), %rdi      # 0x14df4
leaq 0xafd5(%rip), %rsi      # 0x123df
movl $0xc78, %edx            # imm = 0xC78
xorl %eax, %eax
callq 0xc960
cmpl $0x0, 0x1a6fb(%rip)     # 0x21b18
je 0x742c
callq 0x8006
testl %eax, %eax
je 0x762d
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
movq %r15, %r13
cmpl $0x0, 0x19eb9(%rip)     # 0x21300
jle 0x7463
leaq 0xda1f(%rip), %rdi      # 0x14e6f
leaq 0xaf88(%rip), %rsi      # 0x123df
movl $0xc8a, %edx            # imm = 0xC8A
xorl %eax, %eax
callq 0xc960
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x787b
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 0x3248
leaq 0x18360(%rsp), %rbp
movq %rbp, %rdi
callq 0x3248
cmpl %r15d, 0x19e21(%rip)    # 0x21300
jle 0x74fb
movq %r12, %rdi
movl $0x1, %esi
callq 0x3261
movq %rbp, %rdi
movl $0x1, %esi
callq 0x3261
cmpl $0x0, 0x19df6(%rip)     # 0x212f8
je 0x7518
leaq 0x1ac18(%rsp), %rdi
movl $0x190, %edx            # imm = 0x190
xorl %esi, %esi
callq 0x2170
cmpl $0x0, 0x19de1(%rip)     # 0x21300
jle 0x753b
leaq 0xd988(%rip), %rdi      # 0x14eb0
leaq 0xaeb0(%rip), %rsi      # 0x123df
movl $0xca0, %edx            # imm = 0xCA0
xorl %eax, %eax
callq 0xc960
leal 0x1(%rbx), %ecx
leaq 0x10(%rsp), %rdi
leaq 0x2080(%rsp), %rdx
movq %r14, %rsi
movq %r13, %r8
callq 0x6463
movl %eax, %r15d
cmpl $0x0, 0x19da0(%rip)     # 0x21300
jle 0x7582
leaq 0xd992(%rip), %rdi      # 0x14efb
leaq 0xae6f(%rip), %rsi      # 0x123df
movl $0xca3, %edx            # imm = 0xCA3
movl %r15d, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0xc960
cmpb $0x0, 0x8(%rsp)
je 0x75c9
cmpl $0x0, 0x19d70(%rip)     # 0x21300
jle 0x75ac
leaq 0xd9b3(%rip), %rdi      # 0x14f4c
leaq 0xae3f(%rip), %rsi      # 0x123df
movl $0xca7, %edx            # imm = 0xCA7
xorl %eax, %eax
callq 0xc960
movq 0x18a1d(%rip), %rax     # 0x1ffd0
movq (%rax), %rdi
callq 0x22d0
callq 0x7fee
movq (%rsp), %rdi
callq 0x20f0
cmpl $0x0, 0x19d28(%rip)     # 0x212f8
je 0x75df
leaq 0x2080(%rsp), %rdi
callq 0xb17a
movq %r12, %rdi
callq 0x3266
movq %rbp, %rdi
callq 0x3266
cmpl $0x0, 0x19d0a(%rip)     # 0x21300
jle 0x7618
leaq 0xd986(%rip), %rdi      # 0x14f85
leaq 0xadd9(%rip), %rsi      # 0x123df
movl $0xcb1, %edx            # imm = 0xCB1
movl %r15d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0xc960
movl %r15d, %eax
addq $0x1adc8, %rsp          # imm = 0x1ADC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d12c(%rip), %r13     # 0x24760
leaq 0xadd1(%rip), %rdx      # 0x1240c
leaq 0x19cd6(%rip), %r8      # 0x21318
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2140
leaq 0xb8a0(%rip), %rsi      # 0x12efb
movq %r13, %rdi
callq 0x2350
testq %rax, %rax
je 0x7680
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x7fc4
movb $0x1, %al
movq %rax, 0x8(%rsp)
jmp 0x743d
movl $0x0, 0x1a48e(%rip)     # 0x21b18
callq 0x2060
movl (%rax), %edi
callq 0x23c0
leaq 0xd78c(%rip), %rdi      # 0x14e29
leaq 0xad3b(%rip), %rsi      # 0x123df
leaq 0x19c6d(%rip), %rcx     # 0x21318
movq $0x0, 0x8(%rsp)
movl $0xc81, %edx            # imm = 0xC81
movq %rax, %r8
xorl %eax, %eax
callq 0xc960
jmp 0x7435