// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/build/c/shell.c
// Function: insert
static int insert(char c, int draw) {
    if (gbl_len < JANET_LINE_MAX - 1) {
        if (gbl_len == gbl_pos) {
            gbl_buf[gbl_pos++] = c;
            gbl_buf[++gbl_len] = '\0';
            if (draw) {
                if (gbl_plen + gbl_len < gbl_cols) {
                    /* Avoid a full update of the line in the
                     * trivial case. */
                    if (write_console(&c, 1) == -1) return -1;
                } else {
                    refresh();
                }
            }
        } else {
            memmove(gbl_buf + gbl_pos + 1, gbl_buf + gbl_pos, gbl_len - gbl_pos);
            gbl_buf[gbl_pos++] = c;
            gbl_buf[++gbl_len] = '\0';
            if (draw) refresh();
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %dil, %al
movb %al, -0x5(%rbp)
movl %esi, -0xc(%rbp)
movq %fs:0x0, %rax
leaq -0x145c(%rax), %rax
cmpl $0x3ff, (%rax)          # imm = 0x3FF
jge 0x7fdfc
movq %fs:0x0, %rax
leaq -0x145c(%rax), %rax
movl (%rax), %eax
movl %eax, -0x10(%rbp)
movq %fs:0x0, %rax
movq %rax, %rcx
movl -0x10(%rbp), %eax
leaq -0x1010(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x7fca8
movb -0x5(%rbp), %al
movb %al, -0x21(%rbp)
movq %fs:0x0, %rax
leaq -0x1450(%rax), %rax
movq %rax, -0x20(%rbp)
movq %fs:0x0, %rax
movb -0x21(%rbp), %dl
movq %rax, %rcx
movq -0x20(%rbp), %rax
leaq -0x1010(%rcx), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq %fs:0x0, %rax
leaq -0x1450(%rax), %rax
movq %rax, -0x18(%rbp)
movq %fs:0x0, %rax
movq %rax, %rcx
movq -0x18(%rbp), %rax
leaq -0x145c(%rcx), %rdx
movl (%rdx), %ecx
addl $0x1, %ecx
movl %ecx, (%rdx)
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
cmpl $0x0, -0xc(%rbp)
je 0x7fca3
movq %fs:0x0, %rax
leaq -0x1aec(%rax), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movq %fs:0x0, %rax
movq %rax, %rcx
movl -0x2c(%rbp), %eax
leaq -0x145c(%rcx), %rcx
addl (%rcx), %eax
movl %eax, -0x28(%rbp)
movq %fs:0x0, %rax
movq %rax, %rcx
movl -0x28(%rbp), %eax
leaq -0x1af0(%rcx), %rcx
cmpl (%rcx), %eax
jge 0x7fc9c
leaq -0x5(%rbp), %rdi
movl $0x1, %esi
callq 0x7fad0
cmpq $-0x1, %rax
jne 0x7fc9a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7fe03
jmp 0x7fca1
callq 0x7fe10
jmp 0x7fca3
jmp 0x7fdfa
movq %fs:0x0, %rax
leaq -0x1450(%rax), %rax
movq %rax, -0x68(%rbp)
movq %fs:0x0, %rax
movq %rax, %rcx
movq -0x68(%rbp), %rax
leaq -0x1010(%rcx), %rcx
movslq (%rcx), %rcx
addq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq %fs:0x0, %rax
leaq -0x1450(%rax), %rax
movq %rax, -0x60(%rbp)
movq %fs:0x0, %rax
movq %rax, %rcx
movq -0x60(%rbp), %rax
leaq -0x1010(%rcx), %rcx
movslq (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq %fs:0x0, %rax
leaq -0x145c(%rax), %rax
movl (%rax), %eax
movl %eax, -0x48(%rbp)
movq %fs:0x0, %rax
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq %rax, %rcx
movl -0x48(%rbp), %eax
leaq -0x1010(%rcx), %rcx
subl (%rcx), %eax
movslq %eax, %rdx
callq 0x15950
movb -0x5(%rbp), %al
movb %al, -0x41(%rbp)
movq %fs:0x0, %rax
leaq -0x1450(%rax), %rax
movq %rax, -0x40(%rbp)
movq %fs:0x0, %rax
movb -0x41(%rbp), %dl
movq %rax, %rcx
movq -0x40(%rbp), %rax
leaq -0x1010(%rcx), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq %fs:0x0, %rax
leaq -0x1450(%rax), %rax
movq %rax, -0x38(%rbp)
movq %fs:0x0, %rax
movq %rax, %rcx
movq -0x38(%rbp), %rax
leaq -0x145c(%rcx), %rdx
movl (%rdx), %ecx
addl $0x1, %ecx
movl %ecx, (%rdx)
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
cmpl $0x0, -0xc(%rbp)
je 0x7fdf8
callq 0x7fe10
jmp 0x7fdfa
jmp 0x7fdfc
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)