// File: pranavmodx[P]modlang/src/evaluator.cpp
// Function: Evaluator::evalStringIndexExpression(String*, Integer*)
Object *Evaluator::evalStringIndexExpression(String *string, Integer *index)
{
	int i = index->value;
	auto arr = string->value;

	if (arr.size() <= i)
		return new Error("error: index " + index->inspect() + " out of range");

	return new String(std::string(1, arr[i]));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
leaq -0x48(%rbp), %rdi
callq 0x5130
leaq -0x48(%rbp), %rdi
callq 0x51d0
movslq -0x24(%rbp), %rcx
cmpq %rcx, %rax
ja 0x36d6a
movl $0x28, %edi
callq 0x52a0
movq %rax, -0xf0(%rbp)
jmp 0x36c3b
movb $0x1, -0xb9(%rbp)
movq -0x20(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0xb8(%rbp), %rdi
callq *%rax
jmp 0x36c58
leaq 0xf13e(%rip), %rsi      # 0x45d9d
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0x1bde0
jmp 0x36c74
leaq 0xeae0(%rip), %rdx      # 0x4575b
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x1bb10
jmp 0x36c8d
movq -0xf0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2b980
jmp 0x36c9f
movq -0xf0(%rbp), %rax
movb $0x0, -0xb9(%rbp)
movq %rax, -0x8(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5518
leaq -0x98(%rbp), %rdi
callq 0x5518
leaq -0xb8(%rbp), %rdi
callq 0x5518
movl $0x1, -0xc0(%rbp)
jmp 0x36e86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x36e9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x36d49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x36d3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x36d31
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5518
leaq -0x98(%rbp), %rdi
callq 0x5518
leaq -0xb8(%rbp), %rdi
callq 0x5518
testb $0x1, -0xb9(%rbp)
jne 0x36d54
jmp 0x36d65
movq -0xf0(%rbp), %rdi
movl $0x28, %esi
callq 0x52b0
jmp 0x36e9c
movl $0x28, %edi
callq 0x52a0
movq %rax, -0xf8(%rbp)
jmp 0x36d7d
movb $0x1, -0xe2(%rbp)
movslq -0x24(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x54f0
movq %rax, -0x100(%rbp)
jmp 0x36d9a
movq -0x100(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x10c(%rbp)
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x54a0
movl -0x10c(%rbp), %edx
movq -0x108(%rbp), %rcx
leaq -0xe0(%rbp), %rdi
movl $0x1, %esi
callq 0x18ea0
jmp 0x36ddd
movq -0xf8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x38640
jmp 0x36df2
movq -0xf8(%rbp), %rax
movb $0x0, -0xe2(%rbp)
movq %rax, -0x8(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x5518
leaq -0xe1(%rbp), %rdi
callq 0x52f0
movl $0x1, -0xc0(%rbp)
jmp 0x36e86
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x36e68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x36e5c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x5518
leaq -0xe1(%rbp), %rdi
callq 0x52f0
testb $0x1, -0xe2(%rbp)
jne 0x36e73
jmp 0x36e84
movq -0xf8(%rbp), %rdi
movl $0x28, %esi
callq 0x52b0
jmp 0x36e9c
leaq -0x48(%rbp), %rdi
callq 0x5518
movq -0x8(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x5518
movq -0x50(%rbp), %rdi
callq 0x5490
nop