#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_private_key_t {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int goldilocks_sign(unsigned char *, unsigned char const *, unsigned long long,
                    struct goldilocks_private_key_t const *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *,
                          unsigned long long);
int crypto_sign(unsigned char *sm, unsigned long long *smlen,
                const unsigned char *m, unsigned long long mlen,
                const unsigned char sk[(2 * (448 / 8) + 32)]) {
  int ret =
      goldilocks_sign(sm, m, mlen, (const struct goldilocks_private_key_t *)sk);
  if (ret)
    abort();
  memcpy(sm + (2 * (448 / 8)), m, mlen);
  *smlen = mlen + (2 * (448 / 8));
  return 0;
}


x86 assembly (clang, -O0):
<crypto_sign>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <goldilocks_sign@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1175 <crypto_sign+0x45>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rdi
add    $0x70,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x20(%rbp),%rcx
add    $0x70,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypto_sign>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %r8,%rcx
call   1040 <goldilocks_sign@plt>
test   %eax,%eax
jne    117d <crypto_sign+0x4d>
add    $0x70,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <memcpy@plt>
add    $0x70,%r12
mov    %r12,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.goldilocks_private_key_t = type { i32 }
define i32 @crypto_sign(i8* %0, i64* %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %6
store i64* %1, i64** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i8* %4, i8** %10
%12 = load i8*, i8** %6
%13 = load i8*, i8** %8
%14 = load i64, i64* %9
%15 = load i8*, i8** %10
%16 = bitcast i8* %15 to %struct.goldilocks_private_key_t*
%17 = call i32 @goldilocks_sign(i8* %12, i8* %13, i64 %14, %struct.goldilocks_private_key_t* %16)
store i32 %17, i32* %11
%18 = load i32, i32* %11
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %5
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %5
%23 = load i8*, i8** %6
%24 = getelementptr inbounds i8, i8* %23, i64 112
%25 = load i8*, i8** %8
%26 = load i64, i64* %9
%27 = call i32 @memcpy(i8* %24, i8* %25, i64 %26)
%28 = load i64, i64* %9
%29 = add i64 %28, 112
%30 = load i64*, i64** %7
store i64 %29, i64* %30
ret i32 0
}

LLVM IR (-O2):
%struct.goldilocks_private_key_t = type { i32 }
define i32 @crypto_sign(i8* %0, i64* nocapture writeonly %1, i8* %2, i64 %3, i8* %4) {
%6 = bitcast i8* %4 to %struct.goldilocks_private_key_t*
%7 = tail call i32 @goldilocks_sign(i8* %0, i8* %2, i64 %3, %struct.goldilocks_private_key_t* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 (...) @abort()
unreachable
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %0, i64 112
%13 = tail call i32 @memcpy(i8* %12, i8* %2, i64 %3)
%14 = add i64 %3, 112
store i64 %14, i64* %1
ret i32 0
}