// File: /workspace/github_c_makefile_star2_O2/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:
testq %rdi, %rdi
je 0x92f7
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %r13d
movq %rdi, %r14
movq %rdx, 0x28(%rsp)
leaq 0x8(%rsp), %rbp
andl $0x0, (%rbp)
leaq 0x18(%rsp), %rax
andl $0x0, (%rax)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x10(%rsp)
xorl %eax, %eax
movl $0x0, 0x14(%rsp)
xorl %ebx, %ebx
movl $0x0, 0xc(%rsp)
movq %rax, 0x30(%rsp)
incl %eax
movl %eax, 0x24(%rsp)
incq %rbx
leaq -0x1(%rbx), %rsi
cmpq 0x8(%r14), %rsi
jae 0x92e4
movq %r14, %rdi
callq 0x6978
movq %rax, %r15
movq %rax, %rdi
callq 0x20b0
movb (%r15), %cl
cmpb $0xa, %cl
je 0x905e
cmpq $0x2, %rax
jb 0x909c
cmpb $0xd, %cl
jne 0x909c
cmpb $0xa, 0x1(%r15)
je 0x905e
movl %r13d, 0x1c(%rsp)
movl 0x8(%rsp), %edx
xorl %r12d, %r12d
movl 0xc(%rsp), %r13d
cmpb $0x20, %cl
jne 0x90bc
movb 0x1(%r15,%r12), %cl
incq %r12
jmp 0x90ad
addl %edx, %r13d
xorl %ecx, %ecx
cmpl $0x0, 0x10(%rsp)
setne %cl
movl %ecx, %edx
negl %edx
xorl %esi, %esi
xorl %edi, %edi
cmpq %rdi, %rax
je 0x90fb
movzbl (%r15,%rdi), %r8d
cmpl $0x7d, %r8d
je 0x90ef
cmpl $0x7b, %r8d
jne 0x90f6
incl %esi
addl %ecx, 0x14(%rsp)
jmp 0x90f6
decl %r13d
addl %edx, 0x14(%rsp)
incq %rdi
jmp 0x90d1
movl %esi, 0x8(%rsp)
movq %r15, %rdi
leaq 0x56a3(%rip), %rsi      # 0xe7ac
callq 0x21b0
testq %rax, %rax
je 0x912a
movq %r15, %rdi
movq %rax, %rsi
callq 0x92fa
testl %eax, %eax
movl %r13d, %ecx
cmovnel 0x24(%rsp), %ecx
jmp 0x912d
movl %r13d, %ecx
movl 0x10(%rsp), %edx
movl %edx, %eax
xorl $0x1, %eax
orl 0x14(%rsp), %eax
cmovel 0x30(%rsp), %ecx
movl $0x0, %eax
cmovel %eax, %edx
movl %edx, 0x10(%rsp)
movl %ecx, %eax
movl 0x1c(%rsp), %r13d
imull %r13d, %eax
cmpl %r12d, %eax
je 0x9193
movq %r15, %rdi
movl %ecx, %r13d
callq 0x7daf
movq %rax, %r12
movq 0x28(%rsp), %rdi
movl %ebx, %esi
movq %rax, %rdx
leaq 0x585f(%rip), %rcx      # 0xe9d9
callq 0x560c
movq %r12, %rdi
callq 0x2030
movl %r13d, %ecx
movl 0x1c(%rsp), %r13d
incl 0x20(%rsp)
cmpl $0x0, 0x18(%rsp)
je 0x91a7
decl %ecx
movl %ecx, 0xc(%rsp)
andl $0x0, 0x18(%rsp)
jmp 0x91ab
movl %ecx, 0xc(%rsp)
movq %r15, %rdi
leaq 0x562c(%rip), %rsi      # 0xe7e1
movq %rbp, %rdx
leaq 0x18(%rsp), %r12
movq %r12, %rcx
callq 0x9354
movq %r15, %rdi
leaq 0x3e5b(%rip), %rsi      # 0xd02a
movq %rbp, %rdx
movq %r12, %rcx
callq 0x9354
movq %r15, %rdi
leaq 0x55c8(%rip), %rsi      # 0xe7ac
callq 0x21b0
testq %rax, %rax
je 0x9247
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x92fa
testl %eax, %eax
je 0x9247
movq %r12, %rdi
callq 0x20b0
movq %rax, %rbp
pushq $0x4
popq %r13
movsbl (%r12,%r13), %edi
callq 0x7ace
testb %al, %al
je 0x9229
leaq 0x1(%r13), %rax
cmpq %rbp, %r13
movq %rax, %r13
jb 0x920f
movq %r12, %rdi
pushq $0x7b
popq %rsi
callq 0x20c0
testq %rax, %rax
movl 0x1c(%rsp), %r13d
leaq 0x8(%rsp), %rbp
jne 0x9247
incl 0x8(%rsp)
movq %r15, %rdi
leaq 0x55df(%rip), %rsi      # 0xe830
movq %rbp, %rdx
leaq 0x18(%rsp), %rcx
callq 0x9354
movq %r15, %rdi
leaq 0x55aa(%rip), %rsi      # 0xe812
callq 0x21b0
testq %rax, %rax
je 0x905e
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x92fa
testl %eax, %eax
je 0x905e
movl %r13d, %ebp
movq %r12, %rdi
callq 0x20b0
movq %rax, %r15
pushq $0x6
popq %r13
movsbl (%r12,%r13), %edi
callq 0x7ace
leaq 0x1(%r13), %rcx
testb %al, %al
je 0x92b8
cmpq %r15, %r13
movq %rcx, %r13
jb 0x929e
cmpb $0x28, -0x1(%r12,%rcx)
movl %ebp, %r13d
leaq 0x8(%rsp), %rbp
jne 0x905e
incl 0x8(%rsp)
incl 0x14(%rsp)
pushq $0x1
popq %rax
movl %eax, 0x10(%rsp)
movl 0xc(%rsp), %eax
jmp 0x9053
movl 0x20(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq