// File: /workspace/github_c_makefile_star2_O2/tabemann[P]attoforth/src/runtime/inner.c
// Function: af_spawn
af_task_t* af_spawn(af_global_t* global, af_task_t* parent_task) {
  af_cell_t* data_stack_top;
  af_float_t* float_stack_top;
  af_compiled_t** return_stack_top;
  af_cell_t* data_space_base;
  af_wordlist_t** wordlist_order;
  void* task_local_space_base;
  af_task_t* task;
  
  if(!(data_stack_top = malloc(global->default_data_stack_count *
			       sizeof(af_cell_t)))) {
    return NULL;
  }
  if(!(float_stack_top = malloc(global->default_float_stack_count *
				sizeof(af_float_t)))) {
    free(data_stack_top);
    return NULL;
  }
  if(!(return_stack_top = malloc(global->default_return_stack_count *
				 sizeof(af_compiled_t*)))) {
    free(float_stack_top);
    free(data_stack_top);
    return NULL;
  }
  if(!(data_space_base = malloc(global->default_data_space_size *
				sizeof(af_cell_t)))) {
    free(return_stack_top);
    free(float_stack_top);
    free(data_stack_top);
    return NULL;
  }
  if(!(wordlist_order = malloc(global->default_wordlist_order_max_count *
			       sizeof(af_wordlist_t*)))) {
    free(data_space_base);
    free(return_stack_top);
    free(float_stack_top);
    free(data_stack_top);
    return NULL;
  }
  if(!(task_local_space_base = malloc(global->task_local_space_size *
					sizeof(af_byte_t)))) {
    free(wordlist_order);
    free(data_space_base);
    free(return_stack_top);
    free(float_stack_top);
    free(data_stack_top);
    return NULL;
  }
  if(!(task = malloc(sizeof(af_task_t)))) {
    free(task_local_space_base);
    free(wordlist_order);
    free(data_space_base);
    free(return_stack_top);
    free(float_stack_top);
    free(data_stack_top);
    return NULL;
  }
  memcpy(task_local_space_base, global->default_task_local_space_base,
	 global->task_local_space_size * sizeof(af_byte_t));
  task->global = global;
  task->next_task = global->first_task;
  global->first_task = task;
  task->base_cycles_before_yield = 0;
  task->extra_cycles = 0;
  task->current_cycles_before_yield = 0;
  task->current_cycles_left = 0;
  task->yields = 0;
  task->is_compiling = FALSE;
  task->is_to_be_freed = FALSE;
  task->interpreter_pointer = NULL;
  task->data_stack_current = task->data_stack_base =
    (data_stack_top + global->default_data_stack_count) -
    global->default_data_stack_base_room_count;
  task->float_stack_current = task->float_stack_base =
    (float_stack_top + global->default_float_stack_count) -
    global->default_float_stack_base_room_count;
  task->return_stack_current = task->return_stack_base =
    (return_stack_top + global->default_return_stack_count) -
    global->default_return_stack_base_room_count;
  task->data_stack_top = data_stack_top;
  task->float_stack_top = float_stack_top;
  task->return_stack_top = return_stack_top;
  task->data_space_current = task->data_space_base =
    data_space_base;
  task->data_space_top =
    data_space_base + global->default_data_space_size;
  task->task_local_space_base = task_local_space_base;
  task->wordlist_order_max_count = global->default_wordlist_order_max_count;
  task->wordlist_order = wordlist_order;
  if(parent_task) {
    memcpy(task->wordlist_order, parent_task->wordlist_order,
	  parent_task->wordlist_order_count);
    task->wordlist_order_count = parent_task->wordlist_order_count;
    task->current_wordlist = parent_task->current_wordlist;
  } else {
    *task->wordlist_order = global->forth_wordlist;
    task->wordlist_order_count = 1;
    task->current_wordlist = global->forth_wordlist;
  }
  task->most_recent_word = NULL;
  task->current_input = NULL;
  task->base = 10;
  task->init_word = NULL;
  task->current_word = NULL;
  task->abort = global->default_abort;
  task->terminate = NULL;
  task->free_data_on_exit = FALSE;
  task->do_trace = FALSE;
  task->nesting_level = -1;
  global->task_count++;
  af_handle_spawn(global, task);
  return task;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r13
movq %rdi, %r14
movq 0x128(%rdi), %rbp
leaq (,%rbp,8), %rdi
callq 0x2220
testq %rax, %rax
je 0x2903
movq %rax, %rbx
movq 0x130(%r14), %r12
leaq (,%r12,8), %rdi
callq 0x2220
testq %rax, %rax
je 0x28fb
movq %rax, %r15
movq 0x138(%r14), %rax
movq %rax, 0x40(%rsp)
leaq (,%rax,8), %rdi
callq 0x2220
testq %rax, %rax
je 0x28f3
movq %rax, (%rsp)
movq 0x160(%r14), %rax
movq %rax, 0x38(%rsp)
leaq (,%rax,8), %rdi
callq 0x2220
testq %rax, %rax
je 0x28ea
movq %rax, 0x8(%rsp)
movq 0x1d0(%r14), %rax
movq %rax, 0x30(%rsp)
leaq (,%rax,8), %rdi
callq 0x2220
testq %rax, %rax
je 0x28e0
movq %rax, 0x18(%rsp)
movq 0x1d8(%r14), %rdi
movq %rdi, 0x28(%rsp)
callq 0x2220
testq %rax, %rax
je 0x28d6
movq %rax, 0x10(%rsp)
movq %r13, 0x20(%rsp)
movl $0x140, %edi            # imm = 0x140
callq 0x2220
testq %rax, %rax
je 0x28cc
movq %rax, %r13
movq 0x1e8(%r14), %rsi
movq 0x10(%rsp), %rdi
movq 0x28(%rsp), %rdx
callq 0x21f0
movq %r14, (%r13)
movq (%r14), %rax
movq %rax, 0x8(%r13)
movq %r13, (%r14)
andq $0x0, 0x58(%r13)
leaq (%rbx,%rbp,8), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%r13)
movaps %xmm0, 0x20(%r13)
movaps %xmm0, 0x30(%r13)
movaps %xmm0, 0x40(%r13)
movq 0x140(%r14), %rcx
shlq $0x3, %rcx
subq %rcx, %rax
movq %rax, 0x90(%r13)
movq %rax, 0x60(%r13)
leaq (%r15,%r12,8), %rax
movq 0x148(%r14), %rcx
shlq $0x3, %rcx
subq %rcx, %rax
movq %rax, 0x98(%r13)
movq %rax, 0x68(%r13)
movq (%rsp), %rdx
movq 0x40(%rsp), %rax
leaq (%rdx,%rax,8), %rax
movq 0x150(%r14), %rcx
shlq $0x3, %rcx
subq %rcx, %rax
movq %rax, 0xa0(%r13)
movq %rax, 0x70(%r13)
movq %rbx, 0x78(%r13)
movq %r15, 0x80(%r13)
movq %rdx, 0x88(%r13)
movq 0x8(%rsp), %rax
movq %rax, 0xd8(%r13)
movq %rax, 0xc8(%r13)
movq 0x38(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, 0xd0(%r13)
movq 0x10(%rsp), %rax
movq %rax, 0x120(%r13)
movq 0x30(%rsp), %rax
movq %rax, 0xc0(%r13)
movq 0x18(%rsp), %rdi
movq %rdi, 0xb0(%r13)
movq 0x20(%rsp), %r15
testq %r15, %r15
je 0x2918
movq 0xb0(%r15), %rsi
movq 0xb8(%r15), %rbx
movq %rbx, %rdx
callq 0x21f0
movq 0xa8(%r15), %rax
jmp 0x2925
movq 0x10(%rsp), %rdi
callq 0x2050
movq 0x18(%rsp), %rdi
callq 0x2050
movq 0x8(%rsp), %rdi
callq 0x2050
movq (%rsp), %rdi
callq 0x2050
movq %r15, %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2050
xorl %r13d, %r13d
movq %r13, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1b8(%r14), %rax
movq %rax, (%rdi)
pushq $0x1
popq %rbx
movq %rbx, 0xb8(%r13)
movq %rax, 0xa8(%r13)
xorps %xmm0, %xmm0
movaps %xmm0, 0xe0(%r13)
movq $0xa, 0xf0(%r13)
andq $0x0, 0x50(%r13)
andq $0x0, 0xf8(%r13)
movq 0x1a8(%r14), %rax
movq %rax, 0x100(%r13)
andq $0x0, 0x108(%r13)
andq $0x0, 0x118(%r13)
andq $0x0, 0x128(%r13)
orq $-0x1, 0x130(%r13)
incq 0x18(%r14)
movq %r14, %rdi
callq 0x2d87
jmp 0x2906