#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 */

/* Variables and functions */
int /*<<< orphan*/ crypto_sign_keypair_nistp256schnorr(unsigned char *,
                                                       unsigned char *);
int /*<<< orphan*/ crypto_sign_nistp256schnorr(unsigned char *,
                                               unsigned long long *,
                                               unsigned char *,
                                               unsigned long long,
                                               unsigned char *);
int /*<<< orphan*/ crypto_sign_open_nistp256schnorr(unsigned char *,
                                                    unsigned long long *,
                                                    unsigned char *,
                                                    unsigned long long,
                                                    unsigned char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
unsigned char *malloc(int);
int /*<<< orphan*/ printf(char *);
unsigned char *strdup(char *);
int strlen(unsigned char *);
int main() {
  unsigned char sk[64];
  unsigned char pk[64];
  unsigned char *m = strdup("Hello World!");
  unsigned char *sm = malloc(strlen(m) + 65);
  unsigned long long smlen;
  unsigned long long mlen = strlen(m) + 1;
  crypto_sign_keypair_nistp256schnorr(pk, sk);
  crypto_sign_nistp256schnorr(sm, &smlen, m, mlen, sk);
  for (int i = 0; i < 10000; i++) {
    crypto_sign_open_nistp256schnorr(m, &mlen, sm, smlen, pk);
  }
  printf("10000 verifications completed\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
add    $0x41,%edi
call   1060 <malloc@plt>
mov    %rax,-0xa0(%rbp)
mov    -0x98(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0xb0(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <crypto_sign_keypair_nistp256schnorr@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x98(%rbp),%rdx
mov    -0xb0(%rbp),%rcx
lea    -0x50(%rbp),%r8
lea    -0xa8(%rbp),%rsi
call   1050 <crypto_sign_nistp256schnorr@plt>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2710,-0xb4(%rbp)
jge    1265 <main+0xe5>
mov    -0x98(%rbp),%rdi
mov    -0xa0(%rbp),%rdx
mov    -0xa8(%rbp),%rcx
lea    -0x90(%rbp),%r8
lea    -0xb0(%rbp),%rsi
call   1080 <crypto_sign_open_nistp256schnorr@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1219 <main+0x99>
lea    0xda1(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xe68(%rip),%rdi
call   10a0 <strdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0x41(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
movslq %eax,%r12
mov    %r12,(%rsp)
lea    0x10(%rsp),%r15
lea    0x50(%rsp),%r13
mov    %r15,%rdi
mov    %r13,%rsi
call   1070 <crypto_sign_keypair_nistp256schnorr@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1050 <crypto_sign_nistp256schnorr@plt>
mov    $0x2710,%ebp
mov    %rsp,%r12
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rcx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r15,%r8
call   1080 <crypto_sign_open_nistp256schnorr@plt>
add    $0xffffffff,%ebp
jne    1200 <main+0x80>
lea    0xdeb(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Hello World!\00"
@.str.1 = [31 x i8] c"10000 verifications completed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca [64 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %1
%9 = call i8* @strdup(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = add nsw i32 %11, 65
%13 = call i8* @malloc(i32 %12)
store i8* %13, i8** %5
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
store i64 %17, i64* %7
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%20 = call i32 @crypto_sign_keypair_nistp256schnorr(i8* %18, i8* %19)
%21 = load i8*, i8** %5
%22 = load i8*, i8** %4
%23 = load i64, i64* %7
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%25 = call i32 @crypto_sign_nistp256schnorr(i8* %21, i64* %6, i8* %22, i64 %23, i8* %24)
store i32 0, i32* %8
br label %26
26: ; preds = %35, %0
%27 = load i32, i32* %8
%28 = icmp slt i32 %27, 10000
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = load i64, i64* %6
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%34 = call i32 @crypto_sign_open_nistp256schnorr(i8* %30, i64* %7, i8* %31, i64 %32, i8* %33)
br label %35
35: ; preds = %29
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %26
38: ; preds = %26
%39 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"Hello World!\00"
@str = [30 x i8] c"10000 verifications completed\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca [64 x i8]
%3 = alloca i64
%4 = alloca i64
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%7 = tail call dereferenceable_or_null(13) i8* @strdup(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strlen(i8* %7)
%9 = add nsw i32 %8, 65
%10 = tail call i8* @malloc(i32 %9)
%11 = bitcast i64* %3 to i8*
%12 = bitcast i64* %4 to i8*
%13 = tail call i32 @strlen(i8* %7)
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
store i64 %15, i64* %4
%16 = call i32 @crypto_sign_keypair_nistp256schnorr(i8* %6, i8* %5)
%17 = call i32 @crypto_sign_nistp256schnorr(i8* %10, i64* %3, i8* %7, i64 %15, i8* %5)
br label %21
18: ; preds = %21
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %0, %21
%22 = phi i32 [ 0, %0 ], [ %25, %21 ]
%23 = load i64, i64* %3
%24 = call i32 @crypto_sign_open_nistp256schnorr(i8* %7, i64* %4, i8* %10, i64 %23, i8* %6)
%25 = add nuw nsw i32 %22, 1
%26 = icmp eq i32 %25, 10000
br i1 %26, label %18, label %21
}