#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int crypto_dh_sanitycheck(int /*<<< orphan*/ const *);
scalar_t__ crypto_verify_bytes(int /*<<< orphan*/ const *, int /*<<< orphan*/ *,
                               int);
int /*<<< orphan*/ libcperciva_HMAC_SHA256_Buf(int /*<<< orphan*/ const *, int,
                                               int /*<<< orphan*/ const *, int,
                                               int /*<<< orphan*/ *);
int proto_crypt_dh_validate(const uint8_t yh_r[(256 + 32)],
                            const uint8_t dhmac_r[32]) {
  uint8_t hbuf[32];
  libcperciva_HMAC_SHA256_Buf(dhmac_r, 32, yh_r, 256, hbuf);
  if (crypto_verify_bytes(&yh_r[256], hbuf, 32))
    return (1);
  return (crypto_dh_sanitycheck(&yh_r[0]));
}


x86 assembly (clang, -O0):
<proto_crypt_dh_validate>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    -0xa0(%rbp),%r8
mov    $0x20,%esi
mov    $0x100,%ecx
call   1040 <libcperciva_HMAC_SHA256_Buf@plt>
mov    -0x10(%rbp),%rdi
add    $0x400,%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x20,%edx
call   1050 <crypto_verify_bytes@plt>
cmp    $0x0,%rax
je     1193 <proto_crypt_dh_validate+0x63>
movl   $0x1,-0x4(%rbp)
jmp    119f <proto_crypt_dh_validate+0x6f>
mov    -0x10(%rbp),%rdi
call   1030 <crypto_dh_sanitycheck@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proto_crypt_dh_validate>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %rsi,%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
mov    $0x100,%ecx
mov    %r14,%r8
call   1040 <libcperciva_HMAC_SHA256_Buf@plt>
lea    0x400(%rbx),%rdi
mov    %r14,%rsi
mov    $0x20,%edx
call   1050 <crypto_verify_bytes@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1181 <proto_crypt_dh_validate+0x51>
mov    %rbx,%rdi
call   1030 <crypto_dh_sanitycheck@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @proto_crypt_dh_validate(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [32 x i32]
store i32* %0, i32** %4
store i32* %1, i32** %5
%7 = load i32*, i32** %5
%8 = load i32*, i32** %4
%9 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%10 = call i32 @libcperciva_HMAC_SHA256_Buf(i32* %7, i32 32, i32* %8, i32 256, i32* %9)
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 256
%13 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%14 = call i64 @crypto_verify_bytes(i32* %12, i32* %13, i32 32)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 1, i32* %3
br label %21
17: ; preds = %2
%18 = load i32*, i32** %4
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = call i32 @crypto_dh_sanitycheck(i32* %19)
store i32 %20, i32* %3
br label %21
21: ; preds = %17, %16
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
define i32 @proto_crypt_dh_validate(i32* %0, i32* %1) {
%3 = alloca [32 x i32]
%4 = bitcast [32 x i32]* %3 to i8*
%5 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%6 = call i32 @libcperciva_HMAC_SHA256_Buf(i32* %1, i32 32, i32* %0, i32 256, i32* %5)
%7 = getelementptr inbounds i32, i32* %0, i64 256
%8 = call i64 @crypto_verify_bytes(i32* %7, i32* %5, i32 32)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @crypto_dh_sanitycheck(i32* %0)
br label %12
12: ; preds = %2, %10
%13 = phi i32 [ %11, %10 ], [ 1, %2 ]
ret i32 %13
}