// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]libcperciva/tests/crypto_aes/main.c
// Function: selftest
static int
selftest(void)
{
	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 failures = 0;
	size_t num_tests = sizeof(tests) / sizeof(tests[0]);
#ifdef CPUSUPPORT_X86_AESNI
	__m128i bufsse;
#endif
#ifdef CPUSUPPORT_ARM_AES
	uint8x16_t bufarm;
#endif

	/* Sanity check. */
#ifdef CPUSUPPORT_X86_AESNI
	if (cpusupport_x86_aesni()) {
		if (crypto_aes_can_use_intrinsics() != 1) {
			warn0("Unexpected error with AESNI");
			goto err0;
		}
	}
#endif

	/* 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 of \"%s\"...",
		    keylen * 8, tests[i].plaintext_hex);

		/* Run AES. */
#ifdef CPUSUPPORT_X86_AESNI
		if (crypto_aes_can_use_intrinsics() == 1) {
			bufsse = _mm_loadu_si128(
			    (const __m128i *)plaintext_arr);
			bufsse = crypto_aes_encrypt_block_aesni_m128i(bufsse,
			    key_exp);
			_mm_storeu_si128((__m128i *)cbuf, bufsse);
		} else
#endif
#ifdef CPUSUPPORT_ARM_AES
		if (crypto_aes_can_use_intrinsics() == 2) {
			bufarm = vld1q_u8(plaintext_arr);
			bufarm = crypto_aes_encrypt_block_arm_u8(bufarm,
			    key_exp);
			vst1q_u8(cbuf, bufarm);
		} else
#endif
		crypto_aes_encrypt_block(plaintext_arr, cbuf, key_exp);

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

		/* Clean up. */
		crypto_aes_key_free(key_exp);
	}

	/* Report overall success to exit code. */
	if (failures)
		return (1);
	else
		return (0);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x57bc(%rip), %rbx      # 0x721c
cmpl $0x0, (%rbx)
je 0x1a7b
callq 0x1f14
cmpl $0x1, %eax
je 0x1a8c
leaq 0x2594(%rip), %rdi      # 0x400a
jmp 0x1bbc
leaq 0x579e(%rip), %r14      # 0x7220
cmpl $0x0, (%r14)
je 0x1be2
leaq 0x273d(%rip), %rdi      # 0x41d0
callq 0x1c41
movb $0x1, %bpl
leaq 0x52fe(%rip), %r14      # 0x6da0
leaq 0x50(%rsp), %r15
leaq 0x40(%rsp), %r12
xorl %eax, %eax
xorl %r13d, %r13d
leaq (%rax,%rax,2), %rax
movq 0x10(%r14,%rax,8), %rcx
movq %rcx, 0x10(%rsp)
movups (%r14,%rax,8), %xmm0
movups %xmm0, (%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x1ca1
testl %eax, %eax
jne 0x1bb5
movq 0x38(%rsp), %rsi
shlq $0x3, %rsi
leaq 0x26f8(%rip), %rdi      # 0x41ed
leaq 0x2658(%rip), %rdx      # 0x4154
xorl %eax, %eax
callq 0x1030
callq 0x1f14
cmpl $0x1, %eax
jne 0x1b26
movaps 0x50(%rsp), %xmm0
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x2709
movaps %xmm0, 0x20(%rsp)
jmp 0x1b3b
movq 0x18(%rsp), %rbx
movq %r15, %rdi
leaq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x206d
movdqa 0x20(%rsp), %xmm0
pcmpeqb 0x40(%rsp), %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1b83
leaq 0x2779(%rip), %rdi      # 0x42d2
callq 0x1070
leaq 0x26a9(%rip), %rdi      # 0x420e
leaq 0x20(%rsp), %rsi
callq 0x1e9f
leaq 0x26a7(%rip), %rdi      # 0x421d
movq %r12, %rsi
callq 0x1e9f
incq %r13
jmp 0x1b8f
leaq 0x273f(%rip), %rdi      # 0x42c9
callq 0x1070
movq %rbx, %rdi
callq 0x207f
movl $0x1, %eax
testb $0x1, %bpl
movl $0x0, %ebp
jne 0x1ab1
xorl %eax, %eax
testq %r13, %r13
setne %al
jmp 0x1bd3
leaq 0x2482(%rip), %rdi      # 0x403e
xorl %eax, %eax
callq 0x34ff
callq 0x1190
movl $0x0, (%rax)
movl $0x1, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1eec
movl %eax, (%rbx)
movl $0x1, (%r14)
testl %eax, %eax
jne 0x1a65
jmp 0x1a8c