// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/samtools-0.1.18/knetfile.c
// Function: socket_connect
static int socket_connect(const char *host, const char *port)
{
#define __err_connect(func) do { perror(func); freeaddrinfo(res); return -1; } while (0)

	int on = 1, fd;
	struct linger lng = { 0, 0 };
	struct addrinfo hints, *res = 0;
	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	/* In Unix/Mac, getaddrinfo() is the most convenient way to get
	 * server information. */
	if (getaddrinfo(host, port, &hints, &res) != 0) __err_connect("getaddrinfo");
	if ((fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) __err_connect("socket");
	/* The following two setsockopt() are used by ftplib
	 * (http://nbpfaus.net/~pfau/ftplib/). I am not sure if they
	 * necessary. */
	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) __err_connect("setsockopt");
	if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &lng, sizeof(lng)) == -1) __err_connect("setsockopt");
	if (connect(fd, res->ai_addr, res->ai_addrlen) != 0) __err_connect("connect");
	freeaddrinfo(res);
	return fd;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movl $0x1, 0x4c(%rsp)
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x2f4c0
movq $0x0, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x2f4c0
movl $0x0, 0x14(%rsp)
movl $0x1, 0x18(%rsp)
movq 0x58(%rsp), %rdi
movq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x2fe60
cmpl $0x0, %eax
je 0x482c04
jmp 0x482be1
leaq 0xf846c(%rip), %rdi     # 0x57b054
callq 0x33870
movq 0x8(%rsp), %rdi
callq 0x30d50
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
jmp 0x482d2f
movq 0x8(%rsp), %rax
movl 0x4(%rax), %edi
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
movq 0x8(%rsp), %rax
movl 0xc(%rax), %edx
callq 0x32370
movl %eax, 0x48(%rsp)
cmpl $-0x1, %eax
jne 0x482c4f
jmp 0x482c2c
leaq 0xf5dc5(%rip), %rdi     # 0x5789f8
callq 0x33870
movq 0x8(%rsp), %rdi
callq 0x30d50
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
jmp 0x482d2f
movl 0x48(%rsp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq 0x4c(%rsp), %rcx
movl $0x4, %r8d
callq 0x306f0
cmpl $-0x1, %eax
jne 0x482c97
jmp 0x482c74
leaq 0xf83e5(%rip), %rdi     # 0x57b060
callq 0x33870
movq 0x8(%rsp), %rdi
callq 0x30d50
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
jmp 0x482d2f
movl 0x48(%rsp), %edi
movl $0x1, %esi
movl $0xd, %edx
leaq 0x40(%rsp), %rcx
movl $0x8, %r8d
callq 0x306f0
cmpl $-0x1, %eax
jne 0x482cdc
jmp 0x482cbc
leaq 0xf839d(%rip), %rdi     # 0x57b060
callq 0x33870
movq 0x8(%rsp), %rdi
callq 0x30d50
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
jmp 0x482d2f
movl 0x48(%rsp), %edi
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
movq 0x8(%rsp), %rax
movl 0x10(%rax), %edx
callq 0x31d50
cmpl $0x0, %eax
je 0x482d1d
jmp 0x482cfd
leaq 0xf8367(%rip), %rdi     # 0x57b06b
callq 0x33870
movq 0x8(%rsp), %rdi
callq 0x30d50
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
jmp 0x482d2f
movq 0x8(%rsp), %rdi
callq 0x30d50
movl 0x48(%rsp), %eax
movl %eax, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopl (%rax,%rax)