// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xce59
movl $0x0, -0x4(%rbp)
jmp 0xd283
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x40(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0xd27d
movq -0x10(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x8890
movq %rax, -0x80(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x80(%rbp), %rdi
callq 0x2090
movq %rax, -0x60(%rbp)
movq -0x80(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0xcf21
cmpq $0x2, -0x60(%rbp)
jb 0xcf26
movq -0x80(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0xcf26
movq -0x80(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0xa, %eax
jne 0xcf26
jmp 0xd266
movl -0x30(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x80(%rbp), %rax
movq -0x50(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0xcf6d
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xcf45
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0xcfe7
movq -0x80(%rbp), %rax
movq -0x50(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7b, %eax
jne 0xcfaa
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0xcfa8
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xcfd7
movq -0x80(%rbp), %rax
movq -0x50(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7d, %eax
jne 0xcfd5
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0xcfd3
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xcfd5
jmp 0xcfd7
jmp 0xcfd9
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xcf75
movq -0x80(%rbp), %rdi
leaq 0x77c7(%rip), %rsi      # 0x147b9
callq 0x2190
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xd01d
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xd290
cmpl $0x0, %eax
je 0xd01d
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0xd036
cmpl $0x1, -0x3c(%rbp)
jne 0xd036
movl $0x0, -0x3c(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
movl -0x14(%rbp), %ecx
imull -0x28(%rbp), %ecx
cmpl %ecx, %eax
je 0xd083
movq -0x80(%rbp), %rdi
callq 0xad00
movq %rax, -0x88(%rbp)
movq -0x20(%rbp), %rdi
movl -0x38(%rbp), %esi
movq -0x88(%rbp), %rdx
leaq 0x7962(%rip), %rcx      # 0x149cb
callq 0x6850
movq -0x88(%rbp), %rdi
callq 0x2030
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0xd099
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x80(%rbp), %rdi
leaq 0x774a(%rip), %rsi      # 0x147ee
leaq -0x30(%rbp), %rdx
leaq -0x34(%rbp), %rcx
callq 0xd330
movq -0x80(%rbp), %rdi
leaq 0x5f6e(%rip), %rsi      # 0x1302a
leaq -0x30(%rbp), %rdx
leaq -0x34(%rbp), %rcx
callq 0xd330
movq -0x80(%rbp), %rdi
leaq 0x76e5(%rip), %rsi      # 0x147b9
callq 0x2190
movq %rax, -0x78(%rbp)
movq $0x4, -0x58(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xd17f
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xd290
cmpl $0x0, %eax
je 0xd17f
movq -0x78(%rbp), %rdi
callq 0x2090
movq %rax, -0x68(%rbp)
movq -0x78(%rbp), %rax
movq -0x58(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x69(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x91(%rbp)
je 0xd146
movq -0x58(%rbp), %rax
cmpq -0x68(%rbp), %rax
setb %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0xd152
jmp 0xd160
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0xd10f
movq -0x78(%rbp), %rdi
movl $0x7b, %esi
callq 0x20a0
cmpq $0x0, %rax
jne 0xd17d
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xd17f
movq -0x80(%rbp), %rdi
leaq 0x76b3(%rip), %rsi      # 0x1483d
leaq -0x30(%rbp), %rdx
leaq -0x34(%rbp), %rcx
callq 0xd330
movq -0x80(%rbp), %rdi
leaq 0x767d(%rip), %rsi      # 0x1481f
callq 0x2190
movq %rax, -0x78(%rbp)
movq $0x6, -0x58(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xd264
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xd290
cmpl $0x0, %eax
je 0xd264
movq -0x78(%rbp), %rdi
callq 0x2090
movq %rax, -0x68(%rbp)
movq -0x78(%rbp), %rax
movq -0x58(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x69(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x92(%rbp)
je 0xd218
movq -0x58(%rbp), %rax
cmpq -0x68(%rbp), %rax
setb %al
movb %al, -0x92(%rbp)
movb -0x92(%rbp), %al
testb $0x1, %al
jne 0xd224
jmp 0xd232
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0xd1e1
movq -0x78(%rbp), %rax
movq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x28, %eax
jne 0xd262
movl -0x28(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x1, -0x3c(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xd264
jmp 0xd266
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0xceb6
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nop