// File: Ciaxur[P]yagb-emu/include/imgui/imstb_textedit.h
// Function: ImStb::stb_textedit_discard_redo(ImStb::StbUndoState*)
static void stb_textedit_discard_redo(StbUndoState *state)
{
   int k = STB_TEXTEDIT_UNDOSTATECOUNT-1;

   if (state->redo_point <= k) {
      // if the k'th undo state has characters, clean those up
      if (state->undo_rec[k].char_storage >= 0) {
         int n = state->undo_rec[k].insert_length, i;
         // move the remaining redo character data to the end of the buffer
         state->redo_char_point += n;
         STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
         // adjust the position of all the other records to account for above memmove
         for (i=state->redo_point; i < k; ++i)
            if (state->undo_rec[i].char_storage >= 0)
               state->undo_rec[i].char_storage += n;
      }
      // now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
      // [DEAR IMGUI]
      size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
      const char* buf_begin = (char*)state->undo_rec; (void)buf_begin;
      const char* buf_end   = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
      IM_ASSERT(((char*)(state->undo_rec + state->redo_point)) >= buf_begin);
      IM_ASSERT(((char*)(state->undo_rec + state->redo_point + 1) + move_size) <= buf_end);
      STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, move_size);

      // now move redo_point to point to the new one
      ++state->redo_point;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl $0x62, -0xc(%rbp)
movq -0x8(%rbp), %rax
movswl 0xe00(%rax), %eax
cmpl -0xc(%rbp), %eax
jg 0x15a10b
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jl 0x159ffb
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0xe08(%rax), %ecx
movl %ecx, 0xe08(%rax)
movq -0x8(%rbp), %rdi
addq $0x630, %rdi            # imm = 0x630
movq -0x8(%rbp), %rax
movslq 0xe08(%rax), %rax
shlq %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
addq $0x630, %rsi            # imm = 0x630
movq -0x8(%rbp), %rax
movslq 0xe08(%rax), %rax
shlq %rax
addq %rax, %rsi
movslq -0x10(%rbp), %rcx
xorl %eax, %eax
subq %rcx, %rax
shlq %rax
addq %rax, %rsi
movq -0x8(%rbp), %rcx
movl $0x3e7, %eax            # imm = 0x3E7
subl 0xe08(%rcx), %eax
movslq %eax, %rdx
shlq %rdx
callq 0xd170
movq -0x8(%rbp), %rax
movswl 0xe00(%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x159ff9
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jl 0x159fec
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
jmp 0x159fee
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x159fb7
jmp 0x159ffb
movq -0x8(%rbp), %rax
movswl 0xe00(%rax), %ecx
movl $0x63, %eax
subl %ecx, %eax
subl $0x1, %eax
cltq
shlq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
addq $0x630, %rax            # imm = 0x630
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movswl 0xe00(%rcx), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpq -0x28(%rbp), %rax
jb 0x15a051
jmp 0x15a070
leaq 0x365ea(%rip), %rdi     # 0x190642
leaq 0x3661f(%rip), %rsi     # 0x19067e
movl $0x492, %edx            # imm = 0x492
leaq 0x36632(%rip), %rcx     # 0x19069d
callq 0xd180
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movswl 0xe00(%rcx), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $0x10, %rax
addq -0x20(%rbp), %rax
cmpq -0x30(%rbp), %rax
ja 0x15a099
jmp 0x15a0b8
leaq 0x36633(%rip), %rdi     # 0x1906d3
leaq 0x365d7(%rip), %rsi     # 0x19067e
movl $0x493, %edx            # imm = 0x493
leaq 0x365ea(%rip), %rcx     # 0x19069d
callq 0xd180
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movswl 0xe00(%rax), %eax
cltq
shlq $0x4, %rax
addq %rax, %rdi
addq $0x10, %rdi
movq -0x8(%rbp), %rsi
movq -0x8(%rbp), %rax
movswl 0xe00(%rax), %eax
cltq
shlq $0x4, %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
callq 0xd170
movq -0x8(%rbp), %rax
movw 0xe00(%rax), %cx
addw $0x1, %cx
movw %cx, 0xe00(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)