// File: /workspace/github_c_makefile_star2_O1/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 0x37d7(%rip), %rdi      # 0x6563
callq 0x2b41
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 0x316d
testl %eax, %eax
je 0x2def
leaq 0x328e(%rip), %rdi      # 0x6054
xorl %eax, %eax
callq 0x4e37
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 0x3be4
movq %rax, %r12
movl $0x1, %eax
testq %r12, %r12
je 0x2ddd
movq %rbx, 0x38(%rsp)
movq 0x48(%rsp), %rsi
movq %r12, %rdi
movq %rsi, 0x18(%rsp)
xorl %edx, %edx
callq 0x3bee
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 0x2f91
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 0x316d
testl %eax, %eax
jne 0x2f61
movq 0x28(%rsp), %rsi
shlq $0x3, %rsi
movq 0x8(%r15,%rbx), %rdx
leaq 0x31d5(%rip), %rdi      # 0x6063
xorl %eax, %eax
callq 0x2030
movq 0x40(%rsp), %rdi
callq 0x34cf
movq 0x8(%r15,%rbx), %rdi
callq 0x2140
movq %rax, %rbp
movq %r12, %rdi
xorl %esi, %esi
movq 0x38(%rsp), %rdx
callq 0x3bee
movq %r12, %rdi
movq %r14, %r12
movq %r14, %rsi
leaq 0x90(%rsp), %r14
movq %r14, %rdx
movq %rbp, %rcx
callq 0x3cdb
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2170
testl %eax, %eax
je 0x2f20
leaq 0x37a6(%rip), %rdi      # 0x6696
callq 0x2080
leaq 0x318c(%rip), %rdi      # 0x6088
movq %r14, %rsi
movq %rbp, %rdx
callq 0x32e0
leaq 0x3189(%rip), %rdi      # 0x6097
movq %r13, %rsi
movq %rbp, %rdx
callq 0x32e0
incq 0x20(%rsp)
jmp 0x2f2c
leaq 0x3766(%rip), %rdi      # 0x668d
callq 0x2080
addq $0x18, %rbx
cmpq $0xd8, %rbx
movq %r12, %r14
movq 0x30(%rsp), %r12
jne 0x2e2f
movq %r12, %rdi
callq 0x3f3a
movq 0x18(%rsp), %rdi
callq 0x34cf
movq 0x20(%rsp), %rax
jmp 0x2ddd
leaq 0x30ec(%rip), %rdi      # 0x6054
xorl %eax, %eax
callq 0x4e37
callq 0x21c0
movl $0x0, (%rax)
movq %r12, %rdi
callq 0x3f3a
movq 0x18(%rsp), %rdi
callq 0x34cf
jmp 0x2dd8
leaq 0x3a3b(%rip), %rdi      # 0x69d3
leaq 0x312d(%rip), %rsi      # 0x60cc
leaq 0x35f2(%rip), %rcx      # 0x6598
movl $0x1f8, %edx            # imm = 0x1F8
callq 0x20a0