// File: /workspace/github_c_makefile_star2_O3/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 0x385c(%rip), %rdi      # 0x662f
callq 0x2b88
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 0x36fa
testl %eax, %eax
je 0x2e36
leaq 0x3313(%rip), %rdi      # 0x6120
xorl %eax, %eax
callq 0x54b7
callq 0x21c0
movl $0x0, (%rax)
movl $0x1, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x41a0
movq %rax, %r12
movl $0x1, %eax
testq %r12, %r12
je 0x2e24
movq %rbx, 0x38(%rsp)
movq 0x48(%rsp), %rsi
movq %r12, %rdi
movq %rsi, 0x18(%rsp)
xorl %edx, %edx
callq 0x41aa
leaq 0x70(%rsp), %r14
xorl %ebx, %ebx
movq $0x0, 0x20(%rsp)
movq %r12, 0x30(%rsp)
movq (%r15,%rbx), %rdi
movq (%r15), %rsi
callq 0x21e0
testl %eax, %eax
jne 0x2fd8
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 0x36fa
testl %eax, %eax
jne 0x2fa8
movq 0x28(%rsp), %rsi
shlq $0x3, %rsi
movq 0x8(%r15,%rbx), %rdx
leaq 0x325a(%rip), %rdi      # 0x612f
xorl %eax, %eax
callq 0x2030
movq 0x40(%rsp), %rdi
callq 0x3a5b
movq 0x8(%r15,%rbx), %rdi
callq 0x2140
movq %rax, %rbp
movq %r12, %rdi
xorl %esi, %esi
movq 0x38(%rsp), %rdx
callq 0x41aa
movq %r12, %rdi
movq %r14, %r12
movq %r14, %rsi
leaq 0x90(%rsp), %r14
movq %r14, %rdx
movq %rbp, %rcx
callq 0x4292
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2170
testl %eax, %eax
je 0x2f67
leaq 0x382b(%rip), %rdi      # 0x6762
callq 0x2080
leaq 0x3211(%rip), %rdi      # 0x6154
movq %r14, %rsi
movq %rbp, %rdx
callq 0x386d
leaq 0x320e(%rip), %rdi      # 0x6163
movq %r13, %rsi
movq %rbp, %rdx
callq 0x386d
incq 0x20(%rsp)
jmp 0x2f73
leaq 0x37eb(%rip), %rdi      # 0x6759
callq 0x2080
addq $0x18, %rbx
cmpq $0xd8, %rbx
movq %r12, %r14
movq 0x30(%rsp), %r12
jne 0x2e76
movq %r12, %rdi
callq 0x44fc
movq 0x18(%rsp), %rdi
callq 0x3a5b
movq 0x20(%rsp), %rax
jmp 0x2e24
leaq 0x3171(%rip), %rdi      # 0x6120
xorl %eax, %eax
callq 0x54b7
callq 0x21c0
movl $0x0, (%rax)
movq %r12, %rdi
callq 0x44fc
movq 0x18(%rsp), %rdi
callq 0x3a5b
jmp 0x2e1f
leaq 0x3ac4(%rip), %rdi      # 0x6aa3
leaq 0x31b2(%rip), %rsi      # 0x6198
leaq 0x3677(%rip), %rcx      # 0x6664
movl $0x1f8, %edx            # imm = 0x1F8
callq 0x20a0