// File: /workspace/github_c_makefile_star2_O1/inflex[P]ripMIME/mime.c
// Function: MIME_unpack
int MIME_unpack( char *unpackdir, char *mpname, int current_recursion_level )
{
    int result = 0;
    struct SS_object ss; // Stores the filenames that are created in the unpack operation

    if (current_recursion_level > glb.max_recursion_level) return MIME_ERROR_RECURSION_LIMIT_REACHED;
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack: Unpacking %s to %s, recursion level is %d",FL,mpname,unpackdir,current_recursion_level);
    MIMEH_set_outputdir(unpackdir);
    if (MIME_DNORMAL) SS_set_debug(&ss,1);
    SS_init(&ss);
    if (glb.mailbox_format > 0)
    {
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack: Unpacking using mailbox format",FL);
        result = MIME_unpack_mailbox( unpackdir, mpname, (current_recursion_level), &ss );
    }
    else
    {
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack: Unpacking standard mailpack",FL,mpname,unpackdir,current_recursion_level);
        result = MIME_unpack_single( unpackdir, mpname, (current_recursion_level +1), &ss );
    }

    if (glb.no_nameless)
    {
        MIME_postdecode_cleanup( unpackdir, &ss );
    }

    if (MIME_DNORMAL)
    {
        LOGGER_log("%s:%d:MIME_unpack: Files unpacked from '%s' (recursion=%d);",FL,mpname,current_recursion_level);
        SS_dump(&ss);
    }

    SS_done(&ss);
    if (MIME_DNORMAL) SS_set_debug(&ss,1);
    // If the result is a non-critical one (ie, just running out of data from the
    //      file we attempted to decode - then don't propergate it, on the other
    switch (result) {
        case 1:
            result = 0;
            break;
        case MIME_STATUS_ZERO_FILE:
            result = 0;
            break;
        case MIME_ERROR_FFGET_EMPTY:
        case MIME_ERROR_RECURSION_LIMIT_REACHED:
            result = 0;
            break;
        default:
            break;
    }

    if (current_recursion_level == 0)
    {
        //LOGGER_log("%s:%d:MIME_unpack:DEBUG: Clearing boundary stack",FL);
        BS_clear();
    }
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack: Unpacking of %s is done.",FL,mpname);
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack: -----------------------------------",FL);
    return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movl $0xf0, %r15d
cmpl %edx, 0x1cae9(%rip)     # 0x21b50
jl 0x5215
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %r12
cmpl $0x0, 0x1c283(%rip)     # 0x21300
jle 0x50a2
leaq 0xff40(%rip), %rdi      # 0x14fc6
leaq 0xd352(%rip), %rsi      # 0x123df
movl $0xcc4, %edx            # imm = 0xCC4
movq %rbx, %rcx
movq %r12, %r8
movl %r14d, %r9d
xorl %eax, %eax
callq 0xc960
movq %r12, %rdi
callq 0x7f6f
cmpl $0x0, 0x1c24f(%rip)     # 0x21300
jle 0x50c0
movq %rsp, %rdi
movl $0x1, %esi
callq 0x3261
movq %rsp, %rdi
callq 0x3248
cmpl $0x0, 0x1ca5d(%rip)     # 0x21b2c
movl 0x1c22b(%rip), %eax     # 0x21300
jle 0x5108
testl %eax, %eax
jle 0x50f5
leaq 0xff21(%rip), %rdi      # 0x15003
leaq 0xd2f6(%rip), %rsi      # 0x123df
movl $0xcca, %edx            # imm = 0xCCA
xorl %eax, %eax
callq 0xc960
movq %rsp, %rcx
movq %r12, %rdi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x706d
jmp 0x5141
testl %eax, %eax
jle 0x512f
leaq 0xff22(%rip), %rdi      # 0x15035
leaq 0xd2c5(%rip), %rsi      # 0x123df
movl $0xccf, %edx            # imm = 0xCCF
movq %rbx, %rcx
movq %r12, %r8
movl %r14d, %r9d
xorl %eax, %eax
callq 0xc960
leal 0x1(%r14), %edx
movq %rsp, %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5fde
movl %eax, %r15d
cmpl $0x0, 0x1c9d9(%rip)     # 0x21b24
je 0x5158
movq %rsp, %rsi
movq %r12, %rdi
callq 0x61b5
cmpl $0x0, 0x1c1a1(%rip)     # 0x21300
jle 0x5189
leaq 0xfefc(%rip), %rdi      # 0x15064
leaq 0xd270(%rip), %rsi      # 0x123df
movl $0xcda, %edx            # imm = 0xCDA
movq %rbx, %rcx
movl %r14d, %r8d
xorl %eax, %eax
callq 0xc960
movq %rsp, %rdi
callq 0x32eb
movq %rsp, %rdi
callq 0x3266
cmpl $0x0, 0x1c168(%rip)     # 0x21300
jle 0x51a7
movq %rsp, %rdi
movl $0x1, %esi
callq 0x3261
leal -0xf0(%r15), %eax
cmpl $0x2, %eax
jb 0x51bf
cmpl $0x64, %r15d
je 0x51bf
cmpl $0x1, %r15d
jne 0x51c2
xorl %r15d, %r15d
testl %r14d, %r14d
jne 0x51cc
callq 0xd3a1
cmpl $0x0, 0x1c12d(%rip)     # 0x21300
jle 0x51f2
leaq 0xfec4(%rip), %rdi      # 0x150a0
leaq 0xd1fc(%rip), %rsi      # 0x123df
movl $0xcf6, %edx            # imm = 0xCF6
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc960
cmpl $0x0, 0x1c107(%rip)     # 0x21300
jle 0x5215
leaq 0xfeca(%rip), %rdi      # 0x150cc
leaq 0xd1d6(%rip), %rsi      # 0x123df
movl $0xcf7, %edx            # imm = 0xCF7
xorl %eax, %eax
callq 0xc960
movl %r15d, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r14
popq %r15
retq