// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/net.c
// Function: net_callback_accept
void net_callback_accept(JanetFiber *fiber, JanetAsyncEvent event) {
    JanetStream *stream = fiber->ev_stream;
    NetStateAccept *state = (NetStateAccept *)fiber->ev_state;
    switch (event) {
        default:
            break;
        case JANET_ASYNC_EVENT_MARK: {
            if (state->function) janet_mark(janet_wrap_function(state->function));
            break;
        }
        case JANET_ASYNC_EVENT_CLOSE:
            janet_schedule(fiber, janet_wrap_nil());
            janet_async_end(fiber);
            return;
        case JANET_ASYNC_EVENT_INIT:
        case JANET_ASYNC_EVENT_READ: {
#if defined(JANET_LINUX)
            JSock connfd = accept4(stream->handle, NULL, NULL, SOCK_CLOEXEC);
#else
            /* On BSDs, CLOEXEC should be inherited from server socket */
            JSock connfd = accept(stream->handle, NULL, NULL);
#endif
            if (JSOCKVALID(connfd)) {
                janet_net_socknoblock(connfd);
                JanetStream *stream = make_stream(connfd, JANET_STREAM_READABLE | JANET_STREAM_WRITABLE);
                Janet streamv = janet_wrap_abstract(stream);
                if (state->function) {
                    JanetFiber *sub_fiber = janet_fiber(state->function, 64, 1, &streamv);
                    sub_fiber->supervisor_channel = fiber->supervisor_channel;
                    janet_schedule(sub_fiber, janet_wrap_nil());
                } else {
                    janet_schedule(fiber, streamv);
                    janet_async_end(fiber);
                    return;
                }
            }
            break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x20(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x68(%rbp)
subq $0x6, %rax
ja 0x47beb
movq -0x68(%rbp), %rax
leaq 0x465fe(%rip), %rcx     # 0x8e1e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x47d33
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
je 0x47c1d
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movabsq $-0x2000000000000, %rsi # imm = 0xFFFE000000000000
callq 0x7b610
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x38b90
jmp 0x47d33
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0x70(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
callq 0x2b160
movq -0x8(%rbp), %rdi
callq 0x2a730
jmp 0x47d33
movq -0x18(%rbp), %rax
movl (%rax), %edi
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x80000, %ecx          # imm = 0x80000
callq 0x12330
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x47d31
movl -0x34(%rbp), %edi
callq 0x47d40
movl -0x34(%rbp), %edi
movl $0x600, %esi            # imm = 0x600
callq 0x47d90
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movabsq $-0x1000000000000, %rsi # imm = 0xFFFF000000000000
callq 0x7b610
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
je 0x47d17
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl $0x40, %esi
movl $0x1, %edx
leaq -0x50(%rbp), %rcx
callq 0x36450
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x58(%rbp), %rax
movq %rax, -0x78(%rbp)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0x78(%rbp), %rdi
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rsi
callq 0x2b160
jmp 0x47d2f
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x2b160
movq -0x8(%rbp), %rdi
callq 0x2a730
jmp 0x47d33
jmp 0x47d31
jmp 0x47d33
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)