// File: /workspace/github_c_makefile_star2_O0/tabemann[P]attoforth/src/runtime/prim.c
// Function: af_prim_setenv
void af_prim_setenv(af_task_t* task) {
  af_global_t* global = task->global;
  char* value;
  char* name;
  af_byte_t* value_addr;
  af_cell_t value_len;
  af_byte_t* name_addr;
  af_cell_t name_len;
  int overwrite;
  int error = 0;
  AF_VERIFY_DATA_STACK_READ(task, 5);
  overwrite = *task->data_stack_current++ ? 1 : 0;
  name_len = *task->data_stack_current++;
  name_addr = (af_byte_t*)(*task->data_stack_current++);
  value_len = *task->data_stack_current++;
  value_addr = (af_byte_t*)(*task->data_stack_current);
  if(!(name = malloc(name_len + 1))) {
    af_handle_out_of_memory(global, task);
    return;
  }
  memcpy(name, name_addr, name_len);
  name[name_len] = 0;
  if(!(value = malloc(value_len + 1))) {
    free(name);
    af_handle_out_of_memory(global, task);
    return;
  }
  memcpy(value, value_addr, value_len);
  value[value_len] = 0;
  if(setenv(name, value, overwrite)) {
    error = errno;
  }
  free(value);
  free(name);
  *task->data_stack_current = error;
  AF_ADVANCE_IP(task, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rcx
movq 0x60(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x60(%rcx)
movq (%rax), %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovnel %ecx, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rcx
movq 0x60(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x60(%rcx)
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rcx
movq 0x60(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x60(%rcx)
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rcx
movq 0x60(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x60(%rcx)
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rdi
addq $0x1, %rdi
callq 0x21f0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x13e6b
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x44e0
jmp 0x13f50
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x21c0
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x30(%rbp), %rdi
addq $0x1, %rdi
callq 0x21f0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x13eba
movq -0x20(%rbp), %rdi
callq 0x2040
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x44e0
jmp 0x13f50
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x21c0
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x44(%rbp), %edx
callq 0x20d0
cmpl $0x0, %eax
je 0x13ef6
callq 0x2060
movl (%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2040
movq -0x20(%rbp), %rdi
callq 0x2040
movslq -0x48(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x13f3c
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rax
addq $0x8, %rax
movq %rax, -0x58(%rbp)
jmp 0x13f44
xorl %eax, %eax
movq %rax, -0x58(%rbp)
jmp 0x13f44
movq -0x58(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x58(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)