// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/ev.c
// Function: add_timeout
static void add_timeout(JanetTimeout to) {
    size_t oldcount = janet_vm.tq_count;
    size_t newcount = oldcount + 1;
    if (newcount > janet_vm.tq_capacity) {
        size_t newcap = 2 * newcount;
        JanetTimeout *tq = janet_realloc(janet_vm.tq, newcap * sizeof(JanetTimeout));
        if (NULL == tq) {
            JANET_OUT_OF_MEMORY;
        }
        janet_vm.tq = tq;
        janet_vm.tq_capacity = newcap;
    }
    /* Append */
    janet_vm.tq_count = (int32_t) newcount;
    janet_vm.tq[oldcount] = to;
    /* Heapify */
    size_t index = oldcount;
    while (index > 0) {
        size_t parent = (index - 1) >> 1;
        if (janet_vm.tq[parent].when <= janet_vm.tq[index].when) break;
        /* Swap */
        JanetTimeout tmp = janet_vm.tq[index];
        janet_vm.tq[index] = janet_vm.tq[parent];
        janet_vm.tq[parent] = tmp;
        /* Next */
        index = parent;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
leaq 0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x220(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq 0x228(%rcx), %rax
jbe 0x2be14
movq -0x10(%rbp), %rax
shlq %rax
movq %rax, -0x18(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x248(%rax), %rdi
imulq $0x30, -0x18(%rbp), %rsi
callq 0x12840
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpq -0x20(%rbp), %rax
jne 0x2bdce
jmp 0x2bda0
movq 0x84249(%rip), %rax     # 0xafff0
movq (%rax), %rdi
leaq 0x52253(%rip), %rsi     # 0x7e004
leaq 0x5bac0(%rip), %rdx     # 0x87878
movl $0xf2, %ecx
movb $0x0, %al
callq 0x125f0
movl $0x1, %edi
callq 0x12a70
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq -0x80(%rbp), %rcx
movq %rcx, 0x248(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x228(%rax)
movq -0x10(%rbp), %rax
cltq
movq %rax, -0x88(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq -0x88(%rbp), %rcx
movq %rcx, 0x220(%rax)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq -0x70(%rbp), %rsi
movq 0x248(%rax), %rdi
imulq $0x30, -0x8(%rbp), %rax
addq %rax, %rdi
movl $0x30, %edx
callq 0x12680
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jbe 0x2bfa7
movq -0x28(%rbp), %rax
subq $0x1, %rax
shrq %rax
movq %rax, -0x30(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x248(%rax), %rax
imulq $0x30, -0x30(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq 0x248(%rcx), %rcx
imulq $0x30, -0x28(%rbp), %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jg 0x2beea
jmp 0x2bfa7
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x248(%rax), %rsi
imulq $0x30, -0x28(%rbp), %rax
addq %rax, %rsi
leaq -0x60(%rbp), %rdi
movl $0x30, %edx
callq 0x12680
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x248(%rax), %rax
imulq $0x30, -0x28(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq -0x98(%rbp), %rdi
movq 0x248(%rax), %rsi
imulq $0x30, -0x30(%rbp), %rax
addq %rax, %rsi
movl $0x30, %edx
callq 0x12680
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x248(%rax), %rdi
imulq $0x30, -0x30(%rbp), %rax
addq %rax, %rdi
leaq -0x60(%rbp), %rsi
movl $0x30, %edx
callq 0x12680
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x2be74
addq $0xa0, %rsp
popq %rbp
retq