// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x35(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x2580
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7a00
jmp 0x2582
cmpl $0x2, -0x8(%rbp)
je 0x25ac
movq 0xba51(%rip), %rax      # 0xdfe0
movq (%rax), %rdi
leaq 0x7a6b(%rip), %rsi      # 0xa004
leaq 0x7a80(%rip), %rdx      # 0xa020
movb $0x0, %al
callq 0x2390
jmp 0x28a1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdx
leaq -0x28(%rbp), %rdi
leaq 0x7a64(%rip), %rsi      # 0xa02b
movb $0x0, %al
callq 0x59f0
cmpl $-0x1, %eax
jne 0x260f
jmp 0x25d5
callq 0x2040
cmpl $0x0, (%rax)
je 0x25fa
leaq 0x7a4c(%rip), %rdi      # 0xa032
movb $0x0, %al
callq 0x7ac0
callq 0x2040
movl $0x0, (%rax)
jmp 0x2608
leaq 0x7a31(%rip), %rdi      # 0xa032
movb $0x0, %al
callq 0x7d10
jmp 0x260a
jmp 0x28a1
movq -0x28(%rbp), %rdi
callq 0x5e50
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x2666
jmp 0x2624
callq 0x2040
cmpl $0x0, (%rax)
je 0x264d
movq -0x28(%rbp), %rsi
leaq 0x7a02(%rip), %rdi      # 0xa03b
movb $0x0, %al
callq 0x7ac0
callq 0x2040
movl $0x0, (%rax)
jmp 0x265f
movq -0x28(%rbp), %rsi
leaq 0x79e3(%rip), %rdi      # 0xa03b
movb $0x0, %al
callq 0x7d10
jmp 0x2661
jmp 0x2898
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x2694
jmp 0x2672
movq -0x28(%rbp), %rsi
leaq 0x79e1(%rip), %rdi      # 0xa05e
movb $0x0, %al
callq 0x7d10
callq 0x2040
movl $0x0, (%rax)
jmp 0x288f
movq -0x30(%rbp), %rdi
callq 0x6d20
movl %eax, -0x34(%rbp)
cmpl $-0x1, %eax
jne 0x26e1
jmp 0x26a7
callq 0x2040
cmpl $0x0, (%rax)
je 0x26cc
leaq 0x79be(%rip), %rdi      # 0xa076
movb $0x0, %al
callq 0x7ac0
callq 0x2040
movl $0x0, (%rax)
jmp 0x26da
leaq 0x79a3(%rip), %rdi      # 0xa076
movb $0x0, %al
callq 0x7d10
jmp 0x26dc
jmp 0x288f
movl -0x34(%rbp), %edi
movq -0x20(%rbp), %rsi
callq 0x47b0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x2717
jmp 0x26f9
leaq 0x7983(%rip), %rdi      # 0xa083
movb $0x0, %al
callq 0x7d10
callq 0x2040
movl $0x0, (%rax)
jmp 0x2847
movq -0x18(%rbp), %rdi
leaq -0x35(%rbp), %rsi
movl $0x1, %ecx
leaq 0x185(%rip), %r8        # 0x28b0
xorl %eax, %eax
movl %eax, %r9d
movq %rcx, %rdx
callq 0x4ef0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x2762
jmp 0x2744
leaq 0x7949(%rip), %rdi      # 0xa094
movb $0x0, %al
callq 0x7d10
callq 0x2040
movl $0x0, (%rax)
jmp 0x282e
movq -0x40(%rbp), %rdi
callq 0x5080
movq -0x18(%rbp), %rdi
leaq -0x35(%rbp), %rsi
movl $0x1, %ecx
leaq 0x131(%rip), %r8        # 0x28b0
xorl %eax, %eax
movl %eax, %r9d
movq %rcx, %rdx
callq 0x4ef0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x27b3
jmp 0x2798
leaq 0x78f5(%rip), %rdi      # 0xa094
movb $0x0, %al
callq 0x7d10
callq 0x2040
movl $0x0, (%rax)
jmp 0x282e
leaq 0xbd1a(%rip), %rdi      # 0xe4d4
callq 0x2bd0
cmpl $0x0, %eax
je 0x27c6
jmp 0x282e
movq -0x18(%rbp), %rdi
callq 0x50d0
movl -0x34(%rbp), %edi
callq 0x2430
cmpl $0x0, %eax
je 0x2815
jmp 0x27de
callq 0x2040
cmpl $0x0, (%rax)
je 0x2803
leaq 0x78b7(%rip), %rdi      # 0xa0a6
movb $0x0, %al
callq 0x7ac0
callq 0x2040
movl $0x0, (%rax)
jmp 0x2811
leaq 0x789c(%rip), %rdi      # 0xa0a6
movb $0x0, %al
callq 0x7d10
jmp 0x2813
jmp 0x2815
movq -0x30(%rbp), %rdi
callq 0x6a80
movq -0x28(%rbp), %rdi
callq 0x22e0
xorl %edi, %edi
callq 0x2300
cmpq $0x0, -0x40(%rbp)
je 0x283e
movq -0x40(%rbp), %rdi
callq 0x5080
movq -0x18(%rbp), %rdi
callq 0x50d0
movl -0x34(%rbp), %edi
callq 0x2430
cmpl $0x0, %eax
je 0x288d
jmp 0x2856
callq 0x2040
cmpl $0x0, (%rax)
je 0x287b
leaq 0x783f(%rip), %rdi      # 0xa0a6
movb $0x0, %al
callq 0x7ac0
callq 0x2040
movl $0x0, (%rax)
jmp 0x2889
leaq 0x7824(%rip), %rdi      # 0xa0a6
movb $0x0, %al
callq 0x7d10
jmp 0x288b
jmp 0x288d
jmp 0x288f
movq -0x30(%rbp), %rdi
callq 0x6a80
movq -0x28(%rbp), %rdi
callq 0x22e0
movl $0x1, %edi
callq 0x2300
nopl (%rax,%rax)