// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]spiped/perftests/standalone-enc/../../lib/proto/proto_crypt.c
// Function: proto_crypt_mkkeys
int
proto_crypt_mkkeys(const struct proto_secret * K,
    const uint8_t nonce_l[PCRYPT_NONCE_LEN],
    const uint8_t nonce_r[PCRYPT_NONCE_LEN],
    const uint8_t yh_r[PCRYPT_YH_LEN], const uint8_t x[PCRYPT_X_LEN],
    int nopfs, int decr,
    struct proto_keys ** eh_c, struct proto_keys ** eh_s)
{
	uint8_t nonce_y[PCRYPT_NONCE_LEN * 2 + CRYPTO_DH_KEYLEN];
	uint8_t dk_2[128];
	const uint8_t * nonce_c, * nonce_s;

	/* Copy in nonces (in the right order). */
	nonce_c = decr ? nonce_r : nonce_l;
	nonce_s = decr ? nonce_l : nonce_r;
	memcpy(&nonce_y[0], nonce_c, PCRYPT_NONCE_LEN);
	memcpy(&nonce_y[PCRYPT_NONCE_LEN], nonce_s, PCRYPT_NONCE_LEN);

	/* Are we bypassing the diffie-hellman computation? */
	if (nopfs) {
		/* We sent y_l = 1, so y_SC is also 1. */
		memset(&nonce_y[PCRYPT_NONCE_LEN * 2], 0,
		    CRYPTO_DH_KEYLEN - 1);
		nonce_y[PCRYPT_NONCE_LEN * 2 + CRYPTO_DH_KEYLEN - 1] = 1;
	} else {
		/* Perform the diffie-hellman computation. */
		if (crypto_dh_compute(yh_r, x,
		    &nonce_y[PCRYPT_NONCE_LEN * 2]))
			goto err0;
	}

	/* Compute dk_2. */
	PBKDF2_SHA256(K->K, 32, nonce_y,
	    PCRYPT_NONCE_LEN * 2 + CRYPTO_DH_KEYLEN, 1, dk_2, 128);

	/* Create key structures. */
	if ((*eh_c = mkkeypair(&dk_2[0])) == NULL)
		goto err0;
	if ((*eh_s = mkkeypair(&dk_2[64])) == NULL)
		goto err1;

	/* Success! */
	return (0);

err1:
	proto_crypt_free(*eh_c);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
cmpl $0x0, 0x10(%rbp)
je 0x5061
movq -0x20(%rbp), %rax
movq %rax, -0x218(%rbp)
jmp 0x506c
movq -0x18(%rbp), %rax
movq %rax, -0x218(%rbp)
movq -0x218(%rbp), %rax
movq %rax, -0x208(%rbp)
cmpl $0x0, 0x10(%rbp)
je 0x508d
movq -0x18(%rbp), %rax
movq %rax, -0x220(%rbp)
jmp 0x5098
movq -0x20(%rbp), %rax
movq %rax, -0x220(%rbp)
movq -0x220(%rbp), %rax
movq %rax, -0x210(%rbp)
movq -0x208(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x180(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x178(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x170(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x168(%rbp)
movq -0x210(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x160(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x158(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x150(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x148(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x512d
leaq -0x180(%rbp), %rdi
addq $0x40, %rdi
xorl %esi, %esi
movl $0xff, %edx
callq 0x2080
movb $0x1, -0x41(%rbp)
jmp 0x5151
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq -0x180(%rbp), %rdx
addq $0x40, %rdx
callq 0x10cc0
cmpl $0x0, %eax
je 0x514f
jmp 0x51cf
jmp 0x5151
movq -0x10(%rbp), %rdi
leaq -0x180(%rbp), %rdx
leaq -0x200(%rbp), %r9
movl $0x20, %esi
movl $0x140, %ecx            # imm = 0x140
movl $0x1, %r8d
movq $0x80, (%rsp)
callq 0x5f40
leaq -0x200(%rbp), %rdi
callq 0x4950
movq 0x18(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x519b
jmp 0x51cf
leaq -0x200(%rbp), %rdi
addq $0x40, %rdi
callq 0x4950
movq 0x20(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x51ba
jmp 0x51c3
movl $0x0, -0x4(%rbp)
jmp 0x51d6
movq 0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x51f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nopw %cs:(%rax,%rax)