// File: /workspace/github_c_makefile_star2_O1/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 0x859d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xcf2b(%rip), %r15      # 0x152ae
leaq 0xd0e7(%rip), %r12      # 0x15471
movq %rdi, (%rsp)
movq %rdi, %r13
xorl %r14d, %r14d
testq %r13, %r13
setne %al
je 0x83e8
movb (%r13), %cl
cmpb $0x28, %cl
jne 0x83ab
cmpl $0x1, %r14d
jne 0x83e8
movzbl %cl, %eax
cmpl $0xc, %eax
jg 0x83be
testl %eax, %eax
je 0x83d3
cmpl $0xa, %eax
je 0x83ce
jmp 0x83d6
cmpl $0xd, %eax
je 0x83ce
cmpl $0x22, %eax
jne 0x83d6
xorl $0x1, %r14d
jmp 0x83d6
xorl %r14d, %r14d
jmp 0x83d6
xorl %r13d, %r13d
movq %r13, %rcx
incq %r13
testq %rcx, %rcx
setne %al
cmoveq %rcx, %r13
jne 0x839c
testb %al, %al
je 0x84a9
testl %r14d, %r14d
jne 0x84a9
cmpl $0x0, 0x23f8c(%rip)     # 0x2c38c
jle 0x841b
leaq 0xd031(%rip), %rdi      # 0x1543a
movq %r15, %rsi
movl $0x35b, %edx            # imm = 0x35B
movq %r13, %rcx
xorl %eax, %eax
callq 0xc960
testq %r13, %r13
setne %cl
je 0x84b1
xorl %r14d, %r14d
movq %r13, %rbx
movzbl (%rbx), %ecx
movb $0x1, %al
cmpl $0xc, %ecx
jle 0x8471
cmpl $0xd, %ecx
je 0x847a
cmpl $0x22, %ecx
je 0x847f
cmpl $0x29, %ecx
jne 0x8489
cmpl $0x0, 0x23f3f(%rip)     # 0x2c38c
jle 0x8464
movq %r12, %rdi
movq %r15, %rsi
movl $0x373, %edx            # imm = 0x373
movq %rbx, %rcx
xorl %eax, %eax
callq 0xc960
xorl %eax, %eax
testl %r14d, %r14d
setne %al
movl %eax, %r14d
jmp 0x8489
testl %ecx, %ecx
je 0x8485
cmpl $0xa, %ecx
jne 0x8489
xorl %r14d, %r14d
jmp 0x8487
xorl $0x1, %r14d
jmp 0x8489
xorl %ebx, %ebx
xorl %eax, %eax
movq %rbx, %rdx
testq %rbx, %rbx
setne %cl
movl %ecx, %esi
andb %al, %sil
movzbl %sil, %ebx
addq %rdx, %rbx
testq %rdx, %rdx
je 0x84b7
testb %al, %al
jne 0x842d
jmp 0x84b7
movq %r13, %rbp
jmp 0x854e
xorl %r14d, %r14d
movq %r13, %rbx
testb %cl, %cl
je 0x852f
cmpb $0x29, (%rbx)
jne 0x853b
leaq 0x1(%rbx), %rbp
cmpl $0x0, 0x23ec1(%rip)     # 0x2c38c
jle 0x84e6
leaq 0xcfd7(%rip), %rdi      # 0x154ab
movq %r15, %rsi
movl $0x388, %edx            # imm = 0x388
movq %rbp, %rcx
xorl %eax, %eax
callq 0xc960
movb (%rbp), %al
movq %r13, %rbp
testb %al, %al
je 0x8506
addq $0x2, %rbx
movq %r13, %rbp
movb %al, (%rbp)
incq %rbp
movb (%rbx), %al
incq %rbx
testb %al, %al
jne 0x84f7
cmpl $0x0, 0x23e7f(%rip)     # 0x2c38c
jle 0x8525
leaq 0xcfd0(%rip), %rdi      # 0x154e6
movq %r15, %rsi
movl $0x391, %edx            # imm = 0x391
xorl %eax, %eax
callq 0xc960
movb $0x0, (%rbp)
xorl %eax, %eax
movb $0x1, %dl
jmp 0x8548
movl $0x2, %eax
xorl %edx, %edx
movq %r13, %rbp
jmp 0x8548
movq %r13, %rbp
incq %r13
movl $0x3, %eax
xorl %edx, %edx
movb $0x1, %cl
testb %dl, %dl
je 0x8556
testq %rbp, %rbp
setne %cl
xorl %eax, %eax
cmpl $0x2, %eax
je 0x8568
testb %cl, %cl
je 0x8568
testq %r13, %r13
jne 0x8394
cmpl $0x0, 0x23e1d(%rip)     # 0x2c38c
movq (%rsp), %rcx
jle 0x858f
leaq 0xcf9b(%rip), %rdi      # 0x15517
leaq 0xcd2b(%rip), %rsi      # 0x152ae
movl $0x39b, %edx            # imm = 0x39B
xorl %eax, %eax
callq 0xc960
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
xorl %eax, %eax
retq