#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 *);
scalar_t__ 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;
  for (int i = 0; i < 10; i++) {
    crypto_sign_keypair_nistp256schnorr(pk, sk);
    crypto_sign_nistp256schnorr(sm, &smlen, m, mlen, sk);
    if (crypto_sign_open_nistp256schnorr(m, &mlen, sm, smlen, pk)) {
      printf("0\n");
    } else {
      printf("1\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)
movl   $0x0,-0xb4(%rbp)
cmpl   $0xa,-0xb4(%rbp)
jge    128e <main+0x10e>
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>
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>
cmp    $0x0,%rax
je     1269 <main+0xe9>
lea    0xdae(%rip),%rdi
call   1040 <printf@plt>
jmp    1275 <main+0xf5>
lea    0xda0(%rip),%rdi
call   1040 <printf@plt>
jmp    127a <main+0xfa>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    11e4 <main+0x64>
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
cltq
mov    %rax,(%rsp)
mov    $0xa,%r13d
lea    0x10(%rsp),%r15
lea    0x50(%rsp),%r12
lea    0xe34(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <crypto_sign_keypair_nistp256schnorr@plt>
mov    (%rsp),%rcx
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
mov    %r14,%rdx
mov    %r12,%r8
call   1050 <crypto_sign_nistp256schnorr@plt>
mov    0x8(%rsp),%rcx
mov    %r14,%rdi
mov    %rsp,%rsi
mov    %rbx,%rdx
mov    %r15,%r8
call   1080 <crypto_sign_open_nistp256schnorr@plt>
test   %rax,%rax
mov    %rbp,%rdi
lea    0xde8(%rip),%rax
cmove  %rax,%rdi
call   1030 <puts@plt>
add    $0xffffffff,%r13d
jne    11e0 <main+0x60>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Hello World!\00"
@.str.1 = [3 x i8] c"0\0A\00"
@.str.2 = [3 x i8] c"1\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
store i32 0, i32* %8
br label %18
18: ; preds = %41, %0
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 10
br i1 %20, label %21, label %44
21: ; preds = %18
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%24 = call i32 @crypto_sign_keypair_nistp256schnorr(i8* %22, i8* %23)
%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)
%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 i64 @crypto_sign_open_nistp256schnorr(i8* %30, i64* %7, i8* %31, i64 %32, i8* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %21
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %40
38: ; preds = %21
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %40
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %18
44: ; preds = %18
%45 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"Hello World!\00"
@str = [2 x i8] c"1\00"
@str.3 = [2 x i8] c"0\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
br label %18
16: ; preds = %18
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %0, %18
%19 = phi i32 [ 0, %0 ], [ %28, %18 ]
%20 = call i32 @crypto_sign_keypair_nistp256schnorr(i8* %6, i8* %5)
%21 = load i64, i64* %4
%22 = call i32 @crypto_sign_nistp256schnorr(i8* %10, i64* %3, i8* %7, i64 %21, i8* %5)
%23 = load i64, i64* %3
%24 = call i64 @crypto_sign_open_nistp256schnorr(i8* %7, i64* %4, i8* %10, i64 %23, i8* %6)
%25 = icmp eq i64 %24, 0
%26 = select i1 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0)
%27 = call i32 @puts(i8* dereferenceable(1) %26)
%28 = add nuw nsw i32 %19, 1
%29 = icmp eq i32 %28, 10
br i1 %29, label %16, label %18
}