#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);
void signmessage(unsigned char *sm, unsigned long long *smlen,
                 const unsigned char *m, unsigned long long mlen,
                 const unsigned char sk[(2 * (448 / 8) + 32)],
                 unsigned long long sklen) {
  if (sklen != (2 * (448 / 8) + 32))
    abort();
  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));
}


x86 assembly (clang, -O0):
<signmessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x90,-0x30(%rbp)
je     1165 <signmessage+0x35>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <goldilocks_sign@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     118e <signmessage+0x5e>
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)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<signmessage>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x90,%r9
jne    1184 <signmessage+0x54>
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    1184 <signmessage+0x54>
add    $0x70,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <memcpy@plt>
add    $0x70,%r12
mov    %r12,(%r14)
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 void @signmessage(i8* %0, i64* %1, i8* %2, i64 %3, i8* %4, i64 %5) {
%7 = alloca i8*
%8 = alloca i64*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i8* %0, i8** %7
store i64* %1, i64** %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i8* %4, i8** %11
store i64 %5, i64* %12
%14 = load i64, i64* %12
%15 = icmp ne i64 %14, 144
br i1 %15, label %16, label %18
16: ; preds = %6
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %6
%19 = load i8*, i8** %7
%20 = load i8*, i8** %9
%21 = load i64, i64* %10
%22 = load i8*, i8** %11
%23 = bitcast i8* %22 to %struct.goldilocks_private_key_t*
%24 = call i32 @goldilocks_sign(i8* %19, i8* %20, i64 %21, %struct.goldilocks_private_key_t* %23)
store i32 %24, i32* %13
%25 = load i32, i32* %13
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %18
%28 = call i32 (...) @abort()
unreachable
29: ; preds = %18
%30 = load i8*, i8** %7
%31 = getelementptr inbounds i8, i8* %30, i64 112
%32 = load i8*, i8** %9
%33 = load i64, i64* %10
%34 = call i32 @memcpy(i8* %31, i8* %32, i64 %33)
%35 = load i64, i64* %10
%36 = add i64 %35, 112
%37 = load i64*, i64** %8
store i64 %36, i64* %37
ret void
}

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