// File: /workspace/github_c_makefile_star2_O0/been-jamming[P]MinimalCC/expression.c
// Function: compile_list_index
void compile_list_index(char **c, value *address, unsigned char dereference, FILE *output_file){
	value index;
	type address_type;

	address_type = address->data_type;
	if(pop_type(&address_type) != type_pointer){
		snprintf(error_message, sizeof(error_message), "Cannot address non-pointer type");
		do_error(1);
	}
	++*c;
	compile_expression(&index, c, 1, 0, output_file);
	if(**c != ']'){
		snprintf(error_message, sizeof(error_message), "Expected closing ']'");
		do_error(1);
	}
	++*c;
	cast(&index, INT_TYPE, 1, output_file);
	if(index.data.type == data_register){
		if(type_size(&address_type, 0) == 4){
			fileprint(output_file, "sll $s%d, $s%d, 2\n", index.data.reg, index.data.reg);
		} else if(type_size(&address_type, 0) != 1){
			fileprint(output_file, "li $t0, %d\n", (int) type_size(&address_type, 0));
			fileprint(output_file, "mult $s%d, $t0\n", index.data.reg);
			fileprint(output_file, "mflo $s%d\n", index.data.reg);
		}
		if(address->data.type == data_register){
			fileprint(output_file, "add $s%d, $s%d, $s%d\n", address->data.reg, address->data.reg, index.data.reg);
			if(dereference && peek_type(&address_type) != type_list){
				if(type_size(&address_type, 0) == 4){
					fileprint(output_file, "lw $s%d, 0($s%d)\n", address->data.reg, address->data.reg);
				} else if(type_size(&address_type, 0) == 1){
					fileprint(output_file, "lb $s%d, 0($s%d)\n", address->data.reg, address->data.reg);
				} else {
					snprintf(error_message, sizeof(error_message), "[INTERNAL] Unusable type size");
					do_error(1);
				}
			}
		} else if(address->data.type == data_stack){
			fileprint(output_file, "lw $t0, %d($sp)\n", get_stack_pos(address->data));
			fileprint(output_file, "add $t0, $t0, $s%d\n", index.data.reg);
			if(dereference && peek_type(&address_type) != type_list){
				if(type_size(&address_type, 0) == 4){
					fileprint(output_file, "lw $t0, 0($t0)\n");
				} else if(type_size(&address_type, 0) == 1){
					fileprint(output_file, "lb $t0, 0($t0)\n");
				} else {
					snprintf(error_message, sizeof(error_message), "[INTERNAL] Unusable type size");
					do_error(1);
				}
			}
			fileprint(output_file, "sw $t0, %d($sp)\n", get_stack_pos(address->data));
		}
	} else if(index.data.type == data_stack){
		fileprint(output_file, "lw $t1, %d($sp)\n", get_stack_pos(index.data));
		if(type_size(&address_type, 0) == 4){
			fileprint(output_file, "sll $t1, $t1, 2\n");
		} else if(type_size(&address_type, 0) != 1){
			fileprint(output_file, "li $t0, %d\n", (int) type_size(&address_type, 0));
			fileprint(output_file, "mult $t1, $t0\n");
			fileprint(output_file, "mflo $t1\n");
		}
		if(address->data.type == data_register){
			fileprint(output_file, "add $s%d, $s%d, $t1\n", address->data.reg, address->data.reg);
			if(dereference && peek_type(&address_type) != type_list){
				if(type_size(&address_type, 0) == 4){
					fileprint(output_file, "lw $s%d, 0($s%d)\n", address->data.reg, address->data.reg);
				} else if(type_size(&address_type, 0) == 1){
					fileprint(output_file, "lb $s%d, 0($s%d)\n", address->data.reg, address->data.reg);
				}
			}
		} else if(address->data.type == data_stack){
			fileprint(output_file, "lw $t0, %d($sp)\n", get_stack_pos(address->data));
			fileprint(output_file, "add $t0, $t0, $t1\n");
			if(dereference && peek_type(&address_type) != type_list){
				if(type_size(&address_type, 0) == 4){
					fileprint(output_file, "lw $t0, 0($t0)\n");
				} else if(type_size(&address_type, 0) == 1){
					fileprint(output_file, "lb $t0, 0($t0)\n");
				}
			}
			fileprint(output_file, "sw $t0, %d($sp)\n", get_stack_pos(address->data));
		}
	}
	deallocate(index.data);
	if(dereference){
		pop_type(&(address->data_type));
		if(peek_type(&(address->data_type)) == type_list){
			pop_type(&(address->data_type));
			address->data_type.current_index--;
			add_type_entry(&(address->data_type), type_pointer);
		}
	}
	address->is_reference = !dereference;
}

// Assembly:
subq $0x198, %rsp            # imm = 0x198
movb %dl, %al
movq %rdi, 0x190(%rsp)
movq %rsi, 0x188(%rsp)
movb %al, 0x187(%rsp)
movq %rcx, 0x178(%rsp)
movq 0x188(%rsp), %rsi
addq $0x10, %rsi
leaq 0xe0(%rsp), %rdi
movl $0x40, %edx
callq 0x1120
leaq 0xe0(%rsp), %rdi
callq 0xbe20
cmpl $0x4, %eax
je 0x51dc
leaq 0xc371(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x8849(%rip), %rdx      # 0xda14
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
movq 0x190(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x190(%rsp), %rsi
movq 0x178(%rsp), %r8
leaq 0x120(%rsp), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x4fe0
movq 0x190(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
je 0x5249
leaq 0xc304(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x87fc(%rip), %rdx      # 0xda34
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
movq 0x190(%rsp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x178(%rsp), %rdx
leaq 0xbf5e(%rip), %rax      # 0x111c8
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups 0x30(%rax), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq 0x120(%rsp), %rdi
movl $0x1, %esi
callq 0x3fd0
cmpl $0x0, 0x120(%rsp)
jne 0x5608
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x52e8
movq 0x178(%rsp), %rdi
movl 0x124(%rsp), %edx
movl 0x124(%rsp), %ecx
leaq 0x876d(%rip), %rsi      # 0xda49
movb $0x0, %al
callq 0x16f0
jmp 0x5369
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
je 0x5367
movq 0x178(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
movq 0x78(%rsp), %rdi
movl %eax, %edx
leaq 0x8736(%rip), %rsi      # 0xda5c
movb $0x0, %al
callq 0x16f0
movq 0x178(%rsp), %rdi
movl 0x124(%rsp), %edx
leaq 0x8725(%rip), %rsi      # 0xda68
movb $0x0, %al
callq 0x16f0
movq 0x178(%rsp), %rdi
movl 0x124(%rsp), %edx
leaq 0x8718(%rip), %rsi      # 0xda78
movb $0x0, %al
callq 0x16f0
jmp 0x5369
movq 0x188(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x5486
movq 0x178(%rsp), %rdi
movq 0x188(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x188(%rsp), %rax
movl 0x4(%rax), %ecx
movl 0x124(%rsp), %r8d
leaq 0x86dc(%rip), %rsi      # 0xda83
movb $0x0, %al
callq 0x16f0
movzbl 0x187(%rsp), %eax
cmpl $0x0, %eax
je 0x5481
leaq 0xe0(%rsp), %rdi
callq 0xbdb0
cmpl $0x7, %eax
je 0x5481
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x5417
movq 0x178(%rsp), %rdi
movq 0x188(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x188(%rsp), %rax
movl 0x4(%rax), %ecx
leaq 0x8551(%rip), %rsi      # 0xd95f
movb $0x0, %al
callq 0x16f0
jmp 0x547f
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
jne 0x5459
movq 0x178(%rsp), %rdi
movq 0x188(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x188(%rsp), %rax
movl 0x4(%rax), %ecx
leaq 0x84fd(%rip), %rsi      # 0xd94d
movb $0x0, %al
callq 0x16f0
jmp 0x547d
leaq 0xc0d0(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x862d(%rip), %rdx      # 0xda99
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
jmp 0x547f
jmp 0x5481
jmp 0x5603
movq 0x188(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x5601
movq 0x178(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x188(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0xd0(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0xd8(%rsp)
movq 0xd0(%rsp), %rdi
movl 0xd8(%rsp), %esi
callq 0x1490
movq 0x70(%rsp), %rdi
movl %eax, %edx
leaq 0x8387(%rip), %rsi      # 0xd86a
movb $0x0, %al
callq 0x16f0
movq 0x178(%rsp), %rdi
movl 0x124(%rsp), %edx
leaq 0x85b7(%rip), %rsi      # 0xdab7
movb $0x0, %al
callq 0x16f0
movzbl 0x187(%rsp), %eax
cmpl $0x0, %eax
je 0x55ae
leaq 0xe0(%rsp), %rdi
callq 0xbdb0
cmpl $0x7, %eax
je 0x55ae
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x555a
movq 0x178(%rsp), %rdi
leaq 0x8441(%rip), %rsi      # 0xd992
movb $0x0, %al
callq 0x16f0
jmp 0x55ac
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
jne 0x5586
movq 0x178(%rsp), %rdi
leaq 0x83f4(%rip), %rsi      # 0xd971
movb $0x0, %al
callq 0x16f0
jmp 0x55aa
leaq 0xbfa3(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x8500(%rip), %rdx      # 0xda99
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
jmp 0x55ac
jmp 0x55ae
movq 0x178(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x188(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0xc0(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0xc8(%rsp)
movq 0xc0(%rsp), %rdi
movl 0xc8(%rsp), %esi
callq 0x1490
movq 0x68(%rsp), %rdi
movl %eax, %edx
leaq 0x81df(%rip), %rsi      # 0xd7d9
movb $0x0, %al
callq 0x16f0
jmp 0x5603
jmp 0x5944
cmpl $0x1, 0x120(%rsp)
jne 0x5942
movq 0x178(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0xb0(%rsp)
movl 0x128(%rsp), %eax
movl %eax, 0xb8(%rsp)
movq 0xb0(%rsp), %rdi
movl 0xb8(%rsp), %esi
callq 0x1490
movq 0x60(%rsp), %rdi
movl %eax, %edx
leaq 0x8468(%rip), %rsi      # 0xdacb
movb $0x0, %al
callq 0x16f0
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x5696
movq 0x178(%rsp), %rdi
leaq 0x844f(%rip), %rsi      # 0xdadc
movb $0x0, %al
callq 0x16f0
jmp 0x5709
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
je 0x5707
movq 0x178(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
movq 0x58(%rsp), %rdi
movl %eax, %edx
leaq 0x8388(%rip), %rsi      # 0xda5c
movb $0x0, %al
callq 0x16f0
movq 0x178(%rsp), %rdi
leaq 0x8403(%rip), %rsi      # 0xdaed
movb $0x0, %al
callq 0x16f0
movq 0x178(%rsp), %rdi
leaq 0x83fc(%rip), %rsi      # 0xdafc
movb $0x0, %al
callq 0x16f0
jmp 0x5709
movq 0x188(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x57f8
movq 0x178(%rsp), %rdi
movq 0x188(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x188(%rsp), %rax
movl 0x4(%rax), %ecx
leaq 0x83c7(%rip), %rsi      # 0xdb06
movb $0x0, %al
callq 0x16f0
movzbl 0x187(%rsp), %eax
cmpl $0x0, %eax
je 0x57f3
leaq 0xe0(%rsp), %rdi
callq 0xbdb0
cmpl $0x7, %eax
je 0x57f3
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x57af
movq 0x178(%rsp), %rdi
movq 0x188(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x188(%rsp), %rax
movl 0x4(%rax), %ecx
leaq 0x81b9(%rip), %rsi      # 0xd95f
movb $0x0, %al
callq 0x16f0
jmp 0x57f1
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
jne 0x57ef
movq 0x178(%rsp), %rdi
movq 0x188(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x188(%rsp), %rax
movl 0x4(%rax), %ecx
leaq 0x8165(%rip), %rsi      # 0xd94d
movb $0x0, %al
callq 0x16f0
jmp 0x57f1
jmp 0x57f3
jmp 0x5940
movq 0x188(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x593e
movq 0x178(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x188(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0xa0(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0xa8(%rsp)
movq 0xa0(%rsp), %rdi
movl 0xa8(%rsp), %esi
callq 0x1490
movq 0x50(%rsp), %rdi
movl %eax, %edx
leaq 0x8015(%rip), %rsi      # 0xd86a
movb $0x0, %al
callq 0x16f0
movq 0x178(%rsp), %rdi
leaq 0x82b0(%rip), %rsi      # 0xdb1b
movb $0x0, %al
callq 0x16f0
movzbl 0x187(%rsp), %eax
cmpl $0x0, %eax
je 0x58eb
leaq 0xe0(%rsp), %rdi
callq 0xbdb0
cmpl $0x7, %eax
je 0x58eb
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x58bd
movq 0x178(%rsp), %rdi
leaq 0x80de(%rip), %rsi      # 0xd992
movb $0x0, %al
callq 0x16f0
jmp 0x58e9
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
jne 0x58e7
movq 0x178(%rsp), %rdi
leaq 0x8091(%rip), %rsi      # 0xd971
movb $0x0, %al
callq 0x16f0
jmp 0x58e9
jmp 0x58eb
movq 0x178(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x188(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x90(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x98(%rsp)
movq 0x90(%rsp), %rdi
movl 0x98(%rsp), %esi
callq 0x1490
movq 0x48(%rsp), %rdi
movl %eax, %edx
leaq 0x7ea2(%rip), %rsi      # 0xd7d9
movb $0x0, %al
callq 0x16f0
jmp 0x5940
jmp 0x5942
jmp 0x5944
movq 0x120(%rsp), %rax
movq %rax, 0x80(%rsp)
movl 0x128(%rsp), %eax
movl %eax, 0x88(%rsp)
movq 0x80(%rsp), %rdi
movl 0x88(%rsp), %esi
callq 0x13b0
cmpb $0x0, 0x187(%rsp)
je 0x59e1
movq 0x188(%rsp), %rdi
addq $0x10, %rdi
callq 0xbe20
movq 0x188(%rsp), %rdi
addq $0x10, %rdi
callq 0xbdb0
cmpl $0x7, %eax
jne 0x59df
movq 0x188(%rsp), %rdi
addq $0x10, %rdi
callq 0xbe20
movq 0x188(%rsp), %rax
movl 0x48(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x48(%rax)
movq 0x188(%rsp), %rdi
addq $0x10, %rdi
movl $0x4, %esi
callq 0xb510
jmp 0x59e1
cmpb $0x0, 0x187(%rsp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movb %al, %cl
movq 0x188(%rsp), %rax
movb %cl, 0x50(%rax)
addq $0x198, %rsp            # imm = 0x198
retq
nopl (%rax,%rax)