// File: /workspace/github_c_makefile_star2_O1/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 %eax, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
testq %r14, %r14
je 0x7ca7
xorl %edx, %edx
movzbl (%rbx,%rax), %esi
testb %dl, %dl
je 0x7c29
movb $0x1, %dl
cmpl $0x22, %esi
jne 0x7c9c
leal -0x1(%rax), %edx
cmpb $0x5c, (%rbx,%rdx)
sete %dl
jmp 0x7c9c
movb $0x1, %dl
cmpl $0x22, %esi
je 0x7c9c
cmpl $-0x1, %ebp
je 0x7c65
cmpb $0x2, %cl
je 0x7c59
movzbl %cl, %edx
cmpl $0x1, %edx
jne 0x7c9a
cmpl $0x2a, %esi
jne 0x7c54
leal 0x1(%rax), %edx
cmpb $0x2f, (%rbx,%rdx)
je 0x7d3f
cmpb $0x2, %cl
jne 0x7c9a
cmpl $0xa, %esi
je 0x7cac
cmpl $0xd, %esi
jne 0x7c9a
jmp 0x7cac
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x2f, %esi
jne 0x7c9a
leal 0x1(%rax), %edi
cmpb $0x2a, (%rbx,%rdi)
jne 0x7c82
movb $0x1, %cl
xorl %edx, %edx
movl %eax, %ebp
movl %edi, %eax
jmp 0x7c9c
cmpl $0x2f, %esi
jne 0x7c9a
leal 0x1(%rax), %esi
cmpb $0x2f, (%rbx,%rsi)
jne 0x7c9a
movb $0x2, %cl
xorl %edx, %edx
movl %eax, %ebp
movl %esi, %eax
jmp 0x7c9c
xorl %edx, %edx
incl %eax
cmpq %rax, %r14
ja 0x7c0e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
movl %r14d, %r13d
cmovnel %eax, %r13d
cmpb $0x2, %cl
cmovnel %eax, %r13d
cmpl $-0x1, %ebp
je 0x7d29
cmpl $-0x1, %r13d
je 0x7d29
leaq 0x1(%r14), %rdi
callq 0x2140
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 0x7be4
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 0x7d58
addl $0x2, %eax
jmp 0x7cac