// File: /workspace/github_c_makefile_star2_O1/martincameron[P]towntalk/towntalk.c
// Function: evaluate_sub_expression
static enum result evaluate_sub_expression( struct expression *this,
	struct variables *vars, struct variable *result ) {
	char *data;
	number *arr;
	struct string *str;
	struct variable var = { 0, NULL };
	int offset, length, idx, len;
	struct expression *parameter = this->parameters;
	enum result ret = parameter->evaluate( parameter, vars, &var );
	if( ret ) {
		parameter = parameter->next;
		ret = evaluate_integer( parameter, vars, &idx );
		if( ret ) {
			parameter = parameter->next;
			ret = evaluate_integer( parameter, vars, &len );
			if( ret ) {
				if( var.string_value ) {
					if( var.string_value->type == ARRAY ) {
						length = ( ( struct array * ) var.string_value )->length;
					} else {
						length = var.string_value->length;
					}
					if( idx >= 0 && len >= 0 && MAX_INTEGER - len >= idx && idx + len <= length ) {
						str = new_string( len );
						if( str ) {
							if( var.string_value->type == ARRAY ) {
								data = str->string;
								arr = ( ( struct array * ) var.string_value )->number_values;
								offset = 0;
								while( offset < len ) {
									data[ offset ] = arr[ offset + idx ];
									offset++;
								}
							} else {
								memcpy( str->string, &var.string_value->string[ idx ], sizeof( char ) * len );
							}
							result->string_value = str;
						} else {
							ret = throw_out_of_memory( vars, this );
						}
					} else {
						ret = throw( vars, this, idx, "Range out of bounds." );
					}
				} else {
					ret = throw( vars, this, 0, "Not a string or array." );
				}
			}
		}
		dispose_temporary( &var );
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdx
movaps %xmm0, (%rdx)
movq 0x8(%rdi), %rbx
movq %rbx, %rdi
callq *0x18(%rbx)
testl %eax, %eax
je 0xce66
movq 0x10(%rbx), %rbx
leaq 0x14(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4714
xorl %ebp, %ebp
testl %eax, %eax
je 0xce9a
movq 0x10(%rbx), %rdi
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
callq 0x4714
testl %eax, %eax
je 0xce9a
movq 0x28(%rsp), %r12
testq %r12, %r12
je 0xce6a
movq %r13, 0x18(%rsp)
leaq 0x10(%r12), %rdx
leaq 0x40(%r12), %rcx
cmpb $0x2, 0x14(%r12)
cmoveq %rcx, %rdx
movslq 0x14(%rsp), %rbx
testq %rbx, %rbx
js 0xce73
movl 0x10(%rsp), %r13d
testl %r13d, %r13d
js 0xce73
movl %r13d, %ecx
xorl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ebx, %ecx
jl 0xce73
leal (%rbx,%r13), %ecx
cmpl (%rdx), %ecx
jg 0xce73
movl %eax, 0xc(%rsp)
leaq 0x19(%r13), %rdi
callq 0x31b0
testq %rax, %rax
je 0xce84
movq %rax, %rbp
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
addq $0x18, %rax
movq %rax, 0x8(%rbp)
movb $0x0, 0x18(%rbp,%r13)
movq $0x1, (%rbp)
movl %r13d, 0x10(%rbp)
cmpb $0x2, 0x14(%r12)
movq 0x8(%rbp), %rdi
jne 0xceba
testl %r13d, %r13d
movl 0xc(%rsp), %esi
jle 0xcece
movq 0x18(%r12), %rax
leaq (%rax,%rbx,4), %rax
xorl %ecx, %ecx
movb (%rax,%rcx,4), %dl
movb %dl, (%rdi,%rcx)
incq %rcx
cmpq %rcx, %r13
jne 0xce56
jmp 0xcece
xorl %ebp, %ebp
jmp 0xcea9
leaq 0x619e(%rip), %rcx      # 0x1300f
jmp 0xce8b
leaq 0x6180(%rip), %rcx      # 0x12ffa
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
jmp 0xce95
movq 0xc2e5(%rip), %rcx      # 0x19170
xorl %ebp, %ebp
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3cc3
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xcea9
callq 0x3979
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq 0x8(%r12), %rbx
movq %rbx, %rsi
movq %r13, %rdx
callq 0x3180
movl 0xc(%rsp), %esi
movq 0x18(%rsp), %rax
movq %rbp, 0x8(%rax)
movl %esi, %ebp
jmp 0xce9a