// File: /workspace/github_c_makefile_star2_O2/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 0x13d9
callq 0x24c4
cmpl $0x2, %ebx
jg 0x13ff
movq (%r14), %rsi
leaq 0x1c1c(%rip), %rdi      # 0x3004
xorl %eax, %eax
callq 0x26d0
callq 0x1090
andl $0x0, (%rax)
pushq $0x1
popq %rdi
callq 0x1240
movq 0x8(%r14), %r15
callq 0x1090
andl $0x0, (%rax)
movq 0x10(%r14), %r14
testq %r14, %r14
jne 0x1433
leaq 0x1c63(%rip), %rdi      # 0x307e
leaq 0x1c66(%rip), %rsi      # 0x3088
leaq 0x1c81(%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
pushq $0x16
popq %rax
cmpq %r14, %rcx
je 0x1462
cmpb $0x0, (%rcx)
jne 0x1462
testq %r12, %r12
jg 0x1464
pushq $0x22
popq %rax
movl %eax, (%rbx)
cmpl $0x0, (%rbx)
jne 0x1489
movq %r12, %rdi
callq 0x11b0
testq %rax, %rax
jne 0x149f
leaq 0x1ba9(%rip), %rdi      # 0x3026
xorl %eax, %eax
callq 0x26d0
jmp 0x13f7
leaq 0x1b8d(%rip), %rdi      # 0x301d
xorl %eax, %eax
callq 0x2541
andl $0x0, (%rbx)
jmp 0x13f7
movq %rax, %r14
movq %r15, %rdi
xorl %esi, %esi
callq 0x1af3
testq %rax, %rax
jne 0x14c7
leaq 0x1b75(%rip), %rdi      # 0x302d
xorl %eax, %eax
callq 0x26d0
andl $0x0, (%rbx)
jmp 0x1629
movq %rax, %r15
movq %rax, %rdi
callq 0x1c7d
cmpl $-0x1, %eax
jne 0x14ed
leaq 0x1b60(%rip), %rdi      # 0x303e
xorl %eax, %eax
callq 0x26d0
andl $0x0, (%rbx)
jmp 0x1621
movl %eax, %ebp
pushq $0x3
popq %rsi
movl %eax, %edi
xorl %edx, %edx
xorl %eax, %eax
callq 0x10d0
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
pushq $0x4
popq %rsi
movl %ebp, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x10d0
cmpl $-0x1, %eax
jne 0x1526
cmpl $0x0, (%rbx)
jne 0x1547
leaq 0x1b2b(%rip), %rdi      # 0x304c
jmp 0x15e9
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1220
cmpl $-0x1, %eax
jne 0x1553
cmpl $0x0, (%rbx)
jne 0x1589
leaq 0x1b2a(%rip), %rdi      # 0x306c
jmp 0x15e9
leaq 0x1afe(%rip), %rdi      # 0x304c
jmp 0x15f9
movl %eax, %r13d
movl %r13d, %edi
movq %r14, %rsi
movq %r12, %rdx
movl $0x100, %ecx            # imm = 0x100
callq 0x1060
cmpq %r12, %rax
je 0x1556
cmpq $-0x1, %rax
jne 0x1592
cmpl $0x0, (%rbx)
jne 0x15c0
leaq 0x1af3(%rip), %rdi      # 0x3073
xorl %eax, %eax
callq 0x26d0
jmp 0x15d1
leaq 0x1adc(%rip), %rdi      # 0x306c
jmp 0x15f9
movl %r13d, %edi
callq 0x1140
testl %eax, %eax
jne 0x15dd
movl %ebp, %edi
callq 0x1140
testl %eax, %eax
jne 0x160e
movq %r15, %rdi
callq 0x1c2f
movq %r14, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x1240
leaq 0x1aac(%rip), %rdi      # 0x3073
xorl %eax, %eax
callq 0x2541
andl $0x0, (%rbx)
movl %r13d, %edi
callq 0x1140
testl %eax, %eax
je 0x1603
cmpl $0x0, (%rbx)
jne 0x15f2
leaq 0x1a8f(%rip), %rdi      # 0x3078
xorl %eax, %eax
callq 0x26d0
jmp 0x1603
leaq 0x1a7f(%rip), %rdi      # 0x3078
xorl %eax, %eax
callq 0x2541
andl $0x0, (%rbx)
movl %ebp, %edi
callq 0x1140
testl %eax, %eax
je 0x1621
cmpl $0x0, (%rbx)
jne 0x1636
leaq 0x1a5e(%rip), %rdi      # 0x3078
xorl %eax, %eax
callq 0x26d0
movq %r15, %rdi
callq 0x1c2f
movq %r14, %rdi
callq 0x1040
jmp 0x13f7
leaq 0x1a3b(%rip), %rdi      # 0x3078
xorl %eax, %eax
callq 0x2541
jmp 0x14e5
nopl (%rax)