// File: /workspace/github_c_makefile_star2_O2/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 0x2d9a
leaq 0x528e(%rip), %rsi      # 0x8004
leaq 0x52c3(%rip), %rdx      # 0x8040
leaq 0x5325(%rip), %r8       # 0x80a9
xorl %r14d, %r14d
xorl %edi, %edi
movl $0xa5, %ecx
xorl %eax, %eax
callq 0x403f
jmp 0x2ee5
movq %r8, %r12
movq %rdx, %r14
movq %rsi, %r13
movl %edi, %r15d
movq %r9, (%rsp)
callq 0x24e0
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 0x2e46
callq 0x2600
movq %rax, %r14
movq %rax, %rdi
callq 0x2320
testl %eax, %eax
je 0x2e7f
movq %r14, %rdi
movq %r12, %rsi
movq (%rsp), %r15
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x2420
testl %eax, %eax
je 0x2eaf
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x2220
testl %eax, %eax
jne 0x2ee5
leaq 0x51d8(%rip), %rsi      # 0x8004
leaq 0x520d(%rip), %rdx      # 0x8040
leaq 0x5416(%rip), %r8       # 0x8250
xorl %edi, %edi
movl $0xc1, %ecx
jmp 0x2ecb
callq 0x2450
movq %rax, %r14
movq %rax, %rdi
callq 0x2320
testl %eax, %eax
jne 0x2ee5
leaq 0x519f(%rip), %rsi      # 0x8004
leaq 0x51d4(%rip), %rdx      # 0x8040
leaq 0x5415(%rip), %r8       # 0x8288
xorl %r14d, %r14d
xorl %edi, %edi
movl $0xc9, %ecx
jmp 0x2e9e
leaq 0x517e(%rip), %rsi      # 0x8004
leaq 0x51b3(%rip), %rdx      # 0x8040
leaq 0x5333(%rip), %r8       # 0x81c7
xorl %r14d, %r14d
xorl %edi, %edi
movl $0xb2, %ecx
xorl %eax, %eax
callq 0x403f
movq %rbx, %rdi
callq 0x25e0
jmp 0x2ee5
leaq 0x514e(%rip), %rsi      # 0x8004
leaq 0x5183(%rip), %rdx      # 0x8040
leaq 0x534f(%rip), %r8       # 0x8213
xorl %edi, %edi
movl $0xb9, %ecx
xorl %eax, %eax
callq 0x403f
movq %r14, %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x25e0
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq