// File: /workspace/github_c_makefile_star2_O1/xiaowenhuyuehu[P]remote_access/src/connectivity/ws_nopoll.c
// Function: ws_nopoll_listener
noPollConn *ws_nopoll_listener(const int debug_on, const char *host, const char *port, const int tls_on, const char *server_crt, const char *private_key)
{
    noPollCtx  *ctx = NULL;
	noPollConn *listener = NULL;
    nopoll_bool debug = (nopoll_bool)debug_on;

    if (NULL == host || NULL == port) {
        log_debug("host or port is NULL ");
        return NULL;
    }

    /* create context */
    ctx = nopoll_ctx_new ();
    nopoll_log_enable (ctx, debug);
    nopoll_log_color_enable (ctx, debug);

    if (1 == tls_on) {
    	/* now start a TLS version */
    	listener = nopoll_listener_tls_new (ctx, host, port);
    	if (!nopoll_conn_is_ok (listener)) {
    		log_debug("ERROR: Expected to find proper listener TLS connection status, but found.. ");
    		nopoll_ctx_unref(ctx);
    		return NULL;
    	}

    	/* configure certificates to be used by this listener */
    	if (!nopoll_listener_set_certificate (listener, server_crt, private_key, NULL)) {
    		log_debug("ERROR: unable to configure certificates for TLS websocket.. ");
            nopoll_conn_close (listener);
            nopoll_ctx_unref(ctx);
    		return NULL;
    	}

    	/* register certificates at context level */
    	if (! nopoll_ctx_set_certificate (ctx, NULL, server_crt, private_key, NULL)) {
    		log_debug("ERROR: unable to setup certificates at context level.. ");
            nopoll_conn_close (listener);
            nopoll_ctx_unref(ctx);
    		return NULL;
    	}
	} else {
        listener = nopoll_listener_new (ctx, host, port);
        if (!nopoll_conn_is_ok (listener)) {
            log_debug ("ERROR: Expected to find proper listener connection status, but found.. ");
    		nopoll_ctx_unref(ctx);
            return NULL;
        }
	}

    return listener;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
testq %rsi, %rsi
setne %al
testq %rdx, %rdx
setne %cl
testb %cl, %al
jne 0x2ef8
leaq 0x6130(%rip), %rsi      # 0x9004
leaq 0x6165(%rip), %rdx      # 0x9040
leaq 0x61c7(%rip), %r8       # 0x90a9
xorl %r14d, %r14d
xorl %edi, %edi
movl $0xa5, %ecx
xorl %eax, %eax
callq 0x4371
jmp 0x3043
movq %r8, %r12
movq %rdx, %r14
movq %rsi, %r13
movl %edi, %r15d
movq %r9, (%rsp)
callq 0x24d0
movq %rax, %rbx
movq %rax, %rdi
movl %r15d, %esi
callq 0x22e0
movq %rbx, %rdi
movl %r15d, %esi
callq 0x2390
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
cmpl $0x1, %ebp
jne 0x2fa4
callq 0x25f0
movq %rax, %r14
movq %rax, %rdi
callq 0x2320
testl %eax, %eax
je 0x2fdd
movq %r14, %rdi
movq %r12, %rsi
movq (%rsp), %r15
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x2420
testl %eax, %eax
je 0x300d
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x2220
testl %eax, %eax
jne 0x3043
leaq 0x607a(%rip), %rsi      # 0x9004
leaq 0x60af(%rip), %rdx      # 0x9040
leaq 0x62b8(%rip), %r8       # 0x9250
xorl %edi, %edi
movl $0xc1, %ecx
jmp 0x3029
callq 0x2450
movq %rax, %r14
movq %rax, %rdi
callq 0x2320
testl %eax, %eax
jne 0x3043
leaq 0x6041(%rip), %rsi      # 0x9004
leaq 0x6076(%rip), %rdx      # 0x9040
leaq 0x62b7(%rip), %r8       # 0x9288
xorl %r14d, %r14d
xorl %edi, %edi
movl $0xc9, %ecx
jmp 0x2ffc
leaq 0x6020(%rip), %rsi      # 0x9004
leaq 0x6055(%rip), %rdx      # 0x9040
leaq 0x61d5(%rip), %r8       # 0x91c7
xorl %r14d, %r14d
xorl %edi, %edi
movl $0xb2, %ecx
xorl %eax, %eax
callq 0x4371
movq %rbx, %rdi
callq 0x25d0
jmp 0x3043
leaq 0x5ff0(%rip), %rsi      # 0x9004
leaq 0x6025(%rip), %rdx      # 0x9040
leaq 0x61f1(%rip), %r8       # 0x9213
xorl %edi, %edi
movl $0xb9, %ecx
xorl %eax, %eax
callq 0x4371
movq %r14, %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x25d0
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq