// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/main.c
// Function: req_send_result
static int req_send_result(req_t* req, ns_msg_t* msg)
{
	int len, r;

	msg->id = req->msg->id;

	if (req->fromtcp) {
		peer_t* peer = req->from;
		stream_t* ws = &peer->conn.ws;
		int pos = ws->pos,
			start = ws->size;

		ws->pos = start;

		stream_writei16(ws, 0);

		if ((len = ns_serialize(ws, msg, 0)) <= 0) {
			loge("ns_serialize() error\n");
			ws->pos = pos;
			ws->size = start;
			return -1;
		}

		stream_seti16(ws, start, len);

		ws->pos = pos;

		if (loglevel > LOG_DEBUG) {
			bprint(ws->array + ws->pos, stream_rsize(ws));
		}

		r = tcp_send(peer->conn.sock, ws);
		if (r < 0)
			return -1;
	}
	else {
		stream_t s = STREAM_INIT();
		struct sockaddr* to = (struct sockaddr*)req->from;
		int tolen = req->fromlen;
		listen_t* listen = listens + req->listen;

		if ((len = ns_serialize(&s, msg, 0)) <= 0) {
			loge("ns_serialize() error\n");
			stream_free(&s);
			return -1;
		}

		s.pos = 0;

		if (loglevel > LOG_DEBUG) {
			bprint(s.array, s.size);
		}

		r = udp_send(listen->usock, &s, to, tolen);
		stream_free(&s);
		if (r < 0)
			return -1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movw (%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x32e3d
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2dc90
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %edx, %edx
callq 0x29ec0
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jg 0x32db3
jmp 0x32d5f
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x32d91
movl $0x3, %edi
leaq 0x5e4b(%rip), %rsi      # 0x38bc2
leaq 0x6d58(%rip), %rdx      # 0x39ad6
movl $0x16d, %ecx            # imm = 0x16D
leaq 0x2fd8(%rip), %r8       # 0x35d62
movb $0x0, %al
callq 0x243b0
jmp 0x32d93
movl -0x34(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x38(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x32f4e
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x1c(%rbp), %edx
movl $0x2, %ecx
callq 0x2de60
movl -0x34(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jle 0x32e14
jmp 0x32ddf
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jl 0x32e10
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movslq 0xc(%rax), %rax
addq %rax, %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x30(%rbp), %rax
subl 0xc(%rax), %esi
callq 0x2e3d0
jmp 0x32e12
jmp 0x32e14
movq -0x28(%rbp), %rax
movl (%rax), %edi
movq -0x30(%rbp), %rsi
callq 0x265a0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x32e38
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x32f4e
jmp 0x32f47
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x3200
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rcx
leaq 0xfc1e(%rip), %rax      # 0x42a90
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdi
xorl %edx, %edx
callq 0x29ec0
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jg 0x32edf
jmp 0x32e99
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x32ecb
movl $0x3, %edi
leaq 0x5d11(%rip), %rsi      # 0x38bc2
leaq 0x6c1e(%rip), %rdx      # 0x39ad6
movl $0x186, %ecx            # imm = 0x186
leaq 0x2e9e(%rip), %r8       # 0x35d62
movb $0x0, %al
callq 0x243b0
jmp 0x32ecd
leaq -0x50(%rbp), %rdi
callq 0x2d640
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x32f4e
movl $0x0, -0x44(%rbp)
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jle 0x32f10
jmp 0x32ef4
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jl 0x32f0c
movq -0x50(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x2e3d0
jmp 0x32f0e
jmp 0x32f10
movq -0x68(%rbp), %rax
movl 0x8c(%rax), %edi
movq -0x58(%rbp), %rdx
movl -0x5c(%rbp), %ecx
leaq -0x50(%rbp), %rsi
callq 0x26880
movl %eax, -0x20(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x2d640
cmpl $0x0, -0x20(%rbp)
jge 0x32f45
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x32f4e
jmp 0x32f47
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)