// File: /workspace/github_c_makefile_star2_O1/inflex[P]ripMIME/mime.c
// Function: MIME_unpack_stage2
int MIME_unpack_stage2( FFGET_FILE *f, char *unpackdir, struct MIMEH_header_info *hinfo, int current_recursion_level, struct SS_object *ss )
{
    int result = 0;
    struct MIMEH_header_info *h;
    char *p;

    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Start, recursion %d\n",FL, current_recursion_level);
    if (current_recursion_level > glb.max_recursion_level)
    {
        /** Test for recursion limits **/
        if (MIME_VERBOSE) LOGGER_log("%s:%d:MIME_unpack_stage2:WARNING: Current recursion level of %d is greater than permitted %d"\
                ,FL, current_recursion_level, glb.max_recursion_level);
        return MIME_ERROR_RECURSION_LIMIT_REACHED; // 20040306-1301:PLD
    }
    h = hinfo;
    // Get our headers and determin what we have...
    //
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Parsing headers (initial)\n",FL);
    // Parse the headers, extracting what information we need
    /** 20041216-1102:PLD: Keep attempting to read headers until we get a sane set **/
    do {
        /** Read next set of headers, repeat until a sane set of headers are found **/
        result = MIMEH_parse_headers(f,h);
        DMIME LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Parsing of headers done, sanity = %d, result = %d",FL,h->sanity, result);
    } while ((h->sanity == 0)&&(result != -1));

    DMIME LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Repeat loop of header-reading done, sanity = %d, result = %d",FL,h->sanity, result);
    glb.header_defect_count += MIMEH_get_defect_count(h);
    // Test the result output
    switch (result) {
        case -1:
            return MIME_ERROR_FFGET_EMPTY;
            break;
    }
    // Copy the subject over to our global structure if the subject is not already set.
    //      this will give us the 'main' subject of the entire email and prevent
    //      and subsequent subjects from clobbering it.
    //if (glb.subject[0] == '\0') snprintf(glb.subject, _MIME_STRLEN_MAX, "%s", h->subject );
    if ((strlen(glb.subject) < 1)&&(h->subject != NULL)&&(strlen(h->subject) > 0))
    {
        snprintf(glb.subject, sizeof(glb.subject), "%s", h->subject );
    }
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Headers parsed, Result = %d, Boundary located = %d\n"\
            ,FL,result, hinfo->boundary_located);

    // Test to see if we encountered any DoubleCR situations while we
    //      were processing the headers.  If we did encounter a doubleCR
    //      then we need to decode that data and then reset the doubleCR
    //      flag.
    if (MIMEH_get_doubleCR() != 0)
    {
        MIME_doubleCR_decode( MIMEH_get_doubleCR_name(), unpackdir, h, current_recursion_level);
        MIMEH_set_doubleCR( 0 );
        FFGET_SDL_MODE = 0;
    }

    // If we located a boundary being specified (as apposed to existing)
    // then we push it to the BoundaryStack

    if (h->boundary_located)
    {
        char *lbc;
        char *fbc;

        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Boundary located, pushing to stack (%s)\n",FL,h->boundary);
        BS_push(h->boundary);

        // Get the first and last character positions of the boundary
        //      so we can test these for quotes.
        fbc = h->boundary;
        lbc = h->boundary +strlen(h->boundary) -1;

        // Circumvent attempts to trick the boundary
        //      Even though we may end up pushing 3 boundaries to the stack
        //      they will be popped off if they're not needed.
        if (*fbc == '"') { BS_push((fbc +1)); MIMEH_set_defect( hinfo, MIMEH_DEFECT_UNBALANCED_BOUNDARY_QUOTE); }
        if (*lbc == '"') { *lbc = '\0'; BS_push(h->boundary); *lbc = '"'; MIMEH_set_defect( hinfo, MIMEH_DEFECT_UNBALANCED_BOUNDARY_QUOTE); }
        h->boundary_located = 0;
    } else {
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Decoding in BOUNDARY-LESS mode\n",FL);
        if (h->content_type == _CTYPE_RFC822)
        {
            // Pass off to the RFC822 handler
            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Decoding with RFC822 decoder\n",FL);
            result = MIME_handle_rfc822(f,unpackdir,h,current_recursion_level,ss);
        } else if (MIMEH_is_contenttype(_CTYPE_MULTIPART, h->content_type)) {
            // Pass off to the multipart handler
            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Decoding with Multipart decoder\n",FL);
            result = MIME_handle_multipart(f,unpackdir,h,current_recursion_level,ss);
        } else {
            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Decoding boundaryless file (%s)...\n",FL,h->filename);
            result = MIME_handle_plain( f, unpackdir,h,current_recursion_level,ss);
        } // else-if content was RFC822 or multi-part
        return result;
    } // End of the boundary-LESS mode ( processing the mail which has no boundaries in the primary headers )

    if ((BS_top()!=NULL)&&(result == 0))
    {
        // Commence decoding WITH boundary awareness.
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Decoding with boundaries (filename = %s)\n",FL,h->filename);

        // Decode the data in the current MIME segment
        // based on the header information retrieved from
        // the start of this function.
        result = MIME_decode_encoding(f, unpackdir, h, ss);
        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Done decoding, result = %d",FL,result);
        if (result == 0)
        {
            if (BS_top()!=NULL)
            {
                // As this is a multipart email, then, each section will have its
                // own headers, so, we just simply call the MIMEH_parse call again
                // and get the attachment details
                while ((result == 0)||(result == MIME_STATUS_ZERO_FILE)||(result == MIME_ERROR_RECURSION_LIMIT_REACHED))
                {
                    h->content_type = -1;
                    h->filename[0] = '\0';
                    h->name[0]     = '\0';
                    h->content_transfer_encoding = -1;
                    h->content_disposition = -1;

                    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Decoding headers...\n",FL);
                    do {
                        result = MIMEH_parse_headers(f,h);
                    } while ((h->sanity == 0)&&(result != -1));

                    glb.header_defect_count += MIMEH_get_defect_count(h);
                    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Mime header parsing result = %d\n",FL, result);
                    // 20040305-1331:PLD
                    if (result == -1)
                    {
                        result = MIME_ERROR_FFGET_EMPTY;
                        return result;
                    }

                    if (h->boundary_located)
                    {
                        if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Pushing boundary %s\n",FL, h->boundary);
                        BS_push(h->boundary);
                        h->boundary_located = 0;
                    }

                    if (result == _MIMEH_FOUND_FROM)
                    {
                        return _MIMEH_FOUND_FROM;
                    }

                    if (result == 0)
                    {
                        // If we locate a new boundary specified, it means we have a
                        // embedded message, also if we have a ctype of RFC822
                        if ( (h->boundary_located) \
                                || (h->content_type == _CTYPE_RFC822)\
                                || (MIMEH_is_contenttype(_CTYPE_MULTIPART, h->content_type))\
                            )
                        {
                            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Multipart/RFC822 mail headers found\n",FL);
                            /* If there is no filename, then we have a "standard"
                             * embedded message, which can be just read off as a
                             * continuous stream (simply with new boundaries */
                            if (( h->content_type == _CTYPE_RFC822 ))
                            {
                                // If the content_type is set to message/RFC822
                                // then we simply read off the data to the next
                                // boundary into a seperate file, then 'reload'
                                // the file into ripMIME.  Certainly, this is not
                                // the most efficent way of dealing with nested emails
                                // however, it is a rather robust/reliable way.
                                if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Chose Content-type == RFC822 clause",FL);
                                if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Calling MIME_decode_encoding()",FL);
                                result = MIME_handle_rfc822(f,unpackdir,h,current_recursion_level,ss);
                                // First up - extract the RFC822 body out of the parent mailpack
                                // XX result = MIME_decode_encoding( f, unpackdir, h, ss );

                                // Now decode the RFC822 body.
                                /**
                                  XX
                                  if (result == 0)
                                  {
                                  snprintf(scratch,sizeof(scratch),"%s/%s",unpackdir, h->filename);
                                  snprintf(h->filename,sizeof(h->filename),"%s",scratch);
                                  if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Now calling MIME_unpack_single() on the file '%s' for our RFC822 decode operation.",FL, scratch);
                                //result = MIME_unpack_single( unpackdir, h->filename, current_recursion_level +1, ss);
                                result = MIME_unpack( unpackdir, h->filename, current_recursion_level +1  );
                                if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Unpack result = %d", FL, result);
                                result = 0;
                                } else return result; // 20040305-1312:PLD
                                */
                            } else if (( h->content_transfer_encoding != _CTRANS_ENCODING_B64)&&(h->filename[0] == '\0' )) {

                                // Decode nameless MIME segments which are not BASE64 encoded
                                //
                                // To be honest, i've forgotten what this section of test is supposed to pick out
                                // in terms of files - certainly it does pick out some, but I'm not sure what format
                                // they are.  Shame on me for not remembering, in future I must comment more.
                                if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: NON-BASE64 DECODE\n",FL);
                                h->boundary_located = 0;
                                result = MIME_unpack_stage2(f, unpackdir, h, current_recursion_level , ss);

                                // When we've exited from decoding the sub-mailpack, we need to restore the original
                                // boundary
                                p = BS_top();
                                if (p) snprintf(h->boundary,_MIME_STRLEN_MAX,"%s",p);

                                /** 20041207-0106:PLD:
                                 ** changed to test for _INLINE **/
                                //} else if (( h->content_type = _CTYPE_MULTIPART_APPLEDOUBLE )&&(h->content_disposition != _CDISPOSITION_INLINE)) {
                        } else if (( h->content_type = _CTYPE_MULTIPART_APPLEDOUBLE )&&(h->content_disposition != _CDISPOSITION_INLINE)) {

                            // AppleDouble needs to be handled explicity - as even though it's
                            //      and embedded format, it does not have the normal headers->[headers->data]
                            //      layout of other nested emails

                            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Handle Appledouble explicitly",FL);
                            result = MIME_unpack_stage2(f, unpackdir, h, current_recursion_level , ss);

                        } else {
                            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: RFC822 Message to be decoded...\n",FL);
                            result = MIME_decode_encoding( f, unpackdir, h, ss );
                            if (result != 0) return result; // 20040305-1313:PLD
                            else
                            {
                                if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Now running ripMIME over decoded RFC822 message...\n",FL);

                                // Because we're calling MIME_unpack_single again [ie, recursively calling it
                                // we need to now adjust the input-filename so that it correctly is prefixed
                                // with the directory we unpacked to.

                                snprintf(scratch,sizeof(scratch),"%s/%s",unpackdir, h->filename);
                                snprintf(h->filename,sizeof(h->filename),"%s",scratch);
                                //result = MIME_unpack_single( unpackdir, h->filename, current_recursion_level +1, ss);
                                result = MIME_unpack_single( unpackdir, h->filename, current_recursion_level,ss );
                            }

                        } // else-if transfer-encoding wasn't B64 and filename was blank
                        } else {
                            // If the attachment included in this MIME segment is NOT a
                            // multipart or RFC822 embedded email, we can then simply use
                            // the normal decoding function to interpret its data.
                            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Decoding a normal attachment \n",FL);
                            result = MIME_decode_encoding( f, unpackdir, h, ss );

                            if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Decoding a normal attachment '%s' done. \n",FL, h->filename);
                            // See if we have an attachment output which is actually another
                            //      email.
                            //
                            // Added 24 Aug 2003 by PLD
                            //      Ricardo Kleemann supplied offending mailpack to display
                            //      this behavior
                            if (result != 0) return result; // 20040305-1314:PLD
                            else
                            {
                                char *mime_fname;

                                mime_fname = PLD_dprintf("%s/%s", unpackdir, h->filename);
                                if(mime_fname != NULL)
                                {
                                    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Testing '%s' for email type",FL,mime_fname);
                                    if (MIME_is_file_RFC822(mime_fname))
                                    {
                                        //MIME_unpack_single( unpackdir, mime_fname, (hinfo->current_recursion_level+1), ss);
                                        MIME_unpack_single( unpackdir, mime_fname, current_recursion_level+1,ss);
                                    }
                                    free(mime_fname);
                                }
                            }
                        } // if there was a boundary, RFC822 content or it was multi-part
                    } else {
                        // if the result is not 0
                        break;
                    } // result == 0 test
                } // While (result)

                // ???? Why do we bother to pop the stack ???
                //  The way BS is designed it will auto-pop the inner nested boundaries
                //      when a higher-up one is located.
                //if (result == 0) BS_pop(); // 20040305-2219:PLD
            } // if MIME_BS_top()
        } // if result == 0
    } // if (result)
    if (MIME_DNORMAL) LOGGER_log("%s:%d:MIME_unpack_stage2:DEBUG: Exiting with result=%d recursion=%d\n",FL,result, current_recursion_level);
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r14
movl %ecx, %ebx
movq %rdx, %r15
movq %rsi, (%rsp)
movq %rdi, %r13
cmpl $0x0, 0x1ae79(%rip)     # 0x21300
jle 0x64a5
leaq 0xde35(%rip), %rdi      # 0x142c5
leaq 0xbf48(%rip), %rsi      # 0x123df
movl $0xa98, %edx            # imm = 0xA98
movl %ebx, %ecx
xorl %eax, %eax
callq 0xc960
movl 0x1b6a4(%rip), %r8d     # 0x21b50
cmpl %ebx, %r8d
jge 0x64de
movl $0xf0, %r14d
cmpl $0x0, 0x1ae2e(%rip)     # 0x212ec
jle 0x6ce8
leaq 0xde2f(%rip), %rdi      # 0x142fa
leaq 0xbf0d(%rip), %rsi      # 0x123df
movl $0xa9d, %edx            # imm = 0xA9D
movl %ebx, %ecx
jmp 0x6780
movq %r14, 0x8(%rsp)
cmpl $0x0, 0x1ae16(%rip)     # 0x21300
jle 0x6506
leaq 0xde64(%rip), %rdi      # 0x14357
leaq 0xbee5(%rip), %rsi      # 0x123df
movl $0xaa3, %edx            # imm = 0xAA3
xorl %eax, %eax
callq 0xc960
leaq 0xde85(%rip), %rbp      # 0x14392
leaq 0xbecb(%rip), %r12      # 0x123df
movq %r13, %rdi
movq %r15, %rsi
callq 0xb070
movl %eax, %r14d
cmpl $0x0, 0x1add7(%rip)     # 0x21300
jle 0x6547
movl 0x18d30(%r15), %ecx
movq %rbp, %rdi
movq %r12, %rsi
movl $0xaa9, %edx            # imm = 0xAA9
movl %r14d, %r8d
xorl %eax, %eax
callq 0xc960
movl 0x18d30(%r15), %ecx
testl %ecx, %ecx
jne 0x6558
cmpl $-0x1, %r14d
jne 0x6514
cmpl $0x0, 0x1ada1(%rip)     # 0x21300
jle 0x657e
leaq 0xde7c(%rip), %rdi      # 0x143e4
leaq 0xbe70(%rip), %rsi      # 0x123df
movl $0xaac, %edx            # imm = 0xAAC
movl %r14d, %r8d
xorl %eax, %eax
callq 0xc960
movq %r15, %rdi
callq 0xb28e
addl %eax, 0x1a954(%rip)     # 0x20ee0
cmpl $-0x1, %r14d
je 0x6ce2
cmpb $0x0, 0x1ddc3(%rip)     # 0x24360
jne 0x65c5
leaq 0x59fc(%r15), %rcx
cmpb $0x0, (%rcx)
je 0x65c5
leaq 0x1ddae(%rip), %rdi     # 0x24360
leaq 0x11ad4(%rip), %rdx     # 0x1808d
movl $0x3ff, %esi            # imm = 0x3FF
xorl %eax, %eax
callq 0x2140
cmpl $0x0, 0x1ad34(%rip)     # 0x21300
jle 0x65f2
movl 0x59f8(%r15), %r8d
leaq 0xde65(%rip), %rdi      # 0x14441
leaq 0xbdfc(%rip), %rsi      # 0x123df
movl $0xabd, %edx            # imm = 0xABD
movl %r14d, %ecx
xorl %eax, %eax
callq 0xc960
callq 0x7f35
testl %eax, %eax
je 0x6625
callq 0x7f5e
movq %rax, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movl %ebx, %ecx
callq 0x4ee9
xorl %edi, %edi
callq 0x7f3c
leaq 0x1e551(%rip), %rax     # 0x24b70
movl $0x0, (%rax)
cmpl $0x0, 0x59f8(%r15)
movl 0x1accd(%rip), %eax     # 0x21300
je 0x678c
testl %eax, %eax
jle 0x665e
leaq 0x31fe(%r15), %rcx
leaq 0xde4a(%rip), %rdi      # 0x14495
leaq 0xbd8d(%rip), %rsi      # 0x123df
movl $0xad2, %edx            # imm = 0xAD2
xorl %eax, %eax
callq 0xc960
leaq 0x31fe(%r15), %rbp
movq %rbp, %rdi
callq 0xd470
movq %rbp, %rdi
callq 0x2110
movq %rax, %r12
cmpb $0x22, 0x31fe(%r15)
jne 0x669b
leaq 0x31ff(%r15), %rdi
callq 0xd470
movq %r15, %rdi
movl $0x6, %esi
callq 0x802f
cmpb $0x22, -0x1(%rbp,%r12)
jne 0x66ca
movb $0x0, 0x31fd(%r15,%r12)
movq %rbp, %rdi
callq 0xd470
movb $0x22, 0x31fd(%r15,%r12)
movq %r15, %rdi
movl $0x6, %esi
callq 0x802f
movl $0x0, 0x59f8(%r15)
callq 0xd613
testq %rax, %rax
setne %al
testl %r14d, %r14d
sete %cl
testb %cl, %al
je 0x675a
cmpl $0x0, 0x1ac0f(%rip)     # 0x21300
jle 0x6714
leaq 0x5efd(%r15), %rcx
leaq 0xdee0(%rip), %rdi      # 0x145e1
leaq 0xbcd7(%rip), %rsi      # 0x123df
movl $0xaf5, %edx            # imm = 0xAF5
xorl %eax, %eax
callq 0xc960
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movq 0x8(%rsp), %rcx
callq 0x5888
movl %eax, %r14d
cmpl $0x0, 0x1abce(%rip)     # 0x21300
jle 0x6751
leaq 0xdef0(%rip), %rdi      # 0x1462b
leaq 0xbc9d(%rip), %rsi      # 0x123df
movl $0xafb, %edx            # imm = 0xAFB
movl %r14d, %ecx
xorl %eax, %eax
callq 0xc960
testl %r14d, %r14d
je 0x685b
cmpl $0x0, 0x1ab9f(%rip)     # 0x21300
jle 0x6ce8
leaq 0xe236(%rip), %rdi      # 0x149a4
leaq 0xbc6a(%rip), %rsi      # 0x123df
movl $0xbaa, %edx            # imm = 0xBAA
movl %r14d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0xc960
jmp 0x6ce8
testl %eax, %eax
jle 0x67aa
leaq 0xdd47(%rip), %rdi      # 0x144de
leaq 0xbc41(%rip), %rsi      # 0x123df
movl $0xae1, %edx            # imm = 0xAE1
xorl %eax, %eax
callq 0xc960
movl 0x27f8(%r15), %esi
cmpl $0x1f4, %esi            # imm = 0x1F4
movq 0x8(%rsp), %r14
jne 0x6803
cmpl $0x0, 0x1ab3b(%rip)     # 0x21300
jle 0x67e1
leaq 0xdd50(%rip), %rdi      # 0x1451e
leaq 0xbc0a(%rip), %rsi      # 0x123df
movl $0xae5, %edx            # imm = 0xAE5
xorl %eax, %eax
callq 0xc960
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movl %ebx, %ecx
movq %r14, %r8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6d5a
movl $0x64, %edi
callq 0x8078
movl 0x1aaed(%rip), %ecx     # 0x21300
testl %eax, %eax
je 0x6cfa
testl %ecx, %ecx
jle 0x6839
leaq 0xdd36(%rip), %rdi      # 0x1455c
leaq 0xbbb2(%rip), %rsi      # 0x123df
movl $0xae9, %edx            # imm = 0xAE9
xorl %eax, %eax
callq 0xc960
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movl %ebx, %ecx
movq %r14, %r8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x62d0
callq 0xd613
testq %rax, %rax
je 0x6d41
leaq 0x5efd(%r15), %rax
movq %rax, 0x10(%rsp)
leal 0x1(%rbx), %eax
movl %eax, 0x24(%rsp)
xorl %r12d, %r12d
xorl %r14d, %r14d
testl %r14d, %r14d
je 0x689a
cmpl $0xf0, %r14d
je 0x689a
cmpl $0x64, %r14d
jne 0x675a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x27f8(%r15)
movb %r12b, 0x5efd(%r15)
movb %r12b, 0x6efe(%r15)
movl %eax, 0x166f8(%r15)
movl %eax, 0x17100(%r15)
cmpl $0x0, 0x1aa37(%rip)     # 0x21300
jle 0x68e5
leaq 0xdd94(%rip), %rdi      # 0x14666
leaq 0xbb06(%rip), %rsi      # 0x123df
movl $0xb0b, %edx            # imm = 0xB0B
xorl %eax, %eax
callq 0xc960
movq %r13, %rdi
movq %r15, %rsi
callq 0xb070
movl %eax, %r14d
cmpl $0x0, 0x18d30(%r15)
jne 0x6903
cmpl $-0x1, %r14d
jne 0x68e5
movq %r15, %rdi
callq 0xb28e
addl %eax, 0x1a5cf(%rip)     # 0x20ee0
cmpl $0x0, 0x1a9e8(%rip)     # 0x21300
jle 0x6937
leaq 0xdd7a(%rip), %rdi      # 0x1469b
leaq 0xbab7(%rip), %rsi      # 0x123df
movl $0xb11, %edx            # imm = 0xB11
movl %r14d, %ecx
xorl %eax, %eax
callq 0xc960
cmpl $-0x1, %r14d
je 0x6ce2
cmpl $0x0, 0x59f8(%r15)
je 0x6984
cmpl $0x0, 0x1a9ae(%rip)     # 0x21300
jle 0x6971
leaq 0xdd81(%rip), %rdi      # 0x146dc
leaq 0xba7d(%rip), %rsi      # 0x123df
movl $0xb1b, %edx            # imm = 0xB1B
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc960
movq %rbp, %rdi
callq 0xd470
movl $0x0, 0x59f8(%r15)
testl %r14d, %r14d
jne 0x6d49
cmpl $0x0, 0x59f8(%r15)
jne 0x69b8
movl 0x27f8(%r15), %esi
cmpl $0x1f4, %esi            # imm = 0x1F4
je 0x69b8
movl $0x64, %edi
callq 0x8078
testl %eax, %eax
je 0x6bef
cmpl $0x0, 0x1a941(%rip)     # 0x21300
movq 0x8(%rsp), %r14
jle 0x69e0
leaq 0xdd44(%rip), %rdi      # 0x14711
leaq 0xba0b(%rip), %rsi      # 0x123df
movl $0xb2e, %edx            # imm = 0xB2E
xorl %eax, %eax
callq 0xc960
cmpl $0x1f4, 0x27f8(%r15) # imm = 0x1F4
jne 0x6a4f
cmpl $0x0, 0x1a90c(%rip)     # 0x21300
jle 0x6a10
leaq 0xdd59(%rip), %rdi      # 0x14756
leaq 0xb9db(%rip), %rsi      # 0x123df
movl $0xb3a, %edx            # imm = 0xB3A
xorl %eax, %eax
callq 0xc960
cmpl $0x0, 0x1a8e9(%rip)     # 0x21300
jle 0x6a33
leaq 0xdd7a(%rip), %rdi      # 0x1479a
leaq 0xb9b8(%rip), %rsi      # 0x123df
movl $0xb3b, %edx            # imm = 0xB3B
xorl %eax, %eax
callq 0xc960
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movl %ebx, %ecx
movq %r14, %r8
callq 0x6d5a
movl %eax, %r14d
jmp 0x6882
cmpl $0x64, 0x166f8(%r15)
je 0x6a67
movq 0x10(%rsp), %rax
cmpb $0x0, (%rax)
je 0x6b7e
movl $0x66, 0x27f8(%r15)
cmpl $0x64, 0x17100(%r15)
movl 0x1a880(%rip), %eax     # 0x21300
jne 0x6b44
testl %eax, %eax
jle 0x6aa4
leaq 0xddb9(%rip), %rdi      # 0x1484a
leaq 0xb947(%rip), %rsi      # 0x123df
movl $0xb6b, %edx            # imm = 0xB6B
xorl %eax, %eax
callq 0xc960
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x5888
testl %eax, %eax
jne 0x6d55
cmpl $0x0, 0x1a83b(%rip)     # 0x21300
jle 0x6ae1
leaq 0xddbd(%rip), %rdi      # 0x1488b
leaq 0xb90a(%rip), %rsi      # 0x123df
movl $0xb70, %edx            # imm = 0xB70
xorl %eax, %eax
callq 0xc960
movl $0x400, %esi            # imm = 0x400
leaq 0x1dc73(%rip), %rdi     # 0x24760
leaq 0xb918(%rip), %rdx      # 0x1240c
movq (%rsp), %r14
movq %r14, %rcx
movq 0x10(%rsp), %r12
movq %r12, %r8
xorl %eax, %eax
callq 0x2140
movl $0x1001, %esi           # imm = 0x1001
movq %r12, %rdi
leaq 0x11574(%rip), %rdx     # 0x1808d
leaq 0x1dc40(%rip), %rcx     # 0x24760
xorl %eax, %eax
callq 0x2140
movq %r14, %rdi
movq %r12, %rsi
movl %ebx, %edx
movq 0x8(%rsp), %rcx
callq 0x5fde
movl %eax, %r14d
xorl %r12d, %r12d
jmp 0x6882
testl %eax, %eax
jle 0x6b62
leaq 0xdcbd(%rip), %rdi      # 0x1480c
leaq 0xb889(%rip), %rsi      # 0x123df
movl $0xb67, %edx            # imm = 0xB67
xorl %eax, %eax
callq 0xc960
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movl %ebx, %ecx
movq %r14, %r8
callq 0x6463
movl %eax, %r14d
jmp 0x6882
cmpl $0x0, 0x1a77b(%rip)     # 0x21300
jle 0x6ba1
leaq 0xdc4b(%rip), %rdi      # 0x147d9
leaq 0xb84a(%rip), %rsi      # 0x123df
movl $0xb55, %edx            # imm = 0xB55
xorl %eax, %eax
callq 0xc960
movl $0x0, 0x59f8(%r15)
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movl %ebx, %ecx
movq %r14, %r8
callq 0x6463
movl %eax, %r14d
callq 0xd613
testq %rax, %rax
je 0x6882
movl $0x3ff, %esi            # imm = 0x3FF
movq %rbp, %rdi
leaq 0x114ad(%rip), %rdx     # 0x1808d
movq %rax, %rcx
xorl %eax, %eax
callq 0x2140
jmp 0x6882
cmpl $0x0, 0x1a70a(%rip)     # 0x21300
movq 0x8(%rsp), %r14
jle 0x6c17
leaq 0xdcdb(%rip), %rdi      # 0x148df
leaq 0xb7d4(%rip), %rsi      # 0x123df
movl $0xb81, %edx            # imm = 0xB81
xorl %eax, %eax
callq 0xc960
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x5888
movl %eax, %r14d
cmpl $0x0, 0x1a6cd(%rip)     # 0x21300
jle 0x6c54
leaq 0xdce2(%rip), %rdi      # 0x1491e
leaq 0xb79c(%rip), %rsi      # 0x123df
movl $0xb84, %edx            # imm = 0xB84
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0xc960
testl %r14d, %r14d
jne 0x6ce8
xorl %r14d, %r14d
leaq 0xb7a5(%rip), %rdi      # 0x1240c
movq (%rsp), %rsi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xc66c
testq %rax, %rax
je 0x6882
cmpl $0x0, 0x1a679(%rip)     # 0x21300
movq %rax, 0x18(%rsp)
jle 0x6cb0
leaq 0xdcd3(%rip), %rdi      # 0x14968
leaq 0xb743(%rip), %rsi      # 0x123df
movl $0xb93, %edx            # imm = 0xB93
movq %rax, %rcx
xorl %eax, %eax
callq 0xc960
movq 0x18(%rsp), %rax
movq %rax, %rdi
callq 0x39e8
testl %eax, %eax
je 0x6cd3
movq (%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x24(%rsp), %edx
movq 0x8(%rsp), %rcx
callq 0x5fde
movq 0x18(%rsp), %rdi
callq 0x2030
jmp 0x6882
movl $0xf1, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ecx, %ecx
jle 0x6d1f
leaq 0x5efd(%r15), %rcx
leaq 0xd891(%rip), %rdi      # 0x1459d
leaq 0xb6cc(%rip), %rsi      # 0x123df
movl $0xaec, %edx            # imm = 0xAEC
xorl %eax, %eax
callq 0xc960
movq %r13, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
movl %ebx, %ecx
movq %r14, %r8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6faa
xorl %r14d, %r14d
jmp 0x675a
cmpl $0x64, %r14d
jne 0x675a
jmp 0x6ce8
movl %eax, %r14d
jmp 0x6ce8