// File: /workspace/github_c_makefile_star2_O1/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 0x4800
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 0x4b40
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 0x289b
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 0x2893
movq %rax, %rbx
leaq 0x48e4(%rip), %rdi      # 0x703b
xorl %eax, %eax
callq 0x5be8
movl $0x0, (%rbx)
jmp 0x289b
movq %rbx, %rdi
callq 0x545d
cmpl $-0x1, %eax
jne 0x278c
callq 0x2040
cmpl $0x0, (%rax)
jne 0x27bb
leaq 0x48ef(%rip), %rdi      # 0x7076
jmp 0x2872
movl %eax, %ebp
movl %eax, %edi
movq %r14, %rsi
callq 0x3d8c
testq %rax, %rax
jne 0x27ca
leaq 0x48df(%rip), %rdi      # 0x7083
xorl %eax, %eax
callq 0x5d07
callq 0x2040
movl $0x0, (%rax)
jmp 0x2856
movq %rax, %r14
leaq 0x48b1(%rip), %rdi      # 0x7076
jmp 0x2885
movq %rax, %r14
leaq 0x147(%rip), %r8        # 0x291b
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
movl $0x1, %ecx
movq %rax, %rdi
xorl %r9d, %r9d
callq 0x41cd
testq %rax, %rax
je 0x2825
movq %rax, %rdi
callq 0x42b3
leaq 0x119(%rip), %r8        # 0x291b
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
movl $0x1, %ecx
movq %r14, %rdi
xorl %r9d, %r9d
callq 0x41cd
testq %rax, %rax
jne 0x28aa
leaq 0x4868(%rip), %rdi      # 0x7094
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x5d07
callq 0x2040
movl $0x0, (%rax)
testq %r15, %r15
je 0x284e
movq %r15, %rdi
callq 0x42b3
movq %r14, %rdi
callq 0x42c5
movl %ebp, %edi
callq 0x2410
testl %eax, %eax
je 0x2893
callq 0x2040
cmpl $0x0, (%rax)
jne 0x287b
leaq 0x4834(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x5d07
jmp 0x2893
movq %rax, %r14
leaq 0x4821(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x5be8
movl $0x0, (%r14)
movq %rbx, %rdi
callq 0x5257
movq 0x10(%rsp), %rdi
callq 0x22b0
jmp 0x2691
movq %rax, %r15
leaq 0x8c10(%rip), %rdi      # 0xb4c4
callq 0x2c1d
testl %eax, %eax
jne 0x2841
movq %r14, %rdi
callq 0x42c5
movl %ebp, %edi
callq 0x2410
testl %eax, %eax
je 0x2902
callq 0x2040
cmpl $0x0, (%rax)
jne 0x28ea
leaq 0x47c5(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x5d07
jmp 0x2902
movq %rax, %r14
leaq 0x47b2(%rip), %rdi      # 0x70a6
xorl %eax, %eax
callq 0x5be8
movl $0x0, (%r14)
movq %rbx, %rdi
callq 0x5257
movq 0x10(%rsp), %rdi
callq 0x22b0
xorl %edi, %edi
callq 0x22d0