// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]libcperciva/perftests/network-ssl/main.c
// Function: main
int
main(int argc, char * argv[])
{
	struct network_ssl_ctx * ctx;
	const char * hostname;
	char * sock_addr;

	/* Working variables. */
	struct sock_addr ** sas_t;
	int socket;
	const uint8_t req = 0;
	void * network_ssl_write_cookie;

	WARNP_INIT;

	/* Check number of arguments. */
	if (argc != 2) {
		fprintf(stderr, "usage: test_network_ssl %s\n",
		    "<hostname>");
		goto err0;
	}
	hostname = argv[1];

	/* Create target address. */
	if (asprintf(&sock_addr, "%s:443", hostname) == -1) {
		warnp("asprintf");
		goto err0;
	}

	/* Resolve target address. */
	if ((sas_t = sock_resolve(sock_addr)) == NULL) {
		warnp("Error resolving socket address: %s", sock_addr);
		goto err1;
	}
	if (sas_t[0] == NULL) {
		warn0("No address found for %s", sock_addr);
		goto err2;
	}

	/* Connect to host. */
	if ((socket = sock_connect(sas_t)) == -1) {
		warnp("sock_connect");
		goto err2;
	}
	if ((ctx = network_ssl_open(socket, hostname)) == NULL) {
		warn0("network_ssl_open");
		goto err3;
	}

	/* Prepare to send a 1-byte buffer containing 0. */
	if ((network_ssl_write_cookie = network_ssl_write(ctx, &req, 1, 1,
	    callback_write_test, NULL)) == NULL) {
		warn0("network_ssl_write");
		goto err4;
	}

	/* Nope, changed our mind! */
	network_ssl_write_cancel(network_ssl_write_cookie);

	/* Prepare to send a 1-byte buffer containing 0 (again). */
	if ((network_ssl_write_cookie = network_ssl_write(ctx, &req, 1, 1,
	    callback_write_test, NULL)) == NULL) {
		warn0("network_ssl_write");
		goto err4;
	}

	/* Wait for reply. */
	if (events_spin(&conndone))
		goto err4;

	/* Clean up. */
	network_ssl_close(ctx);
	if (close(socket))
		warnp("close");
	sock_addr_freelist(sas_t);
	free(sock_addr);

	/* Success! */
	exit(0);

err4:
	if (network_ssl_write_cookie != NULL)
		network_ssl_write_cancel(network_ssl_write_cookie);
	network_ssl_close(ctx);
err3:
	if (close(socket))
		warnp("close");
err2:
	sock_addr_freelist(sas_t);
err1:
	free(sock_addr);
err0:
	/* Failure! */
	exit(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movb $0x0, 0xf(%rsp)
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x254d
callq 0x5500
cmpl $0x2, %ebp
je 0x2579
movq 0x8a87(%rip), %rax      # 0xafe0
movq (%rax), %rdi
leaq 0x4aa1(%rip), %rsi      # 0x7004
leaq 0x4ab6(%rip), %rdx      # 0x7020
xorl %eax, %eax
callq 0x2370
pushq $0x1
popq %rdi
callq 0x22d0
movq 0x8(%rbx), %r14
leaq 0x4aa7(%rip), %rsi      # 0x702b
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x4398
cmpl $-0x1, %eax
jne 0x25b2
callq 0x2040
cmpl $0x0, (%rax)
jne 0x25e3
leaq 0x4a89(%rip), %rdi      # 0x7032
xorl %eax, %eax
callq 0x570c
jmp 0x2571
movq 0x10(%rsp), %rdi
callq 0x4688
testq %rax, %rax
jne 0x25fc
callq 0x2040
cmpl $0x0, (%rax)
movq 0x10(%rsp), %rsi
jne 0x2625
leaq 0x4a64(%rip), %rdi      # 0x703b
xorl %eax, %eax
callq 0x570c
jmp 0x2748
movq %rax, %rbx
leaq 0x4a45(%rip), %rdi      # 0x7032
xorl %eax, %eax
callq 0x557d
andl $0x0, (%rbx)
jmp 0x2571
movq %rax, %rbx
cmpq $0x0, (%rax)
jne 0x263e
movq 0x10(%rsp), %rsi
leaq 0x4a4d(%rip), %rdi      # 0x705e
xorl %eax, %eax
callq 0x570c
callq 0x2040
andl $0x0, (%rax)
jmp 0x2740
movq %rax, %rbx
leaq 0x4a0c(%rip), %rdi      # 0x703b
xorl %eax, %eax
callq 0x557d
andl $0x0, (%rbx)
jmp 0x2748
movq %rbx, %rdi
callq 0x4e61
cmpl $-0x1, %eax
jne 0x2661
callq 0x2040
cmpl $0x0, (%rax)
jne 0x268a
leaq 0x4a1a(%rip), %rdi      # 0x7076
jmp 0x2722
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
callq 0x3990
testq %rax, %rax
jne 0x2699
leaq 0x4a0a(%rip), %rdi      # 0x7083
xorl %eax, %eax
callq 0x570c
callq 0x2040
andl $0x0, (%rax)
jmp 0x2706
movq %rax, %r14
leaq 0x49e2(%rip), %rdi      # 0x7076
jmp 0x2735
movq %rax, %r14
leaq 0x12f(%rip), %r8        # 0x27d2
leaq 0xf(%rsp), %rsi
pushq $0x1
popq %rcx
movq %rax, %rdi
movq %rcx, %rdx
xorl %r9d, %r9d
callq 0x3dae
testq %rax, %rax
je 0x26e8
movq %rax, %rdi
callq 0x3e94
leaq 0x105(%rip), %r8        # 0x27d2
leaq 0xf(%rsp), %rsi
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %rcx, %rdx
xorl %r9d, %r9d
callq 0x3dae
testq %rax, %rax
jne 0x2757
leaq 0x49a5(%rip), %rdi      # 0x7094
xorl %eax, %eax
callq 0x570c
callq 0x2040
andl $0x0, (%rax)
movq %r14, %rdi
callq 0x3ea6
movl %ebp, %edi
callq 0x2410
testl %eax, %eax
je 0x2740
callq 0x2040
cmpl $0x0, (%rax)
jne 0x272b
leaq 0x4984(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x570c
jmp 0x2740
movq %rax, %r14
leaq 0x4971(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x557d
andl $0x0, (%r14)
movq %rbx, %rdi
callq 0x4c87
movq 0x10(%rsp), %rdi
callq 0x22b0
jmp 0x2571
movq %rax, %r15
leaq 0x8d63(%rip), %rdi      # 0xb4c4
callq 0x2ab3
testl %eax, %eax
jne 0x2797
movq %r14, %rdi
callq 0x3ea6
movl %ebp, %edi
callq 0x2410
testl %eax, %eax
je 0x27b9
callq 0x2040
cmpl $0x0, (%rax)
jne 0x27a4
leaq 0x4918(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x570c
jmp 0x27b9
movq %r15, %rdi
callq 0x3e94
jmp 0x26fe
movq %rax, %r14
leaq 0x48f8(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x557d
andl $0x0, (%r14)
movq %rbx, %rdi
callq 0x4c87
movq 0x10(%rsp), %rdi
callq 0x22b0
xorl %edi, %edi
callq 0x22d0