// File: /workspace/github_c_makefile_star2_O3/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 0x266d
callq 0x5b68
cmpl $0x2, %ebp
je 0x269b
movq 0x8967(%rip), %rax      # 0xafe0
movq (%rax), %rdi
leaq 0x4981(%rip), %rsi      # 0x7004
leaq 0x4996(%rip), %rdx      # 0x7020
xorl %eax, %eax
callq 0x2370
movl $0x1, %edi
callq 0x22d0
movq 0x8(%rbx), %r14
leaq 0x4985(%rip), %rsi      # 0x702b
leaq 0x10(%rsp), %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x4824
cmpl $-0x1, %eax
jne 0x26d4
callq 0x2040
cmpl $0x0, (%rax)
jne 0x2705
leaq 0x4967(%rip), %rdi      # 0x7032
xorl %eax, %eax
callq 0x5d07
jmp 0x2691
movq 0x10(%rsp), %rdi
callq 0x4b64
testq %rax, %rax
jne 0x2721
callq 0x2040
cmpl $0x0, (%rax)
movq 0x10(%rsp), %rsi
jne 0x274d
leaq 0x4942(%rip), %rdi      # 0x703b
xorl %eax, %eax
callq 0x5d07
jmp 0x2887
movq %rax, %rbx
leaq 0x4923(%rip), %rdi      # 0x7032
xorl %eax, %eax
callq 0x5be8
movl $0x0, (%rbx)
jmp 0x2691
movq %rax, %rbx
cmpq $0x0, (%rax)
jne 0x2769
movq 0x10(%rsp), %rsi
leaq 0x4928(%rip), %rdi      # 0x705e
xorl %eax, %eax
callq 0x5d07
callq 0x2040
movl $0x0, (%rax)
jmp 0x287f
movq %rax, %rbx
leaq 0x48e4(%rip), %rdi      # 0x703b
xorl %eax, %eax
callq 0x5be8
movl $0x0, (%rbx)
jmp 0x2887
movq %rbx, %rdi
callq 0x547c
cmpl $-0x1, %eax
jne 0x278c
callq 0x2040
cmpl $0x0, (%rax)
jne 0x27bb
leaq 0x48ef(%rip), %rdi      # 0x7076
jmp 0x285e
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
callq 0x3db0
testq %rax, %rax
jne 0x27ca
leaq 0x48df(%rip), %rdi      # 0x7083
xorl %eax, %eax
callq 0x5d07
callq 0x2040
movl $0x0, (%rax)
jmp 0x2842
movq %rax, %r14
leaq 0x48b1(%rip), %rdi      # 0x7076
jmp 0x2871
movq %rax, %r14
leaq 0x140(%rip), %r8        # 0x2914
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
movl $0x1, %ecx
movq %rax, %rdi
xorl %r9d, %r9d
callq 0x41ff
testq %rax, %rax
je 0x2821
movq %rax, %rdi
callq 0x42e5
leaq 0x112(%rip), %r8        # 0x2914
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
movl $0x1, %ecx
movq %r14, %rdi
xorl %r9d, %r9d
callq 0x41ff
testq %rax, %rax
jne 0x2896
leaq 0x486c(%rip), %rdi      # 0x7094
xorl %eax, %eax
callq 0x5d07
callq 0x2040
movl $0x0, (%rax)
movq %r14, %rdi
callq 0x42f7
movl %ebp, %edi
callq 0x2410
testl %eax, %eax
je 0x287f
callq 0x2040
cmpl $0x0, (%rax)
jne 0x2867
leaq 0x4848(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x5d07
jmp 0x287f
movq %rax, %r14
leaq 0x4835(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x5be8
movl $0x0, (%r14)
movq %rbx, %rdi
callq 0x5276
movq 0x10(%rsp), %rdi
callq 0x22b0
jmp 0x2691
movq %rax, %r15
leaq 0x8c24(%rip), %rdi      # 0xb4c4
callq 0x2c05
testl %eax, %eax
jne 0x28d6
movq %r14, %rdi
callq 0x42f7
movl %ebp, %edi
callq 0x2410
testl %eax, %eax
je 0x28fb
callq 0x2040
cmpl $0x0, (%rax)
jne 0x28e3
leaq 0x47d9(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x5d07
jmp 0x28fb
movq %r15, %rdi
callq 0x42e5
jmp 0x283a
movq %rax, %r14
leaq 0x47b9(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x5be8
movl $0x0, (%r14)
movq %rbx, %rdi
callq 0x5276
movq 0x10(%rsp), %rdi
callq 0x22b0
xorl %edi, %edi
callq 0x22d0