// File: /workspace/github_c_makefile_star2_O3/inflex[P]ripMIME/MIME_headers.c
// Function: MIMEH_recompose_multivalue
int MIMEH_recompose_multivalue( struct MIMEH_header_info *hinfo, char *header_name_prefix, char *header_value, char *buffer, size_t buffer_size, char **data_end_point )
{
    int result = 0;
    char *start_position = header_value;


    DMIMEH LOGGER_log("%s:%d:MIMEH_recompose_multivalue:DEBUG: seeking for %s in %s and appending to '%s'. Buffer size=%d", FL, header_name_prefix, header_value,buffer, buffer_size );


    // Locate the first part of the multipart string
    start_position = strstr(header_value, header_name_prefix);
    if (start_position != NULL)
    {
        char *q;
        char *buffer_start;
		  int is_quoted = 0;

        // Setup our buffer insertion point for what ever new data we extract
        buffer_start = buffer +strlen(buffer);
        buffer_size -= strlen(buffer);

        q = start_position;

        // If the string we're looking for exists, then continue...
        do {
            char *p;
            char *end_point;
            char end_point_char='\0';
            int decode_data=0;
            int q_len;

            p = strstr(q, header_name_prefix);
            if (p == NULL) break;

            DMIMEH LOGGER_log("%s:%d:MIMEH_recompose_multivalue:DEBUG: prefix = '''%s'''", FL, p);

            q = strchr(p,'=');
            if (q == NULL) break;

            // Test to see if we have to look for a language encoding specification *sigh*
            if (*(q-1) == '*')
            {
                decode_data=1;
            }

            // Move the pointer past the '=' separator
            q++;

            DMIMEH LOGGER_log("%s:%d:MIMEH_recompose_multivalue:DEBUG: data = '''%s'''", FL, q);

				// Is our string quoted (ie, will likely contain whitespace)
				//
				if (*q == '"') {
					DMIMEH LOGGER_log("%s:%d:MIMEH_recompose_multivalue:DEBUG: multipart segment is quote-prefixed", FL);
					is_quoted = 1;
				}

            // Find where this multipart string ends
				//
				//
				if (is_quoted) end_point = strpbrk(q+1,";\r\n\"");
				else end_point = strpbrk(q, ";\t\n\r ");
            if (end_point != NULL)
            {
                *end_point = '\0';
                end_point_char = *end_point;
                *data_end_point = end_point; // Set this so we know where to start decoding the next time we call this fn
            } else {
                char *ep;

                // If strpbrk comes up with nothing, then we set the data_end_point to the end of the string
                ep = q;
                while (*ep != '\0') ep++;
                *data_end_point = ep;
            }

            // Trim off quotes.
            if (*q == '"')
            {
                int bl;

                //  LOGGER_log("%s:%d:DEBUG: Trimming '%s'", FL, q);
                q++;
                bl = strlen(q);
                if (*(q +bl -1) == '"') *(q +bl -1) = '\0';
                //LOGGER_log("%s:%d:DEBUG: Trim done, '%s'", FL, q);
            }

            if (decode_data == 1)
            {
                MIMEH_decode_multivalue_language_string(q);
            }

            DMIMEH LOGGER_log("%s:%d:MIMEH_recompose_multivalue:DEBUG: segment value = '%s', appending to '%s'", FL, q, buffer);
            snprintf(buffer_start,buffer_size,"%s",q);
            q_len = strlen(q);
            buffer_size -= q_len;
            buffer_start += q_len;
            DMIMEH LOGGER_log("%s:%d:MIMEH_recompose_multivalue:DEBUG: Buffer[remaining=%d]= '%s'", FL, buffer_size,buffer);

            if (end_point != NULL)
            {
                *end_point = end_point_char;
                q = end_point +1;
            }
            else q = NULL;

        } while ((q != NULL)&&(buffer_size > 0));

    }

    DMIMEH LOGGER_log("%s:%d:MIMEH_recompose_multivalue:DEBUG: End point set to: [%d] '%s'",FL, (*data_end_point -header_value), *data_end_point);
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x18(%rsp)
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r14
cmpl $0x0, 0x23394(%rip)     # 0x2c38c
jle 0x9021
movq %r15, (%rsp)
leaq 0xcead(%rip), %rdi      # 0x15eb2
leaq 0xc2d2(%rip), %rsi      # 0x152de
movl $0x591, %edx            # imm = 0x591
movq %r14, %rcx
movq %rbx, %r8
movq %r12, %r9
xorl %eax, %eax
callq 0xc84f
movq %rbx, 0x20(%rsp)
movq %rbx, %rdi
movq %r14, 0x30(%rsp)
movq %r14, %rsi
callq 0x23c0
testq %rax, %rax
je 0x9241
movq %rax, %rbx
movq %r12, %rdi
callq 0x2110
leaq (%r12,%rax), %rbp
subq %rax, %r15
movl $0x0, 0x14(%rsp)
movq %r12, 0x28(%rsp)
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0x23c0
testq %rax, %rax
je 0x9241
movq %rax, %rbx
cmpl $0x0, 0x2330e(%rip)     # 0x2c38c
jle 0x909d
leaq 0xce8e(%rip), %rdi      # 0x15f15
leaq 0xc250(%rip), %rsi      # 0x152de
movl $0x5ad, %edx            # imm = 0x5AD
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc84f
movq %rbx, %rdi
movl $0x3d, %esi
callq 0x2120
testq %rax, %rax
je 0x9241
movq %rax, %r13
movb -0x1(%rax), %r12b
leaq 0x1(%rax), %r14
cmpl $0x0, 0x232c7(%rip)     # 0x2c38c
jle 0x90e4
leaq 0xce81(%rip), %rdi      # 0x15f4f
leaq 0xc209(%rip), %rsi      # 0x152de
movl $0x5bb, %edx            # imm = 0x5BB
movq %r14, %rcx
xorl %eax, %eax
callq 0xc84f
cmpb $0x22, (%r14)
jne 0x9117
movl $0x1, 0x14(%rsp)
cmpl $0x0, 0x23293(%rip)     # 0x2c38c
jle 0x9122
leaq 0xce85(%rip), %rdi      # 0x15f87
leaq 0xc1d5(%rip), %rsi      # 0x152de
movl $0x5c0, %edx            # imm = 0x5C0
xorl %eax, %eax
callq 0xc84f
jmp 0x9122
cmpl $0x0, 0x14(%rsp)
je 0x9222
leaq 0x2(%r13), %rdi
leaq 0xcea6(%rip), %rsi      # 0x15fd3
callq 0x22f0
movq %rax, %rbx
movq %r13, %rax
testq %rbx, %rbx
je 0x9145
movb $0x0, (%rbx)
movq %rbx, %rcx
jmp 0x9152
leaq 0x1(%rax), %rcx
cmpb $0x0, 0x1(%rax)
movq %rcx, %rax
jne 0x9145
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
cmpb $0x22, (%r14)
jne 0x917f
movq %r13, %r14
addq $0x2, %r14
movq %r14, %rdi
callq 0x2110
cltq
cmpb $0x22, 0x1(%r13,%rax)
jne 0x917f
movb $0x0, -0x1(%r14,%rax)
cmpb $0x2a, %r12b
jne 0x918d
movq %r14, %rdi
callq 0x8f1c
cmpl $0x0, 0x231f8(%rip)     # 0x2c38c
movq 0x28(%rsp), %r12
jle 0x91bb
leaq 0xce3c(%rip), %rdi      # 0x15fde
leaq 0xc135(%rip), %rsi      # 0x152de
movl $0x5e8, %edx            # imm = 0x5E8
movq %r14, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0xc84f
movq %rbp, %rdi
movq %r15, %rsi
leaq 0xee98(%rip), %rdx      # 0x18060
movq %r14, %rcx
xorl %eax, %eax
callq 0x2140
movq %r14, %rdi
callq 0x2110
movslq %eax, %r14
subq %r14, %r15
cmpl $0x0, 0x231a5(%rip)     # 0x2c38c
jle 0x9209
leaq 0xce3e(%rip), %rdi      # 0x1602e
leaq 0xc0e7(%rip), %rsi      # 0x152de
movl $0x5ed, %edx            # imm = 0x5ED
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0xc84f
testq %rbx, %rbx
je 0x9241
addq %r14, %rbp
movb $0x0, (%rbx)
incq %rbx
testq %r15, %r15
jne 0x905e
jmp 0x9241
movq %r14, %rdi
leaq 0xcdac(%rip), %rsi      # 0x15fd8
callq 0x22f0
movq %rax, %rbx
movl $0x0, 0x14(%rsp)
jmp 0x9135
cmpl $0x0, 0x23144(%rip)     # 0x2c38c
jle 0x9274
movq 0x18(%rsp), %rax
movq (%rax), %r8
movq %r8, %rcx
subq 0x20(%rsp), %rcx
leaq 0xce10(%rip), %rdi      # 0x16071
leaq 0xc076(%rip), %rsi      # 0x152de
movl $0x5fa, %edx            # imm = 0x5FA
xorl %eax, %eax
callq 0xc84f
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq