// File: /workspace/github_c_makefile_star2_O0/unixlab[P]cloudflare-udp-ping/net.c
// Function: net_bind_tcp
int net_bind_tcp(struct net_addr *shost, int reuseport)
{
	int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
	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 (reuseport) {
		one = 1;
		r = setsockopt(sd, SOL_SOCKET, SO_REUSEPORT, (char *)&one,
			       sizeof(one));
		if (r < 0) {
			PFATAL("setsockopt(SO_REUSEPORT)");
		}
	}

	r = bind(sd, shost->sockaddr, shost->sockaddr_len);
	if (r < 0) {
		PFATAL("bind()");
	}

	r = listen(sd, 128);
	if (r < 0) {
		PFATAL("listen()");
	}

	return sd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x2, %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x460080
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jge 0x402d30
jmp 0x402cbe
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb26ca(%rip), %rsi     # 0x4b5399
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb23e4(%rip), %rsi     # 0x4b50cb
leaq 0xb279c(%rip), %rdx     # 0x4b548a
leaq 0xb25ff(%rip), %rcx     # 0x4b52f4
movl $0xba, %r8d
movb $0x0, %al
callq 0x40df10
leaq 0xb23f4(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2deb(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
movl $0x1, -0x14(%rbp)
movl -0x10(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x14(%rbp), %rcx
movl $0x4, %r8d
callq 0x460040
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x402dd0
jmp 0x402d5e
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2653(%rip), %rsi     # 0x4b53c2
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2344(%rip), %rsi     # 0x4b50cb
leaq 0xb26fc(%rip), %rdx     # 0x4b548a
leaq 0xb255f(%rip), %rcx     # 0x4b52f4
movl $0xc1, %r8d
movb $0x0, %al
callq 0x40df10
leaq 0xb2354(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2d4b(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
cmpl $0x0, -0xc(%rbp)
je 0x402e7c
movl $0x1, -0x14(%rbp)
movl -0x10(%rbp), %edi
movl $0x1, %esi
movl $0xf, %edx
leaq -0x14(%rbp), %rcx
movl $0x4, %r8d
callq 0x460040
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x402e7a
jmp 0x402e08
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb25d5(%rip), %rsi     # 0x4b53ee
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb229a(%rip), %rsi     # 0x4b50cb
leaq 0xb2652(%rip), %rdx     # 0x4b548a
leaq 0xb24b5(%rip), %rcx     # 0x4b52f4
movl $0xc9, %r8d
movb $0x0, %al
callq 0x40df10
leaq 0xb22aa(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2ca1(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
jmp 0x402e7c
movl -0x10(%rbp), %edi
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x38(%rax), %edx
callq 0x45fdb0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x402f10
jmp 0x402e9e
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2595(%rip), %rsi     # 0x4b5444
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2204(%rip), %rsi     # 0x4b50cb
leaq 0xb25bc(%rip), %rdx     # 0x4b548a
leaq 0xb241f(%rip), %rcx     # 0x4b52f4
movl $0xcf, %r8d
movb $0x0, %al
callq 0x40df10
leaq 0xb2214(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2c0b(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
movl -0x10(%rbp), %edi
movl $0x80, %esi
callq 0x45fec0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x402f9a
jmp 0x402f28
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb255e(%rip), %rsi     # 0x4b5497
movb $0x0, %al
callq 0x40df10
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb217a(%rip), %rsi     # 0x4b50cb
leaq 0xb2532(%rip), %rdx     # 0x4b548a
leaq 0xb2395(%rip), %rcx     # 0x4b52f4
movl $0xd4, %r8d
movb $0x0, %al
callq 0x40df10
leaq 0xb218a(%rip), %rdi     # 0x4b50fd
callq 0x40e2c0
movq $0x4e87a8, %rax         # imm = 0x4E87A8
movq (%rax), %rdi
leaq 0xb2b81(%rip), %rsi     # 0x4b5b0a
movb $0x0, %al
callq 0x40df10
movl $0x1, %edi
callq 0x40ce70
movl -0x10(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)