// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x1, 0x277b2(%rip)     # 0x3277c
jl 0xafea
movq -0x10(%rbp), %rcx
leaq 0x11744(%rip), %rdi     # 0x1c71b
leaq 0x11490(%rip), %rsi     # 0x1c46e
movl $0x3e3, %edx            # imm = 0x3E3
movb $0x0, %al
callq 0x117c0
cmpl $0x0, 0x27797(%rip)     # 0x32788
jne 0xaffe
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xb242
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xb219
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movl $0x3b, %esi
callq 0x2110
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xb036
jmp 0xb219
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
cmpl $0x1, 0x27733(%rip)     # 0x3277c
jl 0xb074
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
subq %rax, %rcx
movq -0x20(%rbp), %r8
leaq 0x11705(%rip), %rdi     # 0x1c766
leaq 0x11406(%rip), %rsi     # 0x1c46e
movl $0x3f1, %edx            # imm = 0x3F1
movb $0x0, %al
callq 0x117c0
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0xb08c
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0xb098
movl $0x0, -0x24(%rbp)
jmp 0xb128
jmp 0xb09a
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x31(%rbp)
jne 0xb0cc
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0xd, %ecx
movb %al, -0x31(%rbp)
jne 0xb0cc
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0xb0d5
jmp 0xb126
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x38(%rbp)
addl $-0x9, %eax
subl $0x2, %eax
jb 0xb0fd
jmp 0xb0e9
movl -0x38(%rbp), %eax
subl $0xd, %eax
je 0xb0fd
jmp 0xb0f3
movl -0x38(%rbp), %eax
subl $0x20, %eax
jne 0xb106
jmp 0xb0fd
movl $0x0, -0x24(%rbp)
jmp 0xb10d
movl $0x1, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
jne 0xb115
jmp 0xb126
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xb09a
jmp 0xb128
cmpl $0x1, -0x24(%rbp)
jne 0xb162
cmpl $0x1, 0x27647(%rip)     # 0x3277c
jl 0xb151
leaq 0x1166e(%rip), %rdi     # 0x1c7ac
leaq 0x11329(%rip), %rsi     # 0x1c46e
movl $0x40c, %edx            # imm = 0x40C
movb $0x0, %al
callq 0x117c0
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xb006
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xb214
movq -0x30(%rbp), %rdi
callq 0xaf10
cmpl $0x0, %eax
jne 0xb206
cmpl $0x1, 0x275f1(%rip)     # 0x3277c
jl 0xb1a7
leaq 0x11661(%rip), %rdi     # 0x1c7f5
leaq 0x112d3(%rip), %rsi     # 0x1c46e
movl $0x414, %edx            # imm = 0x414
movb $0x0, %al
callq 0x117c0
movq -0x30(%rbp), %rax
movb $0x20, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0xb1d2
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0xb1d9
movq -0x30(%rbp), %rax
movb $0x20, (%rax)
cmpl $0x1, 0x2759c(%rip)     # 0x3277c
jl 0xb1fc
leaq 0x11645(%rip), %rdi     # 0x1c82e
leaq 0x1127e(%rip), %rsi     # 0x1c46e
movl $0x418, %edx            # imm = 0x418
movb $0x0, %al
callq 0x117c0
movq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0xb212
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xb214
jmp 0xb006
cmpl $0x1, 0x2755c(%rip)     # 0x3277c
jl 0xb23c
leaq 0x11637(%rip), %rdi     # 0x1c860
leaq 0x1123e(%rip), %rsi     # 0x1c46e
movl $0x420, %edx            # imm = 0x420
movb $0x0, %al
callq 0x117c0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)