// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_udp.c
// Function: upstream_step
static int upstream_step(channel_t* ctx,
	fd_set* readset, fd_set* writeset, fd_set* errorset, int upstream)
{
	channel_udp_t* c = (channel_udp_t*)ctx;
	upstream_t *up = &c->upstreams[upstream];
	struct sockaddr_storage addr = { 0 };
	struct sockaddr* from = (struct sockaddr*)&addr;
	int from_len = sizeof(struct sockaddr_storage);
	int r;
	
	if (FD_ISSET(up->sock, errorset)) {
		int err = getsockerr(up->sock);
		loge("sock error: errno=%d, %s \n",
			err, strerror(err));
		return -1;
	}
	else if (FD_ISSET(up->sock, readset)) {
		r = udp_recv(up->sock, c->recv_buffer, NS_PAYLOAD_SIZE, from, &from_len);
		if (r >= 0) {
			parse_recv(c, c->recv_buffer, r, from, from_len);
		}
		else {
			int err = getsockerr(up->sock);
			loge("errno=%d, %s\n",
				err, strerror(err));
			return -1;
		}
	}

	check_expire(c);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x80, %rax
movslq -0x2c(%rbp), %rcx
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x3200
leaq -0xc0(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl $0x80, -0xcc(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x40(%rbp), %rax
movl 0x88(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0xe8(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xe0(%rbp)
movq -0x40(%rbp), %rax
movl 0x88(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xe0(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x19ef8
movq -0x40(%rbp), %rax
movl 0x88(%rax), %edi
callq 0x24f80
movl %eax, -0xd4(%rbp)
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x19eea
movl -0xd4(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0xd4(%rbp), %edi
callq 0x3150
movl -0xec(%rbp), %r9d
movl $0x3, %edi
leaq 0x1cd27(%rip), %rsi     # 0x36bf3
leaq 0x1cdf2(%rip), %rdx     # 0x36cc5
movl $0x129, %ecx            # imm = 0x129
leaq 0x1fa6f(%rip), %r8      # 0x3994e
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x19eec
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a04d
movq -0x18(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x40(%rbp), %rax
movl 0x88(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x100(%rbp), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
movq -0x40(%rbp), %rax
movl 0x88(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xf8(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x1a03b
movq -0x40(%rbp), %rax
movl 0x88(%rax), %edi
movq -0x38(%rbp), %rsi
addq $0x50c, %rsi            # imm = 0x50C
movq -0xc8(%rbp), %rcx
movl $0x400, %edx            # imm = 0x400
leaq -0xcc(%rbp), %r8
callq 0x26960
movl %eax, -0xd0(%rbp)
cmpl $0x0, -0xd0(%rbp)
jl 0x19fc5
movq -0x38(%rbp), %rdi
movq -0x38(%rbp), %rsi
addq $0x50c, %rsi            # imm = 0x50C
movl -0xd0(%rbp), %edx
movq -0xc8(%rbp), %rcx
movl -0xcc(%rbp), %r8d
callq 0x1a060
jmp 0x1a039
movq -0x40(%rbp), %rax
movl 0x88(%rax), %edi
callq 0x24f80
movl %eax, -0xd8(%rbp)
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1a02e
movl -0xd8(%rbp), %eax
movl %eax, -0x104(%rbp)
movl -0xd8(%rbp), %edi
callq 0x3150
movl -0x104(%rbp), %r9d
movl $0x3, %edi
leaq 0x1cbe3(%rip), %rsi     # 0x36bf3
leaq 0x1ccae(%rip), %rdx     # 0x36cc5
movl $0x134, %ecx            # imm = 0x134
leaq 0x1cee3(%rip), %r8      # 0x36f06
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x1a030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a04d
jmp 0x1a03b
jmp 0x1a03d
movq -0x38(%rbp), %rdi
callq 0x1a340
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopl (%rax)