// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpl $0x1, 0x26853(%rip)     # 0x3277c
jl 0xbf59
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %rax
leaq 0x11100(%rip), %rdi     # 0x1d042
leaq 0x10525(%rip), %rsi     # 0x1c46e
movl $0x591, %edx            # imm = 0x591
movq %rax, (%rsp)
movb $0x0, %al
callq 0x117c0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x23b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xc27d
movl $0x0, -0x54(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2100
movq %rax, %rcx
movq -0x90(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0x2100
movq %rax, %rcx
movq -0x28(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movb $0x0, -0x69(%rbp)
movl $0x0, -0x70(%rbp)
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x23b0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0xbfe8
jmp 0xc27b
cmpl $0x1, 0x2678d(%rip)     # 0x3277c
jl 0xc00f
movq -0x60(%rbp), %rcx
leaq 0x110a9(%rip), %rdi     # 0x1d0a5
leaq 0x1046b(%rip), %rsi     # 0x1c46e
movl $0x5ad, %edx            # imm = 0x5AD
movb $0x0, %al
callq 0x117c0
movq -0x60(%rbp), %rdi
movl $0x3d, %esi
callq 0x2110
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xc02d
jmp 0xc27b
movq -0x48(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x2a, %eax
jne 0xc041
movl $0x1, -0x70(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
cmpl $0x1, 0x26728(%rip)     # 0x3277c
jl 0xc074
movq -0x48(%rbp), %rcx
leaq 0x1107e(%rip), %rdi     # 0x1d0df
leaq 0x10406(%rip), %rsi     # 0x1c46e
movl $0x5bb, %edx            # imm = 0x5BB
movb $0x0, %al
callq 0x117c0
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0xc0aa
cmpl $0x1, 0x266f5(%rip)     # 0x3277c
jl 0xc0a3
leaq 0x11087(%rip), %rdi     # 0x1d117
leaq 0x103d7(%rip), %rsi     # 0x1c46e
movl $0x5c0, %edx            # imm = 0x5C0
movb $0x0, %al
callq 0x117c0
movl $0x1, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0xc0ca
movq -0x48(%rbp), %rdi
addq $0x1, %rdi
leaq 0x110a4(%rip), %rsi     # 0x1d163
callq 0x22e0
movq %rax, -0x68(%rbp)
jmp 0xc0de
movq -0x48(%rbp), %rdi
leaq 0x11093(%rip), %rsi     # 0x1d168
callq 0x22e0
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0xc102
movq -0x68(%rbp), %rax
movb $0x0, (%rax)
movq -0x68(%rbp), %rax
movb (%rax), %al
movb %al, -0x69(%rbp)
movq -0x68(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
jmp 0xc12f
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xc124
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0xc10a
movq -0x80(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0xc17d
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x2100
movl %eax, -0x84(%rbp)
movq -0x48(%rbp), %rax
movslq -0x84(%rbp), %rcx
movsbl -0x1(%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0xc17b
movq -0x48(%rbp), %rax
movslq -0x84(%rbp), %rcx
movb $0x0, -0x1(%rax,%rcx)
jmp 0xc17d
cmpl $0x1, -0x70(%rbp)
jne 0xc18c
movq -0x48(%rbp), %rdi
callq 0xbdc0
cmpl $0x1, 0x265e9(%rip)     # 0x3277c
jl 0xc1b7
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %r8
leaq 0x10fca(%rip), %rdi     # 0x1d16e
leaq 0x102c3(%rip), %rsi     # 0x1c46e
movl $0x5e8, %edx            # imm = 0x5E8
movb $0x0, %al
callq 0x117c0
movq -0x50(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x48(%rbp), %rcx
leaq 0x12de0(%rip), %rdx     # 0x1efaa
movb $0x0, %al
callq 0x2130
movq -0x48(%rbp), %rdi
callq 0x2100
movl %eax, -0x74(%rbp)
movslq -0x74(%rbp), %rcx
movq -0x28(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x28(%rbp)
movl -0x74(%rbp), %ecx
movq -0x50(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
cmpl $0x1, 0x26578(%rip)     # 0x3277c
jl 0xc228
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %r8
leaq 0x10fa9(%rip), %rdi     # 0x1d1be
leaq 0x10252(%rip), %rsi     # 0x1c46e
movl $0x5ed, %edx            # imm = 0x5ED
movb $0x0, %al
callq 0x117c0
cmpq $0x0, -0x68(%rbp)
je 0xc246
movb -0x69(%rbp), %cl
movq -0x68(%rbp), %rax
movb %cl, (%rax)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xc24e
movq $0x0, -0x48(%rbp)
jmp 0xc250
xorl %eax, %eax
cmpq $0x0, -0x48(%rbp)
movb %al, -0x91(%rbp)
je 0xc26d
cmpq $0x0, -0x28(%rbp)
seta %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0xbfc0
jmp 0xc27d
cmpl $0x1, 0x264f8(%rip)     # 0x3277c
jl 0xc2b5
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
subq %rax, %rcx
movq -0x30(%rbp), %rax
movq (%rax), %r8
leaq 0x10f5f(%rip), %rdi     # 0x1d201
leaq 0x101c5(%rip), %rsi     # 0x1c46e
movl $0x5fa, %edx            # imm = 0x5FA
movb $0x0, %al
callq 0x117c0
movl -0x34(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)