// File: /workspace/github_c_makefile_star2_O3/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, 0x1cb5e(%rip)     # 0x21b50
jl 0x51a0
movl %edx, %r14d
movq %rsi, %rbx
movq %rdi, %r12
cmpl $0x0, 0x1c2f8(%rip)     # 0x21300
jle 0x502d
leaq 0xffe5(%rip), %rdi      # 0x14ff6
leaq 0xd3c7(%rip), %rsi      # 0x123df
movl $0xcc4, %edx            # imm = 0xCC4
movq %rbx, %rcx
movq %r12, %r8
movl %r14d, %r9d
xorl %eax, %eax
callq 0xc84f
movq %r12, %rdi
callq 0x7eb7
cmpl $0x0, 0x1c2c4(%rip)     # 0x21300
jle 0x504b
movq %rsp, %rdi
movl $0x1, %esi
callq 0x3225
movq %rsp, %rdi
callq 0x320c
cmpl $0x0, 0x1cad2(%rip)     # 0x21b2c
movl 0x1c2a0(%rip), %eax     # 0x21300
jle 0x5093
testl %eax, %eax
jle 0x5080
leaq 0xffc6(%rip), %rdi      # 0x15033
leaq 0xd36b(%rip), %rsi      # 0x123df
movl $0xcca, %edx            # imm = 0xCCA
xorl %eax, %eax
callq 0xc84f
movq %rsp, %rcx
movq %r12, %rdi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x6fb5
jmp 0x50cc
testl %eax, %eax
jle 0x50ba
leaq 0xffc7(%rip), %rdi      # 0x15065
leaq 0xd33a(%rip), %rsi      # 0x123df
movl $0xccf, %edx            # imm = 0xCCF
movq %rbx, %rcx
movq %r12, %r8
movl %r14d, %r9d
xorl %eax, %eax
callq 0xc84f
leal 0x1(%r14), %edx
movq %rsp, %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5f1a
movl %eax, %r15d
cmpl $0x0, 0x1ca4e(%rip)     # 0x21b24
je 0x50e3
movq %rsp, %rsi
movq %r12, %rdi
callq 0x60f5
cmpl $0x0, 0x1c216(%rip)     # 0x21300
jle 0x5114
leaq 0xffa1(%rip), %rdi      # 0x15094
leaq 0xd2e5(%rip), %rsi      # 0x123df
movl $0xcda, %edx            # imm = 0xCDA
movq %rbx, %rcx
movl %r14d, %r8d
xorl %eax, %eax
callq 0xc84f
movq %rsp, %rdi
callq 0x32b7
movq %rsp, %rdi
callq 0x322a
cmpl $0x0, 0x1c1dd(%rip)     # 0x21300
jle 0x5132
movq %rsp, %rdi
movl $0x1, %esi
callq 0x3225
leal -0xf0(%r15), %eax
cmpl $0x2, %eax
jb 0x514a
cmpl $0x64, %r15d
je 0x514a
cmpl $0x1, %r15d
jne 0x514d
xorl %r15d, %r15d
testl %r14d, %r14d
jne 0x5157
callq 0xd212
cmpl $0x0, 0x1c1a2(%rip)     # 0x21300
jle 0x51a0
leaq 0xff69(%rip), %rdi      # 0x150d0
leaq 0xd271(%rip), %rsi      # 0x123df
movl $0xcf6, %edx            # imm = 0xCF6
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc84f
cmpl $0x0, 0x1c17c(%rip)     # 0x21300
jle 0x51a0
leaq 0xff6f(%rip), %rdi      # 0x150fc
leaq 0xd24b(%rip), %rsi      # 0x123df
movl $0xcf7, %edx            # imm = 0xCF7
xorl %eax, %eax
callq 0xc84f
movl %r15d, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r14
popq %r15
retq