// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0xc0(%rbp)
leaq 0x69bc(%rip), %rdi      # 0x95a5
callq 0x2870
movq -0x10(%rbp), %rax
leaq -0x60(%rbp), %rdx
leaq -0x80(%rbp), %rcx
leaq -0x30(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movq (%rax), %r8
movq %r8, (%rsp)
movq 0x8(%rax), %r8
movq %r8, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x30d0
cmpl $0x0, %eax
je 0x2c48
jmp 0x2c2a
leaq 0x6451(%rip), %rdi      # 0x9082
movb $0x0, %al
callq 0x7b30
callq 0x2170
movl $0x0, (%rax)
jmp 0x2e77
callq 0x5720
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x2c5c
jmp 0x2e77
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x5760
movq $0x0, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x2e46
movq -0x10(%rbp), %rax
imulq $0x18, -0xb0(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x2190
cmpl $0x0, %eax
je 0x2ccb
leaq 0x6d30(%rip), %rdi      # 0x99e3
leaq 0x6454(%rip), %rsi      # 0x910e
movl $0x1f8, %edx            # imm = 0x1F8
leaq 0x6914(%rip), %rcx      # 0x95da
callq 0x2090
movq -0x10(%rbp), %rax
imulq $0x18, -0xb0(%rbp), %rcx
addq %rcx, %rax
leaq -0x60(%rbp), %rdx
leaq -0x80(%rbp), %rcx
leaq -0x38(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movq (%rax), %r8
movq %r8, (%rsp)
movq 0x8(%rax), %r8
movq %r8, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x30d0
cmpl $0x0, %eax
je 0x2d30
jmp 0x2d12
leaq 0x6369(%rip), %rdi      # 0x9082
movb $0x0, %al
callq 0x7b30
callq 0x2170
movl $0x0, (%rax)
jmp 0x2e65
movq -0xa8(%rbp), %rsi
shlq $0x3, %rsi
movq -0x10(%rbp), %rax
imulq $0x18, -0xb0(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
leaq 0x633c(%rip), %rdi      # 0x9091
movb $0x0, %al
callq 0x2030
movq -0x38(%rbp), %rdi
callq 0x36d0
movq -0x10(%rbp), %rax
imulq $0x18, -0xb0(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x2110
movq %rax, -0xb8(%rbp)
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x5760
movq -0x28(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
movq -0xb8(%rbp), %rcx
callq 0x59b0
leaq -0xa0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0x21a0
cmpl $0x0, %eax
je 0x2e1f
leaq 0x62e3(%rip), %rdi      # 0x90b6
movb $0x0, %al
callq 0x2030
leaq -0xa0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
leaq 0x62d1(%rip), %rdi      # 0x90c0
callq 0x3280
leaq -0x80(%rbp), %rsi
movq -0xb8(%rbp), %rdx
leaq 0x62c9(%rip), %rdi      # 0x90cf
callq 0x3280
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
jmp 0x2e2d
leaq 0x62b7(%rip), %rdi      # 0x90dd
movb $0x0, %al
callq 0x2030
jmp 0x2e2f
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x2c78
movq -0x28(%rbp), %rdi
callq 0x5cb0
movq -0x30(%rbp), %rdi
callq 0x36d0
movq -0xc0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2e7f
movq -0x28(%rbp), %rdi
callq 0x5cb0
movq -0x30(%rbp), %rdi
callq 0x36d0
movq $0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax)