// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]spiped/perftests/recv-zeros/main.c
// Function: main
int
main(int argc, char ** argv)
{
	/* Command-line parameters. */
	const char * addr = NULL;
	size_t buflen;

	/* Working variables. */
	struct sock_addr * sa;
	int socket;
	int socket_recv;
	char * buffer;
	ssize_t r;

	WARNP_INIT;

	/* Parse command-line arguments. */
	if (argc < 3) {
		warn0("usage: %s ADDRESS BUFLEN", argv[0]);
		goto err0;
	}
	addr = argv[1];
	if (PARSENUM(&buflen, argv[2], 1, SSIZE_MAX)) {
		warnp("parsenum");
		goto err0;
	}

	/* Allocate buffer. */
	if ((buffer = malloc(buflen)) == NULL) {
		warnp("malloc");
		goto err0;
	}

	/* Resolve the address. */
	if ((sa = sock_resolve_one(addr, 0)) == NULL) {
		warn0("sock_resolve_one");
		goto err1;
	}

	/* Create a socket, bind it, mark it as listening. */
	if ((socket = sock_listener(sa)) == -1) {
		warn0("sock_listener");
		goto err2;
	}

	/* Make it blocking. */
	if (fcntl(socket, F_SETFL,
	    fcntl(socket, F_GETFL, 0) & (~O_NONBLOCK)) == -1) {
		warnp("Cannot make connection blocking");
		goto err3;
	}

	/* Accept a connection. */
	if ((socket_recv = accept(socket, NULL, NULL)) == -1) {
		warnp("accept");
		goto err3;
	}

	/* Receive data, but do nothing with it. */
	do {
		r = recv(socket_recv, buffer, buflen, MSG_WAITALL);
	} while (r == (ssize_t)buflen);
	if (r == -1) {
		warnp("recv");
		goto err4;
	}

	/* Close the connection. */
	if (close(socket_recv)) {
		warnp("close");
		goto err3;
	}

	/* Clean up. */
	if (close(socket)) {
		warnp("close");
		goto err2;
	}
	sock_addr_free(sa);
	free(buffer);

	/* Success! */
	exit(0);

err4:
	if (close(socket_recv))
		warnp("close");
err3:
	if (close(socket))
		warnp("close");
err2:
	sock_addr_free(sa);
err1:
	free(buffer);
err0:
	/* Failure! */
	exit(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x14f9
callq 0x27b0
cmpl $0x2, %ebx
jg 0x1524
movq (%r14), %rsi
leaq 0x1afc(%rip), %rdi      # 0x3004
xorl %eax, %eax
callq 0x294f
callq 0x1090
movl $0x0, (%rax)
movl $0x1, %edi
callq 0x1240
movq 0x8(%r14), %r15
callq 0x1090
movl $0x0, (%rax)
movq 0x10(%r14), %r14
testq %r14, %r14
jne 0x155b
leaq 0x1b3b(%rip), %rdi      # 0x307e
leaq 0x1b3e(%rip), %rsi      # 0x3088
leaq 0x1b59(%rip), %rcx      # 0x30aa
movl $0xbb, %edx
callq 0x1120
movq %rax, %rbx
movq %rsp, %r13
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x1200
movq %rax, %r12
movq (%r13), %rcx
movl $0x16, %eax
cmpq %r14, %rcx
je 0x158e
cmpb $0x0, (%rcx)
jne 0x158e
movl $0x22, %eax
testq %r12, %r12
jg 0x1590
movl %eax, (%rbx)
cmpl $0x0, (%rbx)
jne 0x15b5
movq %r12, %rdi
callq 0x11b0
testq %rax, %rax
jne 0x15ce
leaq 0x1a7d(%rip), %rdi      # 0x3026
xorl %eax, %eax
callq 0x294f
jmp 0x151a
leaq 0x1a61(%rip), %rdi      # 0x301d
xorl %eax, %eax
callq 0x2830
movl $0x0, (%rbx)
jmp 0x151a
movq %rax, %r14
movq %r15, %rdi
xorl %esi, %esi
callq 0x1d27
testq %rax, %rax
jne 0x15f9
leaq 0x1a46(%rip), %rdi      # 0x302d
xorl %eax, %eax
callq 0x294f
movl $0x0, (%rbx)
jmp 0x1768
movq %rax, %r15
movq %rax, %rdi
callq 0x1ee3
cmpl $-0x1, %eax
jne 0x1622
leaq 0x1a2e(%rip), %rdi      # 0x303e
xorl %eax, %eax
callq 0x294f
movl $0x0, (%rbx)
jmp 0x1760
movl %eax, %ebp
movl %eax, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x10d0
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl %ebp, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x10d0
cmpl $-0x1, %eax
jne 0x165f
cmpl $0x0, (%rbx)
jne 0x1680
leaq 0x19f2(%rip), %rdi      # 0x304c
jmp 0x1725
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1220
cmpl $-0x1, %eax
jne 0x168c
cmpl $0x0, (%rbx)
jne 0x16c2
leaq 0x19f1(%rip), %rdi      # 0x306c
jmp 0x1725
leaq 0x19c5(%rip), %rdi      # 0x304c
jmp 0x1735
movl %eax, %r13d
movl %r13d, %edi
movq %r14, %rsi
movq %r12, %rdx
movl $0x100, %ecx            # imm = 0x100
callq 0x1060
cmpq %r12, %rax
je 0x168f
cmpq $-0x1, %rax
jne 0x16cb
cmpl $0x0, (%rbx)
jne 0x16f9
leaq 0x19ba(%rip), %rdi      # 0x3073
xorl %eax, %eax
callq 0x294f
jmp 0x170d
leaq 0x19a3(%rip), %rdi      # 0x306c
jmp 0x1735
movl %r13d, %edi
callq 0x1140
testl %eax, %eax
jne 0x1719
movl %ebp, %edi
callq 0x1140
testl %eax, %eax
jne 0x174d
movq %r15, %rdi
callq 0x1e83
movq %r14, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x1240
leaq 0x1973(%rip), %rdi      # 0x3073
xorl %eax, %eax
callq 0x2830
movl $0x0, (%rbx)
movl %r13d, %edi
callq 0x1140
testl %eax, %eax
je 0x1742
cmpl $0x0, (%rbx)
jne 0x172e
leaq 0x1953(%rip), %rdi      # 0x3078
xorl %eax, %eax
callq 0x294f
jmp 0x1742
leaq 0x1943(%rip), %rdi      # 0x3078
xorl %eax, %eax
callq 0x2830
movl $0x0, (%rbx)
movl %ebp, %edi
callq 0x1140
testl %eax, %eax
je 0x1760
cmpl $0x0, (%rbx)
jne 0x1775
leaq 0x191f(%rip), %rdi      # 0x3078
xorl %eax, %eax
callq 0x294f
movq %r15, %rdi
callq 0x1e83
movq %r14, %rdi
callq 0x1040
jmp 0x151a
leaq 0x18fc(%rip), %rdi      # 0x3078
xorl %eax, %eax
callq 0x2830
jmp 0x1617