// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::setsock(int, char*)
static int setsock(socket_t sock, char *msg)
	{
		int bs = buffsize, mode = 1;
#ifdef WIN32
		int tv = 0;
#else
		struct timeval tv = { 0 };
#endif
		tracet(3, "setsock: sock=%d\n", sock);

		if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv)) == -1 ||
			setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const char *)&tv, sizeof(tv)) == -1) {
			sprintf(msg, "sockopt error: notimeo");
			tracet(1, "setsock: setsockopt error 1 sock=%d err=%d\n", sock, errsock());
			closesocket(sock);
			return 0;
		}
		if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (const char *)&bs, sizeof(bs)) == -1 ||
			setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (const char *)&bs, sizeof(bs)) == -1) {
			tracet(1, "setsock: setsockopt error 2 sock=%d err=%d bs=%d\n", sock, errsock(), bs);
			sprintf(msg, "sockopt error: bufsiz");
		}
		if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&mode, sizeof(mode)) == -1) {
			tracet(1, "setsock: setsockopt error 3 sock=%d err=%d\n", sock, errsock());
			sprintf(msg, "sockopt error: nodelay");
		}
		return 1;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl 0x5565f(%rip), %eax     # 0xf9a74
movl %eax, -0x14(%rbp)
movl $0x1, -0x18(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x93d0
movl -0x8(%rbp), %edx
movl $0x3, %edi
leaq 0x24b37(%rip), %rsi     # 0xc8f75
movb $0x0, %al
callq 0x95890
movl -0x8(%rbp), %edi
movl $0x1, %esi
movl $0x14, %edx
leaq -0x28(%rbp), %rcx
movl $0x10, %r8d
callq 0x9d50
cmpl $-0x1, %eax
je 0xa4487
movl -0x8(%rbp), %edi
movl $0x1, %esi
movl $0x15, %edx
leaq -0x28(%rbp), %rcx
movl $0x10, %r8d
callq 0x9d50
cmpl $-0x1, %eax
jne 0xa44d0
movq -0x10(%rbp), %rdi
leaq 0x24af5(%rip), %rsi     # 0xc8f87
movb $0x0, %al
callq 0x9150
movl -0x8(%rbp), %eax
movl %eax, -0x2c(%rbp)
callq 0xa43f0
movl -0x2c(%rbp), %edx
movl %eax, %ecx
movl $0x1, %edi
leaq 0x24ae9(%rip), %rsi     # 0xc8f9e
movb $0x0, %al
callq 0x95890
movl -0x8(%rbp), %edi
callq 0x9e90
movl $0x0, -0x4(%rbp)
jmp 0xa45a8
movl -0x8(%rbp), %edi
movl $0x1, %esi
movl $0x8, %edx
leaq -0x14(%rbp), %rcx
movl $0x4, %r8d
callq 0x9d50
cmpl $-0x1, %eax
je 0xa4512
movl -0x8(%rbp), %edi
movl $0x1, %esi
movl $0x7, %edx
leaq -0x14(%rbp), %rcx
movl $0x4, %r8d
callq 0x9d50
cmpl $-0x1, %eax
jne 0xa454b
movl -0x8(%rbp), %eax
movl %eax, -0x30(%rbp)
callq 0xa43f0
movl -0x30(%rbp), %edx
movl %eax, %ecx
movl -0x14(%rbp), %r8d
movl $0x1, %edi
leaq 0x24a98(%rip), %rsi     # 0xc8fca
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rdi
leaq 0x24ab8(%rip), %rsi     # 0xc8ffc
movb $0x0, %al
callq 0x9150
movl -0x8(%rbp), %edi
movl $0x6, %esi
movl $0x1, %edx
leaq -0x18(%rbp), %rcx
movl $0x4, %r8d
callq 0x9d50
cmpl $-0x1, %eax
jne 0xa45a1
movl -0x8(%rbp), %eax
movl %eax, -0x34(%rbp)
callq 0xa43f0
movl -0x34(%rbp), %edx
movl %eax, %ecx
movl $0x1, %edi
leaq 0x24a8a(%rip), %rsi     # 0xc9012
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rdi
leaq 0x24aa4(%rip), %rsi     # 0xc903e
movb $0x0, %al
callq 0x9150
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)