// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]libcperciva/tests/crypto_aesctr/main.c
// Function: selftest_cases
static size_t
selftest_cases(const struct testcase * tests, size_t num_tests, uint64_t nonce)
{
	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");

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

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

		/* Encrypt with AES-CTR. */
		crypto_aesctr_buf(key_exp, nonce, 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_aes_key_free(key_exp);
	}

	return (failures);

err0:
	/* Failure! */
	return (1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0xb0(%rbp)
leaq 0x665c(%rip), %rdi      # 0x9065
callq 0x2870
movq $0x0, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x2b96
movq -0x10(%rbp), %rax
imulq $0x18, -0xa0(%rbp), %rcx
addq %rcx, %rax
leaq -0x50(%rbp), %rdx
leaq -0x70(%rbp), %rcx
leaq -0x28(%rbp), %rdi
leaq -0x98(%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 0x2a8f
jmp 0x2a71
leaq 0x660a(%rip), %rdi      # 0x9082
movb $0x0, %al
callq 0x7b30
callq 0x2170
movl $0x0, (%rax)
jmp 0x2ba3
movq -0x98(%rbp), %rsi
shlq $0x3, %rsi
movq -0x10(%rbp), %rax
imulq $0x18, -0xa0(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
leaq 0x65dd(%rip), %rdi      # 0x9091
movb $0x0, %al
callq 0x2030
movq -0x10(%rbp), %rax
imulq $0x18, -0xa0(%rbp), %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x2110
movq %rax, -0xa8(%rbp)
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0x50(%rbp), %rdx
leaq -0x90(%rbp), %rcx
movq -0xa8(%rbp), %r8
callq 0x5d20
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movq -0xa8(%rbp), %rdx
callq 0x21a0
cmpl $0x0, %eax
je 0x2b68
leaq 0x659a(%rip), %rdi      # 0x90b6
movb $0x0, %al
callq 0x2030
leaq -0x90(%rbp), %rsi
movq -0xa8(%rbp), %rdx
leaq 0x6588(%rip), %rdi      # 0x90c0
callq 0x3280
leaq -0x70(%rbp), %rsi
movq -0xa8(%rbp), %rdx
leaq 0x6580(%rip), %rdi      # 0x90cf
callq 0x3280
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x2b76
leaq 0x656e(%rip), %rdi      # 0x90dd
movb $0x0, %al
callq 0x2030
movq -0x28(%rbp), %rdi
callq 0x36d0
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x2a19
movq -0xb0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2bab
movq $0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax,%rax)