// File: /workspace/github_c_makefile_star2_O2/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, 0x1bcde(%rip)     # 0x20b50
jl 0x501c
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %r12
cmpl $0x0, 0x1b478(%rip)     # 0x20300
jle 0x4ead
leaq 0xf165(%rip), %rdi      # 0x13ff6
leaq 0xc547(%rip), %rsi      # 0x113df
movl $0xcc4, %edx            # imm = 0xCC4
movq %rbx, %rcx
movq %r12, %r8
movl %r14d, %r9d
xorl %eax, %eax
callq 0xc2a1
movq %r12, %rdi
callq 0x7c4e
cmpl $0x0, 0x1b444(%rip)     # 0x20300
jle 0x4ec9
movq %rsp, %rdi
pushq $0x1
popq %rsi
callq 0x3112
movq %rsp, %rdi
callq 0x30fc
cmpl $0x0, 0x1bc54(%rip)     # 0x20b2c
movl 0x1b422(%rip), %eax     # 0x20300
jle 0x4f11
testl %eax, %eax
jle 0x4efe
leaq 0xf148(%rip), %rdi      # 0x14033
leaq 0xc4ed(%rip), %rsi      # 0x113df
movl $0xcca, %edx            # imm = 0xCCA
xorl %eax, %eax
callq 0xc2a1
movq %rsp, %rcx
movq %r12, %rdi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x6da3
jmp 0x4f4a
testl %eax, %eax
jle 0x4f38
leaq 0xf149(%rip), %rdi      # 0x14065
leaq 0xc4bc(%rip), %rsi      # 0x113df
movl $0xccf, %edx            # imm = 0xCCF
movq %rbx, %rcx
movq %r12, %r8
movl %r14d, %r9d
xorl %eax, %eax
callq 0xc2a1
leal 0x1(%r14), %edx
movq %rsp, %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5d29
movl %eax, %r15d
cmpl $0x0, 0x1bbd0(%rip)     # 0x20b24
je 0x4f61
movq %rsp, %rsi
movq %r12, %rdi
callq 0x5f02
cmpl $0x0, 0x1b398(%rip)     # 0x20300
jle 0x4f92
leaq 0xf123(%rip), %rdi      # 0x14094
leaq 0xc467(%rip), %rsi      # 0x113df
movl $0xcda, %edx            # imm = 0xCDA
movq %rbx, %rcx
movl %r14d, %r8d
xorl %eax, %eax
callq 0xc2a1
movq %rsp, %rdi
callq 0x3192
movq %rsp, %rdi
callq 0x3117
cmpl $0x0, 0x1b35f(%rip)     # 0x20300
jle 0x4fae
movq %rsp, %rdi
pushq $0x1
popq %rsi
callq 0x3112
leal -0xf0(%r15), %eax
cmpl $0x2, %eax
jb 0x4fc6
cmpl $0x64, %r15d
je 0x4fc6
cmpl $0x1, %r15d
jne 0x4fc9
xorl %r15d, %r15d
testl %r14d, %r14d
jne 0x4fd3
callq 0xcc00
cmpl $0x0, 0x1b326(%rip)     # 0x20300
jle 0x501c
leaq 0xf0ed(%rip), %rdi      # 0x140d0
leaq 0xc3f5(%rip), %rsi      # 0x113df
movl $0xcf6, %edx            # imm = 0xCF6
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc2a1
cmpl $0x0, 0x1b300(%rip)     # 0x20300
jle 0x501c
leaq 0xf0f3(%rip), %rdi      # 0x140fc
leaq 0xc3cf(%rip), %rsi      # 0x113df
movl $0xcf7, %edx            # imm = 0xCF7
xorl %eax, %eax
callq 0xc2a1
movl %r15d, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r14
popq %r15
retq