// File: /workspace/github_c_makefile_star2_O1/System-Glitch[P]ESGILinter-C/src/rules/indent.c
// Function: check_indent
unsigned int check_indent(arraylist_t *file, int indent, char *filename){
    if(!file) return 0;
    unsigned int counter = 0;
    int level = 0;
    int count = 0;
    int adding = 0;
    int special = 0;
    int line_counter = 0;
    int start_switch;
    int mem;
    int brackets;
    size_t j;
    size_t index;
    size_t length;
    size_t tmp_length;
    char c;
    char *tmp;
    char *line = NULL;
    char *trimmed = NULL;

    start_switch = 0;
    brackets = 0;
    mem = 0;

    for(size_t h = 0; h < file->size; h++){
        line = arraylist_get(file, h);
        line_counter++;
        length = strlen(line);
        if(line[0] == '\n' || (length >= 2 && line[0] == '\r' && line[1] == '\n')) continue;
        level += adding;
        adding = 0;
        j = 0;
        count = 0;
        while(line[j] == ' '){
            j++;
            count++;
        }
        for(j = 0; j < length; j++){
            if(line[j] == '{'){
                adding++;
                if(start_switch){
                    brackets++;
                }
            }else if(line[j] == '}'){
                level--;
                if(start_switch){
                    brackets--;
                }
            }
        }
        tmp = strstr(line, "case");
        if(tmp && is_expression(line, tmp)){
            level = mem+1;
        }
        if(brackets == 0 && start_switch == 1){
            start_switch = 0;
            level = mem;
        }
        if(count != (indent*level)){
            trimmed = trim(line);
            print_warning(filename, line_counter, trimmed, "Wrong indentation");
            free(trimmed);
            counter++;
        }
        if(special){
            level--;
            special = 0;
        }
        check_expression(line, "if", &adding, &special);
        check_expression(line, "for", &adding, &special);
        tmp = strstr(line,"case");
        index = 4;
        if(tmp && is_expression(line, tmp)){
            tmp_length = strlen(tmp);
            while(is_whitespace(c = tmp[index]) && index < tmp_length) { index++; };
            if(strchr(tmp, '{') == NULL)
                adding++;
        }

        check_expression(line, "while", &adding, &special);
        tmp = strstr(line, "switch");
        index = 6;
        if(tmp && is_expression(line, tmp)){
            tmp_length = strlen(tmp);
            while(is_whitespace(c = tmp[index]) && index < tmp_length) { index++; };
            if(tmp[index] == '('){
                mem = level;
                start_switch = 1;
                brackets++;
                adding++;
            }
        }
    }
    return counter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, 0x30(%rsp)
movl %esi, 0x24(%rsp)
testq %rdi, %rdi
je 0x97ad
movq %rdi, %r12
xorl %eax, %eax
movl %eax, (%rsp)
movl $0x0, 0xc(%rsp)
movl %eax, 0x8(%rsp)
cmpq $0x0, 0x8(%rdi)
je 0x97a7
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %ebx, %ebx
movl $0x0, 0x4(%rsp)
xorl %r14d, %r14d
movl $0x0, 0xc(%rsp)
movq %r12, 0x28(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x6c76
movq %rax, %rbp
incq %r13
movq %rax, %rdi
callq 0x20b0
movb (%rbp), %cl
cmpb $0xa, %cl
je 0x979c
cmpq $0x2, %rax
setb %dl
cmpb $0xd, %cl
setne %cl
orb %dl, %cl
jne 0x9557
cmpb $0xa, 0x1(%rbp)
je 0x979c
movq %rbx, 0x10(%rsp)
addl (%rsp), %r14d
movl $0x0, (%rsp)
xorl %ebx, %ebx
cmpb $0x20, (%rbp)
jne 0x957c
xorl %ebx, %ebx
cmpb $0x20, 0x1(%rbp,%rbx)
leaq 0x1(%rbx), %rbx
je 0x9571
movl (%rsp), %ecx
testq %rax, %rax
je 0x95bb
xorl %edx, %edx
cmpl $0x0, 0x4(%rsp)
setne %dl
movl %edx, %esi
negl %esi
xorl %edi, %edi
movzbl (%rbp,%rdi), %r8d
cmpl $0x7d, %r8d
je 0x95ad
cmpl $0x7b, %r8d
jne 0x95b3
incl %ecx
addl %edx, %r15d
jmp 0x95b3
decl %r14d
addl %esi, %r15d
incq %rdi
cmpq %rdi, %rax
jne 0x9594
movl %ecx, (%rsp)
movq %rbp, %rdi
leaq 0x51e7(%rip), %rsi      # 0xe7af
callq 0x21c0
testq %rax, %rax
je 0x95ed
movq %rbp, %rdi
movq %rax, %rsi
callq 0x97be
movq 0x10(%rsp), %rdx
leal 0x1(%rdx), %ecx
testl %eax, %eax
cmovnel %ecx, %r14d
jmp 0x95f2
movq 0x10(%rsp), %rdx
movl 0x4(%rsp), %ecx
movl %ecx, %eax
xorl $0x1, %eax
orl %r15d, %eax
cmovel %edx, %r14d
movl $0x0, %eax
cmovel %eax, %ecx
movl %ecx, 0x4(%rsp)
movl %r14d, %eax
imull 0x24(%rsp), %eax
cmpl %eax, %ebx
je 0x9648
movq %rbp, %rdi
callq 0x81dc
movq %rax, %rbx
movq 0x30(%rsp), %rdi
movl %r13d, %esi
movq %rax, %rdx
leaq 0x53b2(%rip), %rcx      # 0xe9e9
callq 0x57a8
movq %rbx, %rdi
callq 0x2030
incl 0xc(%rsp)
cmpl $0x0, 0x8(%rsp)
movq %r13, 0x18(%rsp)
je 0x965f
decl %r14d
movl $0x0, 0x8(%rsp)
movq %rbp, %rdi
leaq 0x517b(%rip), %rsi      # 0xe7e4
movq %rsp, %rbx
movq %rbx, %rdx
leaq 0x8(%rsp), %r13
movq %r13, %rcx
callq 0x9818
movq %rbp, %rdi
leaq 0x39a4(%rip), %rsi      # 0xd02a
movq %rbx, %rdx
movq %r13, %rcx
callq 0x9818
movq %rbp, %rdi
leaq 0x5114(%rip), %rsi      # 0xe7af
callq 0x21c0
testq %rax, %rax
je 0x96fe
movq %rax, %r13
movq %rbp, %rdi
movq %rax, %rsi
callq 0x97be
testl %eax, %eax
je 0x96fe
movq %r13, %rdi
callq 0x20b0
movq %rax, %rbx
movl $0x4, %r12d
movsbl (%r13,%r12), %edi
callq 0x7ed1
testb %al, %al
je 0x96e4
leaq 0x1(%r12), %rax
cmpq %rbx, %r12
movq %rax, %r12
jb 0x96c8
movq %r13, %rdi
movl $0x7b, %esi
callq 0x20c0
testq %rax, %rax
movq 0x28(%rsp), %r12
jne 0x96fe
incl (%rsp)
movq %rbp, %rdi
leaq 0x512b(%rip), %rsi      # 0xe833
movq %rsp, %rdx
leaq 0x8(%rsp), %rcx
callq 0x9818
movq %rbp, %rdi
leaq 0x50f6(%rip), %rsi      # 0xe815
callq 0x21c0
testq %rax, %rax
je 0x9792
movq %rax, %r13
movq %rbp, %rdi
movq %rax, %rsi
callq 0x97be
testl %eax, %eax
je 0x9792
movq %r13, %rdi
callq 0x20b0
movq %rax, %rbx
movl $0x6, %r12d
movsbl (%r13,%r12), %edi
callq 0x7ed1
leaq 0x1(%r12), %rcx
testb %al, %al
je 0x9768
cmpq %rbx, %r12
movq %rcx, %r12
jb 0x974c
cmpb $0x28, -0x1(%r13,%rcx)
movq 0x28(%rsp), %r12
movq 0x10(%rsp), %rbx
jne 0x978b
incl (%rsp)
incl %r15d
movl $0x1, 0x4(%rsp)
movl %r14d, %ebx
movq 0x18(%rsp), %r13
jmp 0x979c
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rbx
cmpq 0x8(%r12), %r13
jb 0x9517
movl 0xc(%rsp), %eax
jmp 0x97af
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq