// File: /workspace/github_c_makefile_star2_O2/mattn[P]orelang/ore.c
// Function: ore_index_ref
static ore_value*
ore_index_ref(ore_context* ore, ore_value v, ore_value e, int update) {
  if (v.t == ORE_TYPE_ARRAY) {
    if (e.t != ORE_TYPE_INT) {
      fprintf(stderr, "array index should be int\n");
      ore->err = ORE_ERROR_EXCEPTION;
      return NULL;
    }
    ore_array_t* a = (ore_array_t*) v.v.a->p;
    int n = 0;
    ore_array_iter_t* k;
    for (k = kl_begin(a); k != kl_end(a); k = kl_next(k)) {
      if (n == e.v.i) {
        if (update) {
          ore_value old = kl_val(k);
          ore_value_unref(old);
        }
        return &kl_val(k);
      }
      n++;
    }
    fprintf(stderr, "out of bounds for array\n");
    ore->err = ORE_ERROR_EXCEPTION;
    return NULL;
  }
  if (v.t == ORE_TYPE_HASH) {
    if (e.t != ORE_TYPE_STRING) {
      fprintf(stderr, "hash index should be string\n");
      ore->err = ORE_ERROR_EXCEPTION;
      return NULL;
    }
    ore_hash_t* h = (ore_hash_t*) v.v.h->p;
    if (update) {
      int r = 0;
      khint_t k = kh_get(value, h, e.v.s->p);
      if (k != kh_end(ore->env)) {
        ore_value old = kh_value(ore->env, k);
        ore_value_unref(old);
      }
      k = kh_put(value, h, e.v.s->p, &r);
      return &kh_value(h, k);
    } else {
      khint_t k = kh_get(value, h, e.v.s->p);
      if (k != kh_end(ore->env)) {
        return &kh_value(h, k);
      }
    }
    return NULL;
  }
  if (v.t == ORE_TYPE_OBJECT) {
    ore_context* this = (ore_context*) v.v.o->e;
    if (update) {
      int r = 0;
      khint_t k = kh_get(value, this->env, e.v.s->p);
      if (k != kh_end(ore->env)) {
        ore_value old = kh_value(ore->env, k);
        ore_value_unref(old);
      }
      k = kh_put(value, this->env, e.v.s->p, &r);
      return &kh_value(this->env, k);
    } else {
      khint_t k = kh_get(value, this->env, e.v.s->p);
      if (k != kh_end(ore->env)) {
        return &kh_value(this->env, k);
      }
    }
    return NULL;
  }
  fprintf(stderr, "invalid operation for %s\n", ore_kind(v));
  ore->err = ORE_ERROR_EXCEPTION;
  return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
leaq 0x88(%rsp), %rax
leaq 0x60(%rsp), %rcx
movl (%rcx), %edx
cmpl $0xd, %edx
je 0xe881
cmpl $0x6, %edx
je 0xe905
cmpl $0x5, %edx
jne 0xe9d2
cmpl $0x2, (%rax)
jne 0xea1a
movq 0x8(%rcx), %rcx
movq (%rcx), %r14
movq 0x8(%r14), %rcx
movl 0x8(%rax), %eax
movq (%r14), %r14
cmpq %rcx, %r14
je 0xea44
subl $0x1, %eax
jb 0xe978
addq $0x28, %r14
jmp 0xe866
movq 0x8(%rcx), %rcx
movq 0x10(%rcx), %r12
testl %esi, %esi
je 0xe9a5
movq (%r12), %r14
movq 0x8(%rax), %r13
movq (%r13), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0xa67b
movq (%rbx), %rcx
cmpl (%rcx), %eax
je 0xe8e2
movq 0x20(%rcx), %rcx
movl %eax, %eax
imulq $0x28, %rax, %rax
movq 0x20(%rcx,%rax), %rdx
movq %rdx, 0x20(%rsp)
movups (%rcx,%rax), %xmm0
movups 0x10(%rcx,%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0xa113
movq (%r12), %r14
movq (%r13), %r15
leaq 0x28(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0xa8ea
movq (%r12), %rcx
movl %eax, %eax
imulq $0x28, %rax, %r14
addq 0x20(%rcx), %r14
jmp 0xea6a
cmpl $0x4, (%rax)
jne 0xea2f
movq 0x8(%rcx), %rcx
movq (%rcx), %r15
testl %esi, %esi
je 0xe9a9
movq 0x8(%rax), %r12
movq (%r12), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0xa67b
movq (%rbx), %rcx
cmpl (%rcx), %eax
je 0xe966
movq 0x20(%rcx), %rcx
movl %eax, %eax
imulq $0x28, %rax, %rax
movq 0x20(%rcx,%rax), %rdx
movq %rdx, 0x20(%rsp)
movups (%rcx,%rax), %xmm0
movups 0x10(%rcx,%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0xa113
movq (%r12), %r14
leaq 0x2c(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0xa8ea
jmp 0xe9c3
testl %esi, %esi
je 0xea6a
movq 0x20(%r14), %rax
movq %rax, 0x20(%rsp)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0xa113
jmp 0xea6a
movq (%r12), %r15
movq 0x8(%rax), %rax
movq (%rax), %rsi
movq %r15, %rdi
callq 0xa67b
movq (%rbx), %rcx
cmpl (%rcx), %eax
je 0xea67
movl %eax, %eax
imulq $0x28, %rax, %r14
addq 0x20(%r15), %r14
jmp 0xea6a
movq 0x961f(%rip), %rax      # 0x17ff8
movq (%rax), %r15
movq 0x20(%rcx), %rax
movq %rax, 0x20(%rsp)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0xea7b
leaq 0x3519(%rip), %rsi      # 0x11f1a
xorl %r14d, %r14d
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2160
movl $0x1, 0x20(%rbx)
jmp 0xea6a
movq 0x95d7(%rip), %rax      # 0x17ff8
movq (%rax), %rcx
leaq 0x353e(%rip), %rdi      # 0x11f69
pushq $0x1a
jmp 0xea57
movq 0x95c2(%rip), %rax      # 0x17ff8
movq (%rax), %rcx
leaq 0x355d(%rip), %rdi      # 0x11f9d
pushq $0x1c
jmp 0xea57
movq 0x95ad(%rip), %rax      # 0x17ff8
movq (%rax), %rcx
leaq 0x352f(%rip), %rdi      # 0x11f84
pushq $0x18
popq %rsi
pushq $0x1
popq %rdx
callq 0x2260
movl $0x1, 0x20(%rbx)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq