#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 */
struct goldilocks_public_key_t {
  int dummy;
};
struct goldilocks_private_key_t {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int goldilocks_shared_secret(unsigned char *,
                             struct goldilocks_private_key_t const *,
                             struct goldilocks_public_key_t const *);
int sharedsecret(unsigned char s[64], unsigned long long *slen,
                 const unsigned char sk[(2 * (448 / 8) + 32)],
                 unsigned long long sklen, const unsigned char pk[(448 / 8)],
                 unsigned long long pklen) {
  if (pklen != (448 / 8))
    abort();
  if (sklen != (2 * (448 / 8) + 32))
    abort();
  int ret =
      goldilocks_shared_secret(s, (const struct goldilocks_private_key_t *)sk,
                               (const struct goldilocks_public_key_t *)pk);
  if (ret)
    return -1;
  *slen = 64;
  return 0;
}


x86 assembly (clang, -O0):
<sharedsecret>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpq   $0x38,-0x38(%rbp)
je     1152 <sharedsecret+0x32>
mov    $0x0,%al
call   1030 <abort@plt>
cmpq   $0x90,-0x28(%rbp)
je     1167 <sharedsecret+0x47>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1040 <goldilocks_shared_secret@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1191 <sharedsecret+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a3 <sharedsecret+0x83>
mov    -0x18(%rbp),%rax
movq   $0x40,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sharedsecret>:
push   %rbx
cmp    $0x38,%r9
jne    1156 <sharedsecret+0x36>
cmp    $0x90,%rcx
jne    1156 <sharedsecret+0x36>
mov    %rsi,%rbx
mov    %rdx,%rsi
mov    %r8,%rdx
call   1040 <goldilocks_shared_secret@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
je     114b <sharedsecret+0x2b>
pop    %rbx
ret
movq   $0x40,(%rbx)
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.goldilocks_private_key_t = type { i32 }
%struct.goldilocks_public_key_t = type { i32 }
define i32 @sharedsecret(i8* %0, i64* %1, i8* %2, i64 %3, i8* %4, i64 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
store i8* %0, i8** %8
store i64* %1, i64** %9
store i8* %2, i8** %10
store i64 %3, i64* %11
store i8* %4, i8** %12
store i64 %5, i64* %13
%15 = load i64, i64* %13
%16 = icmp ne i64 %15, 56
br i1 %16, label %17, label %19
17: ; preds = %6
%18 = call i32 (...) @abort()
unreachable
19: ; preds = %6
%20 = load i64, i64* %11
%21 = icmp ne i64 %20, 144
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %19
%25 = load i8*, i8** %8
%26 = load i8*, i8** %10
%27 = bitcast i8* %26 to %struct.goldilocks_private_key_t*
%28 = load i8*, i8** %12
%29 = bitcast i8* %28 to %struct.goldilocks_public_key_t*
%30 = call i32 @goldilocks_shared_secret(i8* %25, %struct.goldilocks_private_key_t* %27, %struct.goldilocks_public_key_t* %29)
store i32 %30, i32* %14
%31 = load i32, i32* %14
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %24
store i32 -1, i32* %7
br label %36
34: ; preds = %24
%35 = load i64*, i64** %9
store i64 64, i64* %35
store i32 0, i32* %7
br label %36
36: ; preds = %34, %33
%37 = load i32, i32* %7
ret i32 %37
}

LLVM IR (-O2):
%struct.goldilocks_private_key_t = type { i32 }
%struct.goldilocks_public_key_t = type { i32 }
define i32 @sharedsecret(i8* %0, i64* nocapture writeonly %1, i8* %2, i64 %3, i8* %4, i64 %5) {
%7 = icmp eq i64 %5, 56
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %6
%11 = icmp eq i64 %3, 144
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = tail call i32 (...) @abort()
unreachable
14: ; preds = %10
%15 = bitcast i8* %2 to %struct.goldilocks_private_key_t*
%16 = bitcast i8* %4 to %struct.goldilocks_public_key_t*
%17 = tail call i32 @goldilocks_shared_secret(i8* %0, %struct.goldilocks_private_key_t* %15, %struct.goldilocks_public_key_t* %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i64 64, i64* %1
br label %20
20: ; preds = %14, %19
%21 = phi i32 [ 0, %19 ], [ -1, %14 ]
ret i32 %21
}