// File: /workspace/github_c_makefile_star2_O1/inflex[P]ripMIME/MIME_headers.c
// Function: MIMEH_fix_header_mistakes
int MIMEH_fix_header_mistakes( char *data )
{
    int result = 0;
    char *p;

    DMIMEH LOGGER_log("%s:%d:MIMEH_fix_header_mistakes:DEBUG: Checking and fixing headers in '%s'",FL,data);

    if (glb.header_fix == 0) return result;

    p = data;
    while (p) {
        int nonblank_detected = 0;
        char *q;

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

        q = p+1;

        DMIMEH LOGGER_log("%s:%d:MIMEH_fix_header_mistakes:DEBUG: Located ';' at offset %d '%20s",FL, p -data, p);

        if ((*q == '\n')||(*q == '\r')) {
            nonblank_detected = 0;
        } else {
            /** If the ; isn't immediately followed by a \n or \r, then search till
             ** the end of the line to see if all the chars are blank **/

            while ((*q != '\0')||(*q != '\r')||(*q != '\n')) {
                switch (*q) {
                    case '\t':
                    case '\n':
                    case '\r':
                    case ' ':
                        nonblank_detected = 0;
                        break;
                    default:
                        nonblank_detected = 1;
                } /*switch*/

                if (nonblank_detected == 1) break;

                q++;
            } /** while looking for the end of the line **/
        } /** ELSE - if *q wasn't a line break char **/

        if (nonblank_detected == 1) {
            DMIMEH LOGGER_log("%s:%d:MIMEH_fix_header_mistakes:DEBUG: Line was normal/safe, continue...",FL);
            p++;
            continue;
        } /** if nonblank_detected == 1 **/
        /** if we had nothing but blanks till the end of the
         ** line, then we need to pull up the next line **/
        if (*q != '\0') {
            if(!MIMEH_check_ct(q)){
                DMIMEH LOGGER_log("%s:%d:MIMEH_fix_header_mistakes:DEBUG: Line needs fixing",FL);
                *q = ' ';
                q++;
                if ((*q == '\n')||(*q == '\r')) *q = ' ';
                DMIMEH LOGGER_log("%s:%d:MIMEH_fix_header_mistakes:DEBUG: Line fixed",FL);
                p = q;
            }else{
                p++;
            }
        } /** If q wasn't the end of data **/
    } /** while looking for more ';' chars **/

    DMIMEH LOGGER_log("%s:%d:MIMEH_fix_header_mistakes:DEBUG: Done",FL);
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x23d0d(%rip)     # 0x2c38c
jle 0x869e
leaq 0xced3(%rip), %rdi      # 0x1555b
leaq 0xcc1f(%rip), %rsi      # 0x152ae
movl $0x3e3, %edx            # imm = 0x3E3
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc960
cmpl $0x0, 0x23cf3(%rip)     # 0x2c398
je 0x8800
leaq 0xcbfc(%rip), %r15      # 0x152ae
movabsq $0x100002600, %r12      # imm = 0x100002600
movq %rbx, %rdi
testq %rdi, %rdi
je 0x87dd
movl $0x3b, %esi
callq 0x2120
movq %rax, %r13
testq %rax, %rax
je 0x8731
cmpl $0x0, 0x23cab(%rip)     # 0x2c38c
jle 0x8702
movq %r13, %rcx
subq %rbx, %rcx
leaq 0xceb6(%rip), %rdi      # 0x155a6
movq %r15, %rsi
movl $0x3f1, %edx            # imm = 0x3F1
movq %r13, %r8
xorl %eax, %eax
callq 0xc960
leaq 0x1(%r13), %r14
movzbl (%r14), %ecx
xorl %eax, %eax
movq %r14, %rbp
cmpl $0xa, %ecx
je 0x873a
cmpl $0xd, %ecx
je 0x873a
movq %r14, %rbp
movzbl (%rbp), %eax
cmpq $0x20, %rax
ja 0x8738
btq %rax, %r12
jae 0x8738
incq %rbp
jmp 0x871c
xorl %edi, %edi
jmp 0x87d4
movb $0x1, %al
testb %al, %al
je 0x8762
cmpl $0x0, 0x23c47(%rip)     # 0x2c38c
jle 0x875d
leaq 0xce9e(%rip), %rdi      # 0x155ec
movq %r15, %rsi
movl $0x40c, %edx            # imm = 0x40C
xorl %eax, %eax
callq 0xc960
movq %r14, %rdi
jmp 0x87d4
cmpb $0x0, (%rbp)
movq %r13, %rdi
je 0x87d4
movq %rbp, %rdi
callq 0x8616
movq %r14, %rdi
testl %eax, %eax
jne 0x87d4
cmpl $0x0, 0x23c0b(%rip)     # 0x2c38c
jle 0x8799
leaq 0xceab(%rip), %rdi      # 0x15635
movq %r15, %rsi
movl $0x414, %edx            # imm = 0x414
xorl %eax, %eax
callq 0xc960
movb $0x20, (%rbp)
movzbl 0x1(%rbp), %eax
incq %rbp
cmpl $0xd, %eax
je 0x87ae
cmpl $0xa, %eax
jne 0x87b2
movb $0x20, (%rbp)
cmpl $0x0, 0x23bd3(%rip)     # 0x2c38c
jle 0x87d1
leaq 0xceac(%rip), %rdi      # 0x1566e
movq %r15, %rsi
movl $0x418, %edx            # imm = 0x418
xorl %eax, %eax
callq 0xc960
movq %rbp, %rdi
testq %r13, %r13
jne 0x86bf
cmpl $0x0, 0x23ba8(%rip)     # 0x2c38c
jle 0x8800
leaq 0xceb3(%rip), %rdi      # 0x156a0
leaq 0xcaba(%rip), %rsi      # 0x152ae
movl $0x420, %edx            # imm = 0x420
xorl %eax, %eax
callq 0xc960
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq