// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]libcperciva/tests/crypto_aesctr/main.c
// Function: selftest_cases_singleobj
static size_t
selftest_cases_singleobj(const struct testcase * tests, size_t num_tests,
    uint64_t nonce)
{
	struct crypto_aesctr * aesctr;
	struct crypto_aes_key * key_orig;
	struct crypto_aes_key * key_exp;
	uint8_t plaintext_arr[MAX_PLAINTEXT_LENGTH];
	uint8_t ciphertext_arr[MAX_PLAINTEXT_LENGTH];
	uint8_t cbuf[MAX_PLAINTEXT_LENGTH];
	size_t keylen;
	size_t i;
	size_t len;
	size_t failures = 0;

	/* Inform user about the hardware optimization status. */
	print_hardware("Checking test vectors of AES reusing the same object");

	/* Get the first test case. */
	if (parse_testcase(tests[0], &key_orig, &keylen, plaintext_arr,
	    ciphertext_arr)) {
		warn0("parse_testcase");
		goto err0;
	}

	/* Create the AES-CTR object. */
	if ((aesctr = crypto_aesctr_alloc()) == NULL)
		goto err0;
	crypto_aesctr_init2(aesctr, key_orig, 0);

	/* Run regular test cases. */
	for (i = 0; i < num_tests; i++) {
		/*
		 * Sanity check: the current design of this function
		 * assumes that all keys are the same.  If we change the
		 * test cases to have different keys, we'll need to
		 * revisit the organization of this test.
		 */
		if (strcmp(tests[i].keytext_hex, tests[0].keytext_hex))
			assert(0);

		/* Prepare for the test case. */
		if (parse_testcase(tests[i], &key_exp, &keylen,
		    plaintext_arr, ciphertext_arr)) {
			warn0("parse_testcase");
			goto err1;
		}
		printf("Computing %zu-bit AES-CTR of \"%s\"...",
		    keylen * 8, tests[i].plaintext_str);

		/* We don't need this key. */
		crypto_aes_key_free(key_exp);

		/* Plaintext length. */
		len = strlen(tests[i].plaintext_str);

		/* Encrypt with AES-CTR, re-using the same object. */
		crypto_aesctr_init2(aesctr, NULL, nonce);
		crypto_aesctr_stream(aesctr, plaintext_arr, cbuf, len);

		/* Check result. */
		if (memcmp(cbuf, ciphertext_arr, len)) {
			printf(" FAILED!\n");
			print_arr("Computed AES:\t", cbuf, len);
			print_arr("Correct AES:\t", ciphertext_arr, len);
			failures++;
		} else {
			printf(" PASSED!\n");
		}
	}

	/* Clean up. */
	crypto_aesctr_free(aesctr);
	crypto_aes_key_free(key_orig);

	return (failures);

err1:
	crypto_aesctr_free(aesctr);
	crypto_aes_key_free(key_orig);
err0:
	/* Failure! */
	return (1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x2c70(%rip), %rdi      # 0x5563
callq 0x26ae
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x70(%rsp), %rdx
leaq 0x50(%rsp), %rcx
callq 0x2cb3
testl %eax, %eax
je 0x2951
leaq 0x2727(%rip), %rdi      # 0x5054
xorl %eax, %eax
callq 0x4b64
callq 0x21c0
andl $0x0, (%rax)
pushq $0x1
popq %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3708
movq %rax, %r12
pushq $0x1
popq %rax
testq %r12, %r12
je 0x293f
movq %rbx, 0x38(%rsp)
movq 0x48(%rsp), %rsi
movq %r12, %rdi
movq %rsi, 0x18(%rsp)
xorl %edx, %edx
callq 0x3710
leaq 0x70(%rsp), %r14
xorl %ebx, %ebx
movq $0x0, 0x20(%rsp)
movq %r12, 0x30(%rsp)
cmpq $0xd8, %rbx
je 0x2aaa
movq (%r15,%rbx), %rdi
movq (%r15), %rsi
callq 0x21e0
testl %eax, %eax
jne 0x2af3
leaq (%r15,%rbx), %rax
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movups (%rax), %xmm0
movups %xmm0, (%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r14, %rdx
leaq 0x50(%rsp), %r13
movq %r13, %rcx
callq 0x2cb3
testl %eax, %eax
jne 0x2ac6
movq 0x28(%rsp), %rsi
shlq $0x3, %rsi
movq 0x8(%r15,%rbx), %rdx
leaq 0x2668(%rip), %rdi      # 0x5063
xorl %eax, %eax
callq 0x2030
movq 0x40(%rsp), %rdi
callq 0x2ffa
movq 0x8(%r15,%rbx), %rdi
callq 0x2140
movq %rax, %rbp
movq %r12, %rdi
xorl %esi, %esi
movq 0x38(%rsp), %rdx
callq 0x3710
movq %r12, %rdi
movq %r14, %r12
movq %r14, %rsi
leaq 0x90(%rsp), %r14
movq %r14, %rdx
movq %rbp, %rcx
callq 0x37f7
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2170
testl %eax, %eax
je 0x2a8d
leaq 0x2c39(%rip), %rdi      # 0x5696
callq 0x2080
leaq 0x261f(%rip), %rdi      # 0x5088
movq %r14, %rsi
movq %rbp, %rdx
callq 0x2e1c
leaq 0x261c(%rip), %rdi      # 0x5097
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2e1c
incq 0x20(%rsp)
jmp 0x2a99
leaq 0x2bf9(%rip), %rdi      # 0x568d
callq 0x2080
addq $0x18, %rbx
movq %r12, %r14
movq 0x30(%rsp), %r12
jmp 0x298f
movq %r12, %rdi
callq 0x396b
movq 0x18(%rsp), %rdi
callq 0x2ffa
movq 0x20(%rsp), %rax
jmp 0x293f
leaq 0x2587(%rip), %rdi      # 0x5054
xorl %eax, %eax
callq 0x4b64
callq 0x21c0
andl $0x0, (%rax)
movq %r12, %rdi
callq 0x396b
movq 0x18(%rsp), %rdi
callq 0x2ffa
jmp 0x293c
leaq 0x2ed9(%rip), %rdi      # 0x59d3
leaq 0x25cb(%rip), %rsi      # 0x50cc
leaq 0x2a90(%rip), %rcx      # 0x5598
movl $0x1f8, %edx            # imm = 0x1F8
callq 0x20a0