// File: /workspace/github_c_makefile_star2_O2/System-Glitch[P]ESGILinter-C/src/stringutils.c
// Function: str_remove_comments
char *str_remove_comments(char *str) {
	char *result            = NULL;
	char *tmp               = NULL;
	int comment_start       = -1;
	int comment_end         = -1;
	unsigned char in_quotes = 0;
	unsigned char type      = 0;
	size_t length = strlen(str);

	for(unsigned i = 0 ; i < length ; i++) {
		if(!in_quotes && str[i] == '\"') {
			in_quotes = 1;
		} else if(in_quotes) {
			if(str[i] == '\"' && str[i-1] != '\\')
				in_quotes = 0;
		} else {
			if(comment_start == -1) {
				if(str[i] == '/' && str[i+1] == '*') {
					type = COMMENT_TYPE_MULTILINE;
					comment_start = i;
					i++;
				} else if(str[i] == '/' && str[i+1] == '/') {
					type = COMMENT_TYPE_ENDLINE;
					comment_start = i;
					i++;
				}
			} else {
				if(type == COMMENT_TYPE_MULTILINE && str[i] == '*' && str[i+1] == '/') {
					comment_end = i + 2;
					break;
				} else if(type == COMMENT_TYPE_ENDLINE && is_line_break(str[i])) {
					comment_end = i;
					break;
				}
			}
		}
	}

	if(type == COMMENT_TYPE_ENDLINE && comment_end == -1)
		comment_end = length;

	if(comment_start != -1 && comment_end != -1) {
		result = malloc((length + 1) * sizeof(char));
		strncpy(result, str, comment_start);
		strncpy(result + comment_start, str + comment_end, length - comment_end);
		result[comment_start + (length - comment_end)] = '\0';
		tmp = str_remove_comments(result);
		free(result);
		result = tmp;
	} else {
		result = strduplicate(str);
	}

	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x20b0
movq %rax, %r14
xorl %esi, %esi
pushq $-0x1
popq %rax
movl %eax, %ebp
xorl %ecx, %ecx
xorl %edx, %edx
movl %edx, %edi
cmpq %rdi, %r14
jbe 0x7898
movzbl (%rbx,%rdi), %edi
testb %sil, %sil
je 0x7826
movb $0x1, %sil
cmpl $0x22, %edi
jne 0x7885
leal -0x1(%rdx), %esi
cmpb $0x5c, (%rbx,%rsi)
sete %sil
jmp 0x7885
movb $0x1, %sil
cmpl $0x22, %edi
je 0x7885
cmpl $-0x1, %ebp
je 0x7855
cmpb $0x2, %cl
je 0x7877
movzbl %cl, %esi
cmpl $0x1, %esi
jne 0x7883
movb $0x1, %cl
cmpl $0x2a, %edi
jne 0x7883
leal 0x1(%rdx), %esi
cmpb $0x2f, (%rbx,%rsi)
jne 0x7883
jmp 0x7930
cmpl $0x2f, %edi
jne 0x7871
leal 0x1(%rdx), %edi
movzbl (%rbx,%rdi), %esi
cmpl $0x2a, %esi
je 0x788c
cmpl $0x2f, %esi
jne 0x7871
movb $0x2, %cl
xorl %esi, %esi
jmp 0x7890
xorl %esi, %esi
movl %eax, %ebp
jmp 0x7885
movb $0x2, %cl
cmpl $0xa, %edi
je 0x7896
cmpl $0xd, %edi
je 0x7896
xorl %esi, %esi
incl %edx
jmp 0x77fd
xorl %esi, %esi
movb $0x1, %cl
movl %edx, %ebp
movl %edi, %edx
jmp 0x7885
movl %edx, %eax
cmpb $0x2, %cl
sete %cl
cmpl $-0x1, %eax
movl %r14d, %r13d
cmovnel %eax, %r13d
testb %cl, %cl
cmovel %eax, %r13d
cmpl $-0x1, %ebp
je 0x791a
cmpl $-0x1, %r13d
je 0x791a
leaq 0x1(%r14), %rdi
callq 0x2130
movq %rax, %r15
movslq %ebp, %r12
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2060
addq %r15, %r12
movslq %r13d, %rax
addq %rax, %rbx
subq %rax, %r14
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2060
movb $0x0, (%r14,%r12)
movq %r15, %rdi
callq 0x77dc
movq %rax, %rbx
movq %r15, %rdi
callq 0x2030
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x794d
addl $0x2, %edx
xorl %ecx, %ecx
movl %edx, %eax
jmp 0x789e