// File: /workspace/github_c_makefile_star2_O0/unixlab[P]cloudflare-udp-ping/net.c
// Function: net_connect_udp
int net_connect_udp(struct net_addr *shost, int src_port, int busy_poll)
{
	int sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if (sd < 0) {
		PFATAL("socket()");
	}

	int one = 1;
	int r = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *)&one,
			   sizeof(one));
	if (r < 0) {
		PFATAL("setsockopt(SO_REUSEADDR)");
	}

	if (busy_poll) {
		r = setsockopt(sd, SOL_SOCKET, SO_BUSY_POLL, (char *)&busy_poll,
			       sizeof(busy_poll));
		if (r < 0) {
			PFATAL("setsockopt(SO_BUSY_POLL)");
		}
	}

	one = 1;
	r = setsockopt(sd, SOL_SOCKET, SO_TIMESTAMPNS, (char *)&one,
		       sizeof(one));
	if (r < 0) {
		PFATAL("setsockopt(SO_TIMESTAMPNS)");
	}

	if (src_port > 1 && src_port < 65536) {
		struct net_addr src;
		memset(&src, 0, sizeof(struct net_addr));
		char buf[32];
		snprintf(buf, sizeof(buf), "0.0.0.0:%d", src_port);
		parse_addr(&src, buf);
		if (bind(sd, src.sockaddr, src.sockaddr_len) < 0) {
			PFATAL("bind()");
		}
	}

	if (-1 == connect(sd, shost->sockaddr, shost->sockaddr_len)) {
		/* is non-blocking, so we don't get error at that point yet */
		if (EINPROGRESS != errno) {
			PFATAL("connect()");
			return -1;
		}
	}

	return sd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl $0x2, %esi
movl $0x11, %edx
movl %esi, %edi
callq 0x460080
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jge 0x403213
jmp 0x4031a1
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb21e7(%rip), %rsi     # 0x4b5399
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb1f01(%rip), %rsi     # 0x4b50cb
leaq 0xb2313(%rip), %rdx     # 0x4b54e4
leaq 0xb211c(%rip), %rcx     # 0x4b52f4
movl $0x101, %r8d            # imm = 0x101
movb $0x0, %al
callq 0x40df10
leaq 0xb1f11(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2908(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
movl $0x1, -0x20(%rbp)
movl -0x1c(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x20(%rbp), %rcx
movl $0x4, %r8d
callq 0x460040
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x4032b3
jmp 0x403241
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2170(%rip), %rsi     # 0x4b53c2
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb1e61(%rip), %rsi     # 0x4b50cb
leaq 0xb2273(%rip), %rdx     # 0x4b54e4
leaq 0xb207c(%rip), %rcx     # 0x4b52f4
movl $0x108, %r8d            # imm = 0x108
movb $0x0, %al
callq 0x40df10
leaq 0xb1e71(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2868(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
cmpl $0x0, -0x18(%rbp)
je 0x403358
movl -0x1c(%rbp), %edi
movl $0x1, %esi
movl $0x2e, %edx
leaq -0x18(%rbp), %rcx
movl $0x4, %r8d
callq 0x460040
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x403356
jmp 0x4032e4
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2169(%rip), %rsi     # 0x4b545e
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb1dbe(%rip), %rsi     # 0x4b50cb
leaq 0xb21d0(%rip), %rdx     # 0x4b54e4
leaq 0xb1fd9(%rip), %rcx     # 0x4b52f4
movl $0x10f, %r8d            # imm = 0x10F
movb $0x0, %al
callq 0x40df10
leaq 0xb1dce(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb27c5(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
jmp 0x403358
movl $0x1, -0x20(%rbp)
movl -0x1c(%rbp), %edi
movl $0x1, %esi
movl $0x23, %edx
leaq -0x20(%rbp), %rcx
movl $0x4, %r8d
callq 0x460040
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jge 0x4033f8
jmp 0x403386
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb215d(%rip), %rsi     # 0x4b54f4
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb1d1c(%rip), %rsi     # 0x4b50cb
leaq 0xb212e(%rip), %rdx     # 0x4b54e4
leaq 0xb1f37(%rip), %rcx     # 0x4b52f4
movl $0x117, %r8d            # imm = 0x117
movb $0x0, %al
callq 0x40df10
leaq 0xb1d2c(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2723(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
cmpl $0x1, -0x14(%rbp)
jle 0x4034d6
cmpl $0x10000, -0x14(%rbp)   # imm = 0x10000
jge 0x4034d6
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x4010a8
leaq -0x90(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl $0x20, %esi
leaq 0xb20ed(%rip), %rdx     # 0x4b5522
movb $0x0, %al
callq 0x40e0a0
leaq -0x90(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x402510
movl -0x1c(%rbp), %edi
movq -0x38(%rbp), %rsi
movl -0x30(%rbp), %edx
callq 0x45fdb0
cmpl $0x0, %eax
jge 0x4034d4
jmp 0x403462
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb1fd1(%rip), %rsi     # 0x4b5444
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb1c40(%rip), %rsi     # 0x4b50cb
leaq 0xb2052(%rip), %rdx     # 0x4b54e4
leaq 0xb1e5b(%rip), %rcx     # 0x4b52f4
movl $0x121, %r8d            # imm = 0x121
movb $0x0, %al
callq 0x40df10
leaq 0xb1c50(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2647(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
jmp 0x4034d6
movl -0x1c(%rbp), %edi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x45fde0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x403583
callq 0x406610
movq %rax, %rcx
movl $0x73, %eax
cmpl (%rcx), %eax
je 0x403581
jmp 0x40350f
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb200d(%rip), %rsi     # 0x4b552d
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb1b93(%rip), %rsi     # 0x4b50cb
leaq 0xb1fa5(%rip), %rdx     # 0x4b54e4
leaq 0xb1dae(%rip), %rcx     # 0x4b52f4
movl $0x128, %r8d            # imm = 0x128
movb $0x0, %al
callq 0x40df10
leaq 0xb1ba3(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb259a(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
jmp 0x403583
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)