// File: /workspace/github_c_makefile_star2_O3/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 0xcbcc
movq 0x10(%rbx), %rbx
leaq 0x14(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x46e7
xorl %ebp, %ebp
testl %eax, %eax
je 0xcc01
movq 0x10(%rbx), %rdi
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
callq 0x46e7
testl %eax, %eax
je 0xcc01
movq 0x28(%rsp), %r12
testq %r12, %r12
je 0xcbd0
movq %r13, 0x18(%rsp)
movb 0x14(%r12), %sil
leaq 0x10(%r12), %rdx
leaq 0x40(%r12), %rcx
cmpb $0x2, %sil
cmoveq %rcx, %rdx
movslq 0x14(%rsp), %r13
testq %r13, %r13
js 0xcbd9
movl 0x10(%rsp), %ebx
testl %ebx, %ebx
js 0xcbd9
movl %ebx, %ecx
xorl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %r13d, %ecx
jl 0xcbd9
leal (%rbx,%r13), %ecx
cmpl (%rdx), %ecx
jg 0xcbd9
movb %sil, 0xb(%rsp)
movl %eax, 0xc(%rsp)
leaq 0x19(%rbx), %rdi
callq 0x31b0
testq %rax, %rax
je 0xcbeb
movq %rax, %rbp
movq %rax, %rdi
addq $0x18, %rdi
movq $0x0, 0x10(%rax)
movq %rdi, 0x8(%rax)
movb $0x0, 0x18(%rax,%rbx)
movq $0x1, (%rax)
movl %ebx, 0x10(%rax)
cmpb $0x2, 0xb(%rsp)
jne 0xcc21
testl %ebx, %ebx
movl 0xc(%rsp), %edx
je 0xcc35
shlq $0x2, %r13
addq 0x18(%r12), %r13
xorl %eax, %eax
movb (%r13,%rax,4), %cl
movb %cl, (%rdi,%rax)
incq %rax
cmpq %rax, %rbx
jne 0xcbba
jmp 0xcc35
xorl %ebp, %ebp
jmp 0xcc10
leaq 0x6436(%rip), %rcx      # 0x1300d
jmp 0xcbf2
leaq 0x6418(%rip), %rcx      # 0x12ff8
movq %r15, %rdi
movq %r14, %rsi
movl %r13d, %edx
jmp 0xcbfc
movq 0xc57e(%rip), %rcx      # 0x19170
xorl %ebp, %ebp
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3c96
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xcc10
callq 0x394d
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq 0x8(%r12), %r13
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3180
movl 0xc(%rsp), %edx
movq 0x18(%rsp), %rax
movq %rbp, 0x8(%rax)
movl %edx, %ebp
jmp 0xcc01