// File: /workspace/github_c_makefile_star2_O3/inflex[P]ripMIME/MIME_headers.c
// Function: MIMEH_strip_comments
int MIMEH_strip_comments( char *input )
{
    char *p,*p_org;
    int in_quote=0;

    if (input == NULL) return 0;

    p = p_org = input;

    do {
        char *q = NULL;

        // Locate (if any) the first occurance of the (
        while ((p_org != NULL)&&((*p_org != '(')||(in_quote==1)))
        {
            switch (*p_org) {
                case '"':
                    in_quote ^= 1;
                    break;
                case '\n':
                case '\r':
                    in_quote = 0;
                    break;
                case '\0':
                    p_org = NULL;
                    break;
            }

            if (p_org) p_org++;
        }

        p = p_org;

        if ((p != NULL)&&(in_quote == 0))
        {
            int stop_searching = 0;

            DMIMEH LOGGER_log("%s:%d:MIMEH_strip_comments:DEBUG: Located open ( at %s",FL,p);
            // If we did locate an opening parenthesis, look for the closing one
            //      NOTE - we cannot have a breaking \n or \r inbetween
            //      q = strpbrk(p, ")\n\r");
            q = p;
            while ( (q != NULL) && (stop_searching == 0) )
            {
                switch (*q) {
                    case '\0':
                        stop_searching = 1;
                        q = NULL;
                        break;

                    case '\n':
                    case '\r':
                        stop_searching = 1;
                        in_quote = 0;
                        break;

                    case '"':
                        in_quote ^= 1;
                        break;

                    case ')':
                        DMIMEH LOGGER_log("%s:%d:MIMEH_strip_comments:DEBUG: Located closing ) at %s",FL,q);
                        if (in_quote == 0) stop_searching = 1;
                        break;
                }
                if ((q != NULL)&&(stop_searching == 0)) q++;
            }

            // If we've got both opening and closing, then we need to remove
            //      the contents of the comment, including the parenthesis
            if (q != NULL)
            {
                if (*q != ')')
                {
                    // if we found a \n or \r between the two (), then jump out
                    // and move p to the next position.
                    p_org++;
                    continue;
                } else {
                    // Move q to the first char after the closing parenthesis
                    q++;

                    DMIMEH LOGGER_log("%s:%d:MIMEH_strip_comments:DEBUG: located closing ) at %s ",FL, q);
                    // While there's more chars in string, copy them to where
                    //      the opening parenthesis is
                    while (*q != '\0')
                    {
                        *p = *q;
                        p++;
                        q++;
                    } // While q != '\0'
                    DMIMEH LOGGER_log("%s:%d:MIMEH_strip_comments:DEBUG: char copy done",FL);

                    // Terminate the string
                    *p = '\0';
                } // if q !=/= ')'

            } else break; // if q == NULL
        } // if p == NULL
    } while ((p != NULL)&&(p_org != NULL)); // do-while more comments to remove

    DMIMEH LOGGER_log("%s:%d:MIMEH_strip_comments:DEBUG: Final string = '%s'",FL,input);
    return 0;
}

// Assembly:
testq %rdi, %rdi
je 0x8481
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xd006(%rip), %r15      # 0x152de
leaq 0xd1c2(%rip), %r12      # 0x154a1
movq %rdi, %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x844d
movq %rcx, %r13
cmpl $0x1, %eax
sete %cl
movzbl (%r13), %edx
cmpl $0x28, %edx
setne %sil
orb %cl, %sil
cmpb $0x1, %sil
jne 0x8332
movl $0x0, %ecx
testl %edx, %edx
je 0x82e4
cmpl $0xa, %edx
je 0x8328
cmpl $0xd, %edx
je 0x8328
cmpl $0x22, %edx
jne 0x832a
xorl $0x1, %eax
jmp 0x832a
xorl %eax, %eax
incq %r13
movq %r13, %rcx
jmp 0x82e4
movq %r13, %rcx
testl %eax, %eax
jne 0x8444
cmpl $0x0, 0x24048(%rip)     # 0x2c38c
jle 0x835f
leaq 0xd11d(%rip), %rdi      # 0x1546a
movq %r15, %rsi
movl $0x35b, %edx            # imm = 0x35B
movq %r13, %rcx
xorl %eax, %eax
callq 0xc84f
xorl %r14d, %r14d
movq %r13, %rbp
movzbl (%rbp), %eax
cmpl $0x21, %eax
jg 0x8389
testl %eax, %eax
je 0x844d
cmpl $0xa, %eax
je 0x843e
cmpl $0xd, %eax
jne 0x83c2
jmp 0x843e
cmpl $0x29, %eax
je 0x8399
cmpl $0x22, %eax
jne 0x83c2
xorl $0x1, %r14d
jmp 0x83c2
cmpl $0x0, 0x23fec(%rip)     # 0x2c38c
jle 0x83b7
movq %r12, %rdi
movq %r15, %rsi
movl $0x373, %edx            # imm = 0x373
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc84f
testl %r14d, %r14d
movl $0x1, %r14d
je 0x83c7
incq %rbp
jmp 0x8365
cmpb $0x29, (%rbp)
jne 0x843e
leaq 0x1(%rbp), %r14
cmpl $0x0, 0x23fb4(%rip)     # 0x2c38c
jle 0x83f3
leaq 0xd0fa(%rip), %rdi      # 0x154db
movq %r15, %rsi
movl $0x388, %edx            # imm = 0x388
movq %r14, %rcx
xorl %eax, %eax
callq 0xc84f
movb (%r14), %al
movq %r13, %r14
testb %al, %al
je 0x8414
xorl %r14d, %r14d
movb %al, (%r13,%r14)
movb 0x2(%rbp,%r14), %al
incq %r14
testb %al, %al
jne 0x8400
addq %r13, %r14
cmpl $0x0, 0x23f71(%rip)     # 0x2c38c
jle 0x8433
leaq 0xd0f2(%rip), %rdi      # 0x15516
movq %r15, %rsi
movl $0x391, %edx            # imm = 0x391
xorl %eax, %eax
callq 0xc84f
movb $0x0, (%r14)
xorl %eax, %eax
movq %r13, %rcx
jmp 0x8444
leaq 0x1(%r13), %rcx
xorl %eax, %eax
testq %r13, %r13
jne 0x82e4
cmpl $0x0, 0x23f38(%rip)     # 0x2c38c
jle 0x8473
leaq 0xd0ea(%rip), %rdi      # 0x15547
leaq 0xce7a(%rip), %rsi      # 0x152de
movl $0x39b, %edx            # imm = 0x39B
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc84f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq