// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
movb $0x0, -0x21(%rbp)
movb $0x0, -0x22(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2090
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpq -0x30(%rbp), %rax
jae 0xa44c
cmpb $0x0, -0x21(%rbp)
jne 0xa322
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0xa322
movb $0x1, -0x21(%rbp)
jmp 0xa43c
cmpb $0x0, -0x21(%rbp)
je 0xa356
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0xa351
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x5c, %eax
je 0xa351
movb $0x0, -0x21(%rbp)
jmp 0xa43a
cmpl $-0x1, -0x1c(%rbp)
jne 0xa3d2
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0xa396
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x2a, %eax
jne 0xa396
movb $0x1, -0x22(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xa3d0
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0xa3ce
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0xa3ce
movb $0x2, -0x22(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xa3d0
jmp 0xa438
movzbl -0x22(%rbp), %eax
cmpl $0x1, %eax
jne 0xa40b
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x2a, %eax
jne 0xa40b
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0xa40b
movl -0x34(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x20(%rbp)
jmp 0xa44c
movzbl -0x22(%rbp), %eax
cmpl $0x2, %eax
jne 0xa434
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
movsbl (%rax,%rcx), %edi
callq 0xa520
movsbl %al, %eax
cmpl $0x0, %eax
je 0xa434
movl -0x34(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0xa44c
jmp 0xa436
jmp 0xa438
jmp 0xa43a
jmp 0xa43c
jmp 0xa43e
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xa2f6
movzbl -0x22(%rbp), %eax
cmpl $0x2, %eax
jne 0xa462
cmpl $-0x1, -0x20(%rbp)
jne 0xa462
movq -0x30(%rbp), %rax
movl %eax, -0x20(%rbp)
cmpl $-0x1, -0x1c(%rbp)
je 0xa4fc
cmpl $-0x1, -0x20(%rbp)
je 0xa4fc
movq -0x30(%rbp), %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x2110
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
movslq -0x1c(%rbp), %rdx
callq 0x2050
movq -0x10(%rbp), %rdi
movslq -0x1c(%rbp), %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movslq -0x20(%rbp), %rax
addq %rax, %rsi
movq -0x30(%rbp), %rdx
movslq -0x20(%rbp), %rax
subq %rax, %rdx
callq 0x2050
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq -0x30(%rbp), %rdx
movslq -0x20(%rbp), %rsi
subq %rsi, %rdx
addq %rdx, %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rdi
callq 0xa2b0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2030
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0xa509
movq -0x8(%rbp), %rdi
callq 0xa550
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)