// File: /workspace/github_c_makefile_star2_O0/System-Glitch[P]ESGILinter-C/src/test.c
// Function: test_scope_parsing
static void test_scope_parsing() {
	printf("------------------------------%s\n", FORMAT_RESET);

	printf("%sTESTING PARSE SCOPE%s\n", COLOR_GREEN_BOLD, FORMAT_RESET);

	arraylist_t *file = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
	arraylist_add(file, strduplicate("static int glob = 89;"));

	arraylist_add(file, strduplicate("void test(int param) {"));
	arraylist_add(file, strduplicate("\tchar c = 'c';"));
	arraylist_add(file, strduplicate("\tprintf(\"%c %d\", c, i);"));
	arraylist_add(file, strduplicate("}"));

	arraylist_add(file, strduplicate("int main() {"));
	arraylist_add(file, strduplicate("\tint i = 42;"));
	arraylist_add(file, strduplicate("\tchar array[] = {'a','b','c','d'};"));
	arraylist_add(file, strduplicate("\tprintf(\"%d\", i);"));
	arraylist_add(file, strduplicate("\tif(i == 42) {"));
	arraylist_add(file, strduplicate("\t\tchar c = array[1];"));
	arraylist_add(file, strduplicate("\t}"));
	arraylist_add(file, strduplicate("}"));

	scope_t *scope = parse_root_scope(file);
	if(scope != NULL) {
		print_scope(scope, 0);
		scope_free(scope);
	}

	arraylist_free(file, 1);

	file = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
	arraylist_add(file, strduplicate("int main() {"));
	arraylist_add(file, strduplicate("\tint i = 42;"));
	arraylist_add(file, strduplicate("\tif(i == 42) {"));
	arraylist_add(file, strduplicate("\t\tchar c = array[1];"));
	//Missing closing parenthesis
	arraylist_add(file, strduplicate("}"));

	scope = parse_root_scope(file);
	if(scope != NULL) {
		print_scope(scope, 0);
		scope_free(scope);
	} else {
		printf("%sScope %sNULL%s, possible syntax error.\n%s", COLOR_YELLOW, COLOR_RED, COLOR_YELLOW, FORMAT_RESET);
	}

	arraylist_free(file, 1);

	file = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
	arraylist_add(file, strduplicate("int main() {"));
	arraylist_add(file, strduplicate("/* comment */ double db = 1.2;"));
	arraylist_add(file, strduplicate("\tfor(int i = 0, j = 5 ; i < 10 ; i++) {"));
	arraylist_add(file, strduplicate("\t\tprintf(\"%d\", i);"));
	arraylist_add(file, strduplicate("\t\tconst char *literal = \"test { int k = 0; }\";"));
	arraylist_add(file, strduplicate("\t}"));
	arraylist_add(file, strduplicate("}"));

	scope = parse_root_scope(file);
	if(scope != NULL) {
		print_scope(scope, 0);
		scope_free(scope);
	} else {
		printf("%sScope %sNULL%s, possible syntax error.\n%s", COLOR_YELLOW, COLOR_RED, COLOR_YELLOW, FORMAT_RESET);
	}

	arraylist_free(file, 1);

	file = arraylist_init(ARRAYLIST_DEFAULT_CAPACITY);
	arraylist_add(file, strduplicate("int main() {"));
	arraylist_add(file, strduplicate("\tswitch (1) {"));
	arraylist_add(file, strduplicate("\tcase 4: int innertest;"));

	arraylist_add(file, strduplicate("\tswitch(b) {")); //10
	arraylist_add(file, strduplicate("\tcase 1: int inner2;"));
	arraylist_add(file, strduplicate("\tcase 2: case 3: int inner3;"));
	arraylist_add(file, strduplicate("\tcase 4: default: int inner4;"));
	arraylist_add(file, strduplicate("\t}"));

	arraylist_add(file, strduplicate("\tint innertest2;"));
	arraylist_add(file, strduplicate("\t}"));
	arraylist_add(file, strduplicate("}"));

	scope = parse_root_scope(file);

	if(scope != NULL) {
		print_scope(scope, 0);
		scope_free(scope);
	} else {
		printf("%sScope %sNULL%s, possible syntax error.\n%s", COLOR_YELLOW, COLOR_RED, COLOR_YELLOW, FORMAT_RESET);
	}

	arraylist_free(file, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
leaq 0xfa6f(%rip), %rdi      # 0x13031
leaq 0xfa5c(%rip), %rsi      # 0x13025
movb $0x0, %al
callq 0x20b0
leaq 0x1009a(%rip), %rdi     # 0x13671
leaq 0xfa9d(%rip), %rsi      # 0x1307b
leaq 0xfa40(%rip), %rdx      # 0x13025
movb $0x0, %al
callq 0x20b0
movl $0xa, %edi
callq 0x8580
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq 0x10081(%rip), %rdi     # 0x1368a
callq 0xa550
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0x10077(%rip), %rdi     # 0x136a0
callq 0xa550
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq 0x1006e(%rip), %rdi     # 0x136b7
callq 0xa550
movq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq 0x1005d(%rip), %rdi     # 0x136c6
callq 0xa550
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x10e20(%rip), %rdi     # 0x144a9
callq 0xa550
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq 0x10035(%rip), %rdi     # 0x136de
callq 0xa550
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0x10022(%rip), %rdi     # 0x136eb
callq 0xa550
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0x1000f(%rip), %rdi     # 0x136f8
callq 0xa550
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x1008b(%rip), %rdi     # 0x13794
callq 0xa550
movq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq 0xfff2(%rip), %rdi      # 0x1371b
callq 0xa550
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0xffe1(%rip), %rdi      # 0x1372a
callq 0xa550
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq 0x10d3f(%rip), %rdi     # 0x144a8
callq 0xa550
movq -0x20(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq 0x10d20(%rip), %rdi     # 0x144a9
callq 0xa550
movq -0x18(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rdi
callq 0x77a0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x37c2
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x3c90
movq -0x10(%rbp), %rdi
callq 0x7fa0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x8a00
movl $0xa, %edi
callq 0x8580
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq 0xfeee(%rip), %rdi      # 0x136de
callq 0xa550
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq 0xfed5(%rip), %rdi      # 0x136eb
callq 0xa550
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq 0xfedf(%rip), %rdi      # 0x1371b
callq 0xa550
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq 0xfec8(%rip), %rdi      # 0x1372a
callq 0xa550
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq 0x10c24(%rip), %rdi     # 0x144a9
callq 0xa550
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rdi
callq 0x77a0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x38c0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x3c90
movq -0x10(%rbp), %rdi
callq 0x7fa0
jmp 0x38e6
leaq 0xfe78(%rip), %rdi      # 0x1373f
leaq 0xf751(%rip), %rcx      # 0x1301f
leaq 0xf744(%rip), %rdx      # 0x13019
leaq 0xf749(%rip), %r8       # 0x13025
movq %rcx, %rsi
movb $0x0, %al
callq 0x20b0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x8a00
movl $0xa, %edi
callq 0x8580
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq 0xfdca(%rip), %rdi      # 0x136de
callq 0xa550
movq -0xd8(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq 0xf9b2(%rip), %rdi      # 0x132ec
callq 0xa550
movq -0xd0(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq 0xfe0b(%rip), %rdi      # 0x1376b
callq 0xa550
movq -0xc8(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq 0xfe0d(%rip), %rdi      # 0x13793
callq 0xa550
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq 0xfdfa(%rip), %rdi      # 0x137a6
callq 0xa550
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq 0x10ad6(%rip), %rdi     # 0x144a8
callq 0xa550
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq 0x10ab1(%rip), %rdi     # 0x144a9
callq 0xa550
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rdi
callq 0x77a0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x3a36
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x3c90
movq -0x10(%rbp), %rdi
callq 0x7fa0
jmp 0x3a5c
leaq 0xfd02(%rip), %rdi      # 0x1373f
leaq 0xf5db(%rip), %rcx      # 0x1301f
leaq 0xf5ce(%rip), %rdx      # 0x13019
leaq 0xf5d3(%rip), %r8       # 0x13025
movq %rcx, %rsi
movb $0x0, %al
callq 0x20b0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x8a00
movl $0xa, %edi
callq 0x8580
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq 0xfc54(%rip), %rdi      # 0x136de
callq 0xa550
movq -0x130(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq 0xfd25(%rip), %rdi      # 0x137d5
callq 0xa550
movq -0x128(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq 0xfd0d(%rip), %rdi      # 0x137e3
callq 0xa550
movq -0x120(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq 0xfcff(%rip), %rdi      # 0x137fb
callq 0xa550
movq -0x118(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq 0xfce6(%rip), %rdi      # 0x13808
callq 0xa550
movq -0x110(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq 0xfcd5(%rip), %rdi      # 0x1381d
callq 0xa550
movq -0x108(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq 0xfccc(%rip), %rdi      # 0x1383a
callq 0xa550
movq -0x100(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq 0x10914(%rip), %rdi     # 0x144a8
callq 0xa550
movq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq 0xfc9e(%rip), %rdi      # 0x13858
callq 0xa550
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq 0x108c8(%rip), %rdi     # 0x144a8
callq 0xa550
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq 0x108a3(%rip), %rdi     # 0x144a9
callq 0xa550
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
callq 0x8730
movq -0x8(%rbp), %rdi
callq 0x77a0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x3c44
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x3c90
movq -0x10(%rbp), %rdi
callq 0x7fa0
jmp 0x3c6a
leaq 0xfaf4(%rip), %rdi      # 0x1373f
leaq 0xf3cd(%rip), %rcx      # 0x1301f
leaq 0xf3c0(%rip), %rdx      # 0x13019
leaq 0xf3c5(%rip), %r8       # 0x13025
movq %rcx, %rsi
movb $0x0, %al
callq 0x20b0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x8a00
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)