// File: /workspace/github_c_makefile_star2_O0/inflex[P]ripMIME/libmime-decoders.c
// Function: MDECODE_decode_quoted_printable
int MDECODE_decode_quoted_printable( char *line, int qpmode, char esc_char )
{
    char c;                             /* The Character to output */
    int op, ip;                         /* OutputPointer and InputPointer */
    int slen = strlen(line); /* Length of our line */

    DMD LOGGER_log("%s:%d:MDECODE_decode_quoted_printable:DEBUG: input string = '%s' Input length = %d\n",FL, line, slen);
    /* Initialise our "pointers" to the start of the encoded string */
    ip=op=0;
    /* for every character in the string... */
    for (ip = 0; ip < slen; ip++)
    {
        c = line[ip];
        /* if we have the quoted-printable esc char, then lets get cracking */
        if (c == esc_char)
        {
            /* if we have another two chars... */
            if ((ip +1) < slen )
            {
                int original_ip = ip;

                /* Is our next char a \n\r ?

                    if it is, then we have to eliminate any further \r\n's etc
                    so as to turn the =\n\r into a 'soft return', which basically
                    means that we ignore it.  Soft-breaks are used so we can
                    fit our long lines into the requirement of a maximum of 76 characters
                    per line.

                    So we move the input-pointer along skipping each character without
                    incrementing the output pointer.
                 */
                /** Absorb any trailing whitespaces **/
                if (1)
                {
                    char *w = &(line[ip +1]);
                    while ((*w == '\t') || (*w == ' ')) {w++;ip++;}
                }

                /** Do we now have a line break ? **/
                if (( line[ip +1] == '\n') || (line[ip +1] == '\r' ))
                {
                    ip++;
                    if ((ip+1 < slen)&&(( line[ip +1] == '\n') || (line[ip +1] == '\r' )))
                    {
                        ip++;
                    }
                    continue;
                }

                else
                {
                    /*
                        if the characters following the '=' symbol are not
                        of the \n or \r pair, then we will [currently]
                        assume that the next two characters are in fact the
                        hexadecimal encodings of the character we do want

                     */
                    /** Revert to original position **/
                    ip = original_ip;

                    /* convert our encoded character from HEX -> decimal */

                    if ( ip < slen-1 ) // was 2, proving - if there are 3 chars in string, =AB, slen = 3, ip = 1
                    {
                        /**
                         * Jan 17th 2007 jjohnston
                         * Fixed a bug that decoded invalid QP sequences
                         */
                        if(hexconv[(int)line[ip+1]] == 20 || hexconv[(int)line[ip+2]] == 20) {

                            //LOGGER_log("%s:%d:MIME_decode_quoted_printable:NOTICE: Invalid characters for quoted-printable at '=%c%c'\n", FL, (int)&line[ip+1], (int)&line[ip+2]);


                        } else {

                        c = (char)hexconv[(int)line[ip+1]]*16 +hexconv[(int)line[ip+2]];

                        /* shuffle the pointer up two spaces */
                        ip+=2;
                    }
                    }
                    else {
                        LOGGER_log("%s:%d:MIME_decode_quoted_printable:WARNING: Ran out of characters when decoding end of '%s'\n", FL, &line[ip] );
                    }
                }
            } /* if there were two extra chars after the ='s */

            /* if we didn't have enough characters, then  we'll make the char the
             * string terminator (such as what happens when we get a =\n
             */
            else
            {
                /* 2002-12-16:18H31: changed from 'line[ip]' to 'line[op]' */
                line[op] = '\0';
                /* 2002-12-16:18H32: added break statement - if we're out of chars, then we quit the for loop */
                break;
            } /* else */

        } /* if c was a encoding char */


        else
            if (( c == '_' ) && ( qpmode == MDECODE_QPMODE_ISO ))
            {
                // RFC2047  (Section 4.2.(2)(3)) says that if we encounter a '_' character in our ISO encodings then
                //  we must convert that to a space ( as we are not allowed to have spaces in any
                c = ' ';
            }

        /* put in the new character, be it converted or not */
        line[op] = c;

        /* shuffle up the output line pointer */
        op++;


    } /* for loop */

    /* terminate the line */
    line[op]='\0';
    DMD LOGGER_log("%s:%d:MDECODE_decode_quoted_printable:DEBUG: Output = '%s' Output length = %d\n", FL, line, strlen(line));
    // 2003-01-26:PLD: Changed from (op -1) -=> op
    return op;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movb %al, -0xd(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2100
movl %eax, -0x1c(%rbp)
cmpl $0x1, 0x23c89(%rip)     # 0x35930
jl 0x11ccb
movq -0x8(%rbp), %rcx
movl -0x1c(%rbp), %r8d
leaq 0xce25(%rip), %rdi      # 0x1eadd
leaq 0xce72(%rip), %rsi      # 0x1eb31
movl $0xc8, %edx
movb $0x0, %al
callq 0x117c0
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x11f13
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0xe(%rbp)
movsbl -0xe(%rbp), %eax
movsbl -0xd(%rbp), %ecx
cmpl %ecx, %eax
jne 0x11ed9
movl -0x18(%rbp), %eax
addl $0x1, %eax
cmpl -0x1c(%rbp), %eax
jge 0x11ec9
movl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x9, %ecx
movb %al, -0x29(%rbp)
je 0x11d54
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
sete %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x11d5d
jmp 0x11d74
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x11d33
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x11da0
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x11dee
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
cmpl -0x1c(%rbp), %eax
jge 0x11de9
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x11de0
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x11de9
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x11f05
movl -0x20(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x11ea0
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0x15290(%rip), %rax     # 0x270b0
movzbl (%rax,%rcx), %eax
cmpl $0x14, %eax
je 0x11e4d
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0x1526c(%rip), %rax     # 0x270b0
movzbl (%rax,%rcx), %eax
cmpl $0x14, %eax
jne 0x11e4f
jmp 0x11e9e
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0x15246(%rip), %rax     # 0x270b0
movsbl (%rax,%rcx), %eax
shll $0x4, %eax
movq -0x8(%rbp), %rcx
movl -0x18(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rdx
leaq 0x15224(%rip), %rcx     # 0x270b0
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movb %al, -0xe(%rbp)
movl -0x18(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x18(%rbp)
jmp 0x11ec5
movq -0x8(%rbp), %rcx
movslq -0x18(%rbp), %rax
addq %rax, %rcx
leaq 0xcc92(%rip), %rdi      # 0x1eb44
leaq 0xcc78(%rip), %rsi      # 0x1eb31
movl $0x116, %edx            # imm = 0x116
movb $0x0, %al
callq 0x117c0
jmp 0x11ec7
jmp 0x11ed7
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x11f13
jmp 0x11eee
movsbl -0xe(%rbp), %eax
cmpl $0x5f, %eax
jne 0x11eec
cmpl $0x1, -0xc(%rbp)
jne 0x11eec
movb $0x20, -0xe(%rbp)
jmp 0x11eee
movb -0xe(%rbp), %dl
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x11ce0
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb $0x0, (%rax,%rcx)
cmpl $0x1, 0x23a0a(%rip)     # 0x35930
jl 0x11f5a
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2100
movq -0x38(%rbp), %rcx
movq %rax, %r8
leaq 0xcc5a(%rip), %rdi      # 0x1eba1
leaq 0xcbe3(%rip), %rsi      # 0x1eb31
movl $0x13c, %edx            # imm = 0x13C
movb $0x0, %al
callq 0x117c0
movl -0x14(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)