// File: /workspace/github_c_makefile_star2_O0/tabemann[P]attoforth/src/runtime/prim.c
// Function: af_prim_format_2number
void af_prim_format_2number(af_task_t* task) {
  af_byte_t buffer[128];
  af_byte_t* current = buffer + sizeof(buffer);
  af_cell_t length = 0;
  af_2cell_t value;
  af_bool_t negative = FALSE;
  AF_VERIFY_DATA_STACK_READ(task, 2);
  AF_LOAD_2CELL(task, 0, value);
  if(value == 0) {
    *(--current) = '0';
    length++;
  } else if(task->base == 10) {
    af_sign_2cell_t signed_value = (af_sign_2cell_t)value;
    if(signed_value < 0) {
      negative = TRUE;
      value = (af_2cell_t)(-signed_value);
    }
    while(value > 0) {
      af_byte_t part = value % 10;
      part += '0';
      value /= 10;
      *(--current) = part;
      length++;
    }
    if(negative) {
      *(--current) = '-';
      length++;
    }
  } else if(task->base >= 2 && task->base <= 36) {
    while(value > 0) {
      af_byte_t part = value % task->base;
      if(part < 10) {
	part += '0';
      } else {
	part += 'A' - 10;
      }
      value /= task->base;
      *(--current) = part;
      length++;
    }
  }
  memcpy(task->data_space_current, current, length);
  *(task->data_stack_current + 1) = (af_cell_t)task->data_space_current;
  *task->data_stack_current = length;
  AF_ADVANCE_IP(task, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
leaq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xb8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq -0xc0(%rbp), %rax
movq 0x60(%rax), %rax
movq -0xc8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xe0(%rbp)
movq $0x0, -0xd8(%rbp)
movq -0xc0(%rbp), %rax
movq 0x60(%rax), %rax
movq -0xc8(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0xf0(%rbp)
movq $0x0, -0xe8(%rbp)
movq -0xf0(%rbp), %rcx
movq -0xe8(%rbp), %rax
movq -0xe0(%rbp), %rdx
orq %rdx, %rax
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
movq -0xb0(%rbp), %rax
movq -0xa8(%rbp), %rcx
orq %rcx, %rax
jne 0x11b92
jmp 0x11b62
movq -0x98(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x98(%rbp)
movb $0x30, -0x1(%rax)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x11e94
movq -0x8(%rbp), %rax
cmpq $0xa, 0xf0(%rax)
jne 0x11d94
movq -0xb0(%rbp), %rax
movq -0xa8(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
movq %rax, -0x100(%rbp)
movq -0xf8(%rbp), %rax
testq %rax, %rax
jns 0x11bfd
jmp 0x11bce
movq $-0x1, -0xb8(%rbp)
movq -0x100(%rbp), %rcx
movq -0xf8(%rbp), %rdx
xorl %eax, %eax
negq %rcx
sbbq %rdx, %rax
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
jmp 0x11bff
movq -0xb0(%rbp), %rax
movq -0xa8(%rbp), %rcx
orq %rcx, %rax
je 0x11d5a
jmp 0x11c18
movq -0xb0(%rbp), %rdx
movq %rdx, -0x138(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, %rcx
shrq %rcx
shldq $0x3f, %rdx, %rax
addq %rcx, %rax
adcq $0x0, %rax
movl %eax, %ecx
movl %ecx, -0x12c(%rbp)
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
mulq %rsi
movq -0x138(%rbp), %rax
movq %rdx, %rcx
movl -0x12c(%rbp), %edx
shrq $0x2, %rcx
movl %ecx, %edi
movl %edi, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %edx
movl %edx, %ecx
movl %eax, %edx
andl $0x1, %edx
movl %edx, %eax
leal (%rax,%rcx,2), %eax
movb %al, -0x101(%rbp)
movb -0x101(%rbp), %al
addb $0x30, %al
movb %al, -0x101(%rbp)
movq -0xb0(%rbp), %rdx
movq -0xa8(%rbp), %rax
movq %rax, %rcx
shrq %rcx
shldq $0x3f, %rdx, %rax
movq %rax, -0x128(%rbp)
addq %rcx, %rax
adcq $0x0, %rax
movq %rax, -0x120(%rbp)
mulq %rsi
movq -0x128(%rbp), %rax
movq %rdx, %rdi
movq -0x120(%rbp), %rdx
shrq $0x2, %rdi
leaq (%rdi,%rdi,4), %rdi
subq %rdi, %rdx
subq %rdx, %rax
sbbq $0x0, %rcx
movq %rcx, -0x118(%rbp)
movabsq $-0x3333333333333334, %rcx # imm = 0xCCCCCCCCCCCCCCCC
movq %rax, %rdi
imulq %rcx, %rdi
mulq %rsi
movq %rax, %rcx
movq %rdx, %rax
movq -0x118(%rbp), %rdx
addq %rdi, %rax
imulq %rsi, %rdx
addq %rdx, %rax
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
movb -0x101(%rbp), %cl
movq -0x98(%rbp), %rax
movq %rax, %rdx
addq $-0x1, %rdx
movq %rdx, -0x98(%rbp)
movb %cl, -0x1(%rax)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x11bff
cmpq $0x0, -0xb8(%rbp)
je 0x11d8f
movq -0x98(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x98(%rbp)
movb $0x2d, -0x1(%rax)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x11e92
movq -0x8(%rbp), %rax
cmpq $0x2, 0xf0(%rax)
jb 0x11e90
movq -0x8(%rbp), %rax
cmpq $0x24, 0xf0(%rax)
ja 0x11e90
jmp 0x11dba
movq -0xb0(%rbp), %rax
movq -0xa8(%rbp), %rcx
orq %rcx, %rax
je 0x11e8e
jmp 0x11dd3
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0xf0(%rax), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x19d90
movb %al, -0x102(%rbp)
movzbl -0x102(%rbp), %eax
cmpl $0xa, %eax
jge 0x11e19
movzbl -0x102(%rbp), %eax
addl $0x30, %eax
movb %al, -0x102(%rbp)
jmp 0x11e29
movzbl -0x102(%rbp), %eax
addl $0x37, %eax
movb %al, -0x102(%rbp)
movq -0x8(%rbp), %rax
movq 0xf0(%rax), %rdx
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
callq 0x19c90
movq %rdx, -0xa8(%rbp)
movq %rax, -0xb0(%rbp)
movb -0x102(%rbp), %cl
movq -0x98(%rbp), %rax
movq %rax, %rdx
addq $-0x1, %rdx
movq %rdx, -0x98(%rbp)
movb %cl, -0x1(%rax)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x11dba
jmp 0x11e90
jmp 0x11e92
jmp 0x11e94
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rdi
movq -0x98(%rbp), %rsi
movq -0xa0(%rbp), %rdx
callq 0x21c0
movq -0x8(%rbp), %rax
movq 0xc8(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0xa0(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x11f0c
movq -0x110(%rbp), %rax
movq 0x58(%rax), %rax
addq $0x8, %rax
movq %rax, -0x140(%rbp)
jmp 0x11f17
xorl %eax, %eax
movq %rax, -0x140(%rbp)
jmp 0x11f17
movq -0x140(%rbp), %rcx
movq -0x110(%rbp), %rax
movq %rcx, 0x58(%rax)
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw %cs:(%rax,%rax)