// File: /workspace/github_c_makefile_star2_O0/System-Glitch[P]ESGILinter-C/src/stringutils.c
// Function: remove_parenthesis
char *remove_parenthesis(char *line, int length) {
	int level       = 0;
	int index       = 0;
	int start_index = 0;
	int end_index   = 0;
	char *sub       = NULL;
	char *tmp       = NULL;
	char c;

	while(is_whitespace(c = line[index]) && index < length) { index++; }

	if(c == '(') {

		level++;

		start_index = ++index;

		while(index < length) {
			c = line[index];
			if(c == '(') level++;
			else if(c == ')') {
				level--;
				if(level == 0) { //Check if end

					end_index = index;
					index++;

					while(is_whitespace(c = line[index]) && index < length) { index++; }

					if(index >= length) {
						sub = strsubstr(line, start_index, end_index - start_index);
						tmp = remove_parenthesis(sub, strlen(sub));
						return tmp != NULL ? tmp : sub;
					} else {
						return NULL;
					}

				}
			}
			index++;
		}
	}

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x39(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x3a(%rbp)
je 0xb0fa
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
setl %al
movb %al, -0x3a(%rbp)
movb -0x3a(%rbp), %al
testb $0x1, %al
jne 0xb103
jmp 0xb10e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xb0cb
movsbl -0x39(%rbp), %eax
cmpl $0x28, %eax
jne 0xb252
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0xb250
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x39(%rbp)
movsbl -0x39(%rbp), %eax
cmpl $0x28, %eax
jne 0xb161
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xb242
movsbl -0x39(%rbp), %eax
cmpl $0x29, %eax
jne 0xb240
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0xb23e
movl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x39(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x3b(%rbp)
je 0xb1bf
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
setl %al
movb %al, -0x3b(%rbp)
movb -0x3b(%rbp), %al
testb $0x1, %al
jne 0xb1c8
jmp 0xb1d3
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xb190
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0xb234
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
movl -0x24(%rbp), %edx
subl -0x20(%rbp), %edx
callq 0xa5e0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rdi
callq 0x2090
movq -0x48(%rbp), %rdi
movl %eax, %esi
callq 0xb090
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xb222
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0xb22a
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xb25a
movq $0x0, -0x8(%rbp)
jmp 0xb25a
jmp 0xb240
jmp 0xb242
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xb130
jmp 0xb252
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)