#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*/ 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);
  for (int i = 0; i < 10000; i++) {
    crypto_sign_nistp256schnorr(sm, &smlen, m, mlen, sk);
  }
  printf("10000 signatures completed\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
call   1090 <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>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2710,-0xb4(%rbp)
jge    122d <main+0xbd>
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>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    11e4 <main+0x74>
lea    0xdd9(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

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

LLVM IR (-O0):
@.str = [13 x i8] c"Hello World!\00"
@.str.1 = [28 x i8] c"10000 signatures 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)
store i32 0, i32* %8
br label %21
21: ; preds = %30, %0
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 10000
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = load i8*, i8** %5
%26 = load i8*, i8** %4
%27 = load i64, i64* %7
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%29 = call i32 @crypto_sign_nistp256schnorr(i8* %25, i64* %6, i8* %26, i64 %27, i8* %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %21
33: ; preds = %21
%34 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @exit(i32 0)
unreachable
}

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