#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ FindMarker(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ ReadHex(int /*<<< orphan*/ *, unsigned char *, int, char *);
int crypto_kem_dec_SIKEp503_compressed(unsigned char *, unsigned char *,
                                       unsigned char *);
int crypto_kem_enc_SIKEp503_compressed(unsigned char *, unsigned char *,
                                       unsigned char *);
int crypto_kem_keypair_SIKEp503_compressed(unsigned char *, unsigned char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ randombytes_init(unsigned char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main() {
  char fn_rsp[32];
  FILE *fp_rsp;
  unsigned char seed[48];
  unsigned char ct[280], ss[24], ss1[24], ct_rsp[280], ss_rsp[24];
  int count;
  int done;
  unsigned char pk[225], sk[407], pk_rsp[225], sk_rsp[407];
  int ret_val;
  sprintf(fn_rsp, "KAT/PQCkemKAT_%d.rsp", 407);
  if ((fp_rsp = fopen(fn_rsp, "r")) == NULL) {
    printf("Couldn't open <%s> for read\n", fn_rsp);
    return -1;
  }
  printf("# %s\n\n", "SIKEp503_compressed");
  done = 0;
  do {
    if (FindMarker(fp_rsp, "count = ")) {
      if (fscanf(fp_rsp, "%d", &count) != 1) {
        done = 1;
        break;
      }
    } else {
      done = 1;
      break;
    }
    if (!ReadHex(fp_rsp, seed, 48, "seed = ")) {
      printf("ERROR: unable to read 'seed' from <%s>\n", fn_rsp);
      return -3;
    }
    randombytes_init(seed, NULL, 256);
    if ((ret_val = crypto_kem_keypair_SIKEp503_compressed(pk, sk)) != 0) {
      printf("crypto_kem_keypair returned <%d>\n", ret_val);
      return -4;
    }
    if (!ReadHex(fp_rsp, pk_rsp, 225, "pk = ")) {
      printf("ERROR: unable to read 'pk' from <%s>\n", fn_rsp);
      return -3;
    }
    if (!ReadHex(fp_rsp, sk_rsp, 407, "sk = ")) {
      printf("ERROR: unable to read 'sk' from <%s>\n", fn_rsp);
      return -3;
    }
    if (memcmp(pk, pk_rsp, 225) != 0) {
      printf("ERROR: pk is different from <%s>\n", fn_rsp);
      return -2;
    }
    if (memcmp(sk, sk_rsp, 407) != 0) {
      printf("ERROR: sk is different from <%s>\n", fn_rsp);
      return -2;
    }
    if ((ret_val = crypto_kem_enc_SIKEp503_compressed(ct, ss, pk)) != 0) {
      printf("crypto_kem_enc returned <%d>\n", ret_val);
      return -4;
    }
    if (!ReadHex(fp_rsp, ct_rsp, 280, "ct = ")) {
      printf("ERROR: unable to read 'pk' from <%s>\n", fn_rsp);
      return -3;
    }
    if (!ReadHex(fp_rsp, ss_rsp, 24, "ss = ")) {
      printf("ERROR: unable to read 'sk' from <%s>\n", fn_rsp);
      return -3;
    }
    if (memcmp(ct, ct_rsp, 280) != 0) {
      printf("ERROR: ct is different from <%s>\n", fn_rsp);
      return -2;
    }
    if (memcmp(ss, ss_rsp, 24) != 0) {
      printf("ERROR: ss is different from <%s>\n", fn_rsp);
      return -2;
    }
    if ((ret_val = crypto_kem_dec_SIKEp503_compressed(ss1, ct, sk)) != 0) {
      printf("crypto_kem_dec returned <%d>\n", ret_val);
      return -4;
    }
    if (memcmp(ss, ss1, 24)) {
      printf("crypto_kem_dec returned bad 'ss' value\n");
      return -4;
    }
  } while (!done);
  fclose(fp_rsp);
  printf("Known Answer Tests PASSED. \n");
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe23(%rip),%rsi
mov    $0x197,%edx
call   10e0 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1223 <main+0x63>
lea    -0x30(%rbp),%rsi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1652 <main+0x492>
lea    0xe0a(%rip),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x318(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   10b0 <FindMarker@plt>
cmp    $0x0,%rax
je     1290 <main+0xd0>
mov    -0x38(%rbp),%rdi
lea    0xdf1(%rip),%rsi
lea    -0x314(%rbp),%rdx
call   1080 <fscanf@plt>
cmp    $0x1,%eax
je     128b <main+0xcb>
movl   $0x1,-0x318(%rbp)
jmp    1626 <main+0x466>
jmp    129f <main+0xdf>
movl   $0x1,-0x318(%rbp)
jmp    1626 <main+0x466>
mov    -0x38(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x30,%edx
lea    0xda8(%rip),%rcx
call   1060 <ReadHex@plt>
cmp    $0x0,%eax
jne    12df <main+0x11f>
lea    -0x30(%rbp),%rsi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1652 <main+0x492>
lea    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x100,%edx
call   10a0 <randombytes_init@plt>
lea    -0x400(%rbp),%rdi
lea    -0x5a0(%rbp),%rsi
call   10d0 <crypto_kem_keypair_SIKEp503_compressed@plt>
mov    %eax,-0x834(%rbp)
cmp    $0x0,%eax
je     1333 <main+0x173>
mov    -0x834(%rbp),%esi
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    1652 <main+0x492>
mov    -0x38(%rbp),%rdi
lea    -0x690(%rbp),%rsi
mov    $0xe1,%edx
lea    0xd63(%rip),%rcx
call   1060 <ReadHex@plt>
cmp    $0x0,%eax
jne    1376 <main+0x1b6>
lea    -0x30(%rbp),%rsi
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1652 <main+0x492>
mov    -0x38(%rbp),%rdi
lea    -0x830(%rbp),%rsi
mov    $0x197,%edx
lea    0xd4c(%rip),%rcx
call   1060 <ReadHex@plt>
cmp    $0x0,%eax
jne    13b9 <main+0x1f9>
lea    -0x30(%rbp),%rsi
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1652 <main+0x492>
lea    -0x400(%rbp),%rdi
lea    -0x690(%rbp),%rsi
mov    $0xe1,%edx
call   1090 <memcmp@plt>
cmp    $0x0,%rax
je     13f9 <main+0x239>
lea    -0x30(%rbp),%rsi
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1652 <main+0x492>
lea    -0x5a0(%rbp),%rdi
lea    -0x830(%rbp),%rsi
mov    $0x197,%edx
call   1090 <memcmp@plt>
cmp    $0x0,%rax
je     1439 <main+0x279>
lea    -0x30(%rbp),%rsi
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1652 <main+0x492>
lea    -0x190(%rbp),%rdi
lea    -0x1b0(%rbp),%rsi
lea    -0x400(%rbp),%rdx
call   1030 <crypto_kem_enc_SIKEp503_compressed@plt>
mov    %eax,-0x834(%rbp)
cmp    $0x0,%eax
je     1482 <main+0x2c2>
mov    -0x834(%rbp),%esi
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    1652 <main+0x492>
mov    -0x38(%rbp),%rdi
lea    -0x2f0(%rbp),%rsi
mov    $0x118,%edx
lea    0xcce(%rip),%rcx
call   1060 <ReadHex@plt>
cmp    $0x0,%eax
jne    14c5 <main+0x305>
lea    -0x30(%rbp),%rsi
lea    0xc01(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1652 <main+0x492>
mov    -0x38(%rbp),%rdi
lea    -0x310(%rbp),%rsi
mov    $0x18,%edx
lea    0xc91(%rip),%rcx
call   1060 <ReadHex@plt>
cmp    $0x0,%eax
jne    1508 <main+0x348>
lea    -0x30(%rbp),%rsi
lea    0xbea(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1652 <main+0x492>
lea    -0x190(%rbp),%rdi
lea    -0x2f0(%rbp),%rsi
mov    $0x118,%edx
call   1090 <memcmp@plt>
cmp    $0x0,%rax
je     1548 <main+0x388>
lea    -0x30(%rbp),%rsi
lea    0xc3e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1652 <main+0x492>
lea    -0x1b0(%rbp),%rdi
lea    -0x310(%rbp),%rsi
mov    $0x18,%edx
call   1090 <memcmp@plt>
cmp    $0x0,%rax
je     1588 <main+0x3c8>
lea    -0x30(%rbp),%rsi
lea    0xc20(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1652 <main+0x492>
lea    -0x1d0(%rbp),%rdi
lea    -0x190(%rbp),%rsi
lea    -0x5a0(%rbp),%rdx
call   1040 <crypto_kem_dec_SIKEp503_compressed@plt>
mov    %eax,-0x834(%rbp)
cmp    $0x0,%eax
je     15d1 <main+0x411>
mov    -0x834(%rbp),%esi
lea    0xbf9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    1652 <main+0x492>
lea    -0x1b0(%rbp),%rdi
lea    -0x1d0(%rbp),%rsi
mov    $0x18,%edx
call   1090 <memcmp@plt>
cmp    $0x0,%rax
je     160d <main+0x44d>
lea    0xbdb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    1652 <main+0x492>
jmp    1612 <main+0x452>
cmpl   $0x0,-0x318(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1242 <main+0x82>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xbc7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0x9f4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
lea    0xe18(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x197,%edx
call   10f0 <sprintf@plt>
lea    0xe16(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1443 <main+0x273>
mov    %rax,%r13
lea    0xe1a(%rip),%rdi
lea    0xe1a(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe20(%rip),%rsi
lea    0x680(%rsp),%r12
lea    0x4e0(%rsp),%r14
lea    0x3c0(%rsp),%rbp
mov    %r13,%rdi
call   10c0 <FindMarker@plt>
test   %rax,%rax
je     145e <main+0x28e>
mov    %r13,%rdi
lea    0xdf6(%rip),%rsi
lea    0x2c(%rsp),%rdx
call   1090 <fscanf@plt>
cmp    $0x1,%eax
jne    145e <main+0x28e>
mov    %rbp,%r15
mov    %r13,%rdi
mov    %r12,%r13
mov    %r14,%rbx
lea    0x1b0(%rsp),%r14
mov    %rdi,%rbp
lea    0x90(%rsp),%r12
mov    %r12,%rsi
mov    $0x30,%edx
lea    0xdb8(%rip),%rcx
call   1070 <ReadHex@plt>
test   %eax,%eax
je     1497 <main+0x2c7>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10b0 <randombytes_init@plt>
lea    0xc0(%rsp),%rdi
mov    %r13,%r12
mov    %r13,%rsi
call   10e0 <crypto_kem_keypair_SIKEp503_compressed@plt>
test   %eax,%eax
jne    14af <main+0x2df>
mov    %rbp,%r13
mov    %rbp,%rdi
mov    %r14,%rbp
mov    %r14,%rsi
mov    $0xe1,%edx
lea    0xdbb(%rip),%rcx
call   1070 <ReadHex@plt>
test   %eax,%eax
je     1485 <main+0x2b5>
mov    %r13,%rdi
mov    %rbx,%r14
mov    %rbx,%rsi
mov    $0x197,%edx
lea    0xdc5(%rip),%rcx
call   1070 <ReadHex@plt>
test   %eax,%eax
je     148e <main+0x2be>
lea    0xc0(%rsp),%rdi
mov    %rbp,%rsi
mov    $0xe1,%edx
call   10a0 <memcmp@plt>
test   %rax,%rax
jne    14b8 <main+0x2e8>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x197,%edx
call   10a0 <memcmp@plt>
test   %rax,%rax
jne    14c1 <main+0x2f1>
mov    %r15,%rbp
mov    %r15,%rdi
lea    0x70(%rsp),%r15
mov    %r15,%rsi
lea    0xc0(%rsp),%rdx
call   1030 <crypto_kem_enc_SIKEp503_compressed@plt>
test   %eax,%eax
jne    14ca <main+0x2fa>
mov    %r13,%rdi
lea    0x2a0(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x118,%edx
lea    0xdd2(%rip),%rcx
call   1070 <ReadHex@plt>
test   %eax,%eax
je     1485 <main+0x2b5>
mov    %r13,%rdi
lea    0x30(%rsp),%rsi
mov    $0x18,%edx
lea    0xdb7(%rip),%rcx
call   1070 <ReadHex@plt>
test   %eax,%eax
je     148e <main+0x2be>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x118,%edx
call   10a0 <memcmp@plt>
test   %rax,%rax
jne    14d3 <main+0x303>
mov    %r15,%rdi
lea    0x30(%rsp),%rsi
mov    $0x18,%edx
call   10a0 <memcmp@plt>
test   %rax,%rax
jne    14dc <main+0x30c>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1050 <crypto_kem_dec_SIKEp503_compressed@plt>
test   %eax,%eax
jne    14f4 <main+0x324>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x18,%edx
call   10a0 <memcmp@plt>
test   %rax,%rax
lea    0xc23(%rip),%rsi
je     1247 <main+0x77>
lea    0xdb8(%rip),%rdi
call   1040 <puts@plt>
jmp    1504 <main+0x334>
lea    0xbcd(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xffffffff,%eax
jmp    1509 <main+0x339>
mov    %r13,%rdi
call   1060 <fclose@plt>
lea    0xd68(%rip),%rdi
call   1040 <puts@plt>
lea    0xbc0(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    1509 <main+0x339>
lea    0xc27(%rip),%rdi
jmp    149e <main+0x2ce>
lea    0xc4a(%rip),%rdi
jmp    149e <main+0x2ce>
lea    0xbc5(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xfffffffd,%eax
jmp    1509 <main+0x339>
lea    0xbd5(%rip),%rdi
jmp    14fb <main+0x32b>
lea    0xc46(%rip),%rdi
jmp    14e3 <main+0x313>
lea    0xc5f(%rip),%rdi
jmp    14e3 <main+0x313>
lea    0xc78(%rip),%rdi
jmp    14fb <main+0x32b>
lea    0xc99(%rip),%rdi
jmp    14e3 <main+0x313>
lea    0xcb2(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xfffffffe,%eax
jmp    1509 <main+0x339>
lea    0xcbc(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xfffffffc,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"KAT/PQCkemKAT_%d.rsp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"Couldn't open <%s> for read\0A\00"
@.str.3 = [7 x i8] c"# %s\0A\0A\00"
@.str.4 = [20 x i8] c"SIKEp503_compressed\00"
@.str.5 = [9 x i8] c"count = \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [8 x i8] c"seed = \00"
@.str.8 = [40 x i8] c"ERROR: unable to read 'seed' from <%s>\0A\00"
@.str.9 = [34 x i8] c"crypto_kem_keypair returned <%d>\0A\00"
@.str.10 = [6 x i8] c"pk = \00"
@.str.11 = [38 x i8] c"ERROR: unable to read 'pk' from <%s>\0A\00"
@.str.12 = [6 x i8] c"sk = \00"
@.str.13 = [38 x i8] c"ERROR: unable to read 'sk' from <%s>\0A\00"
@.str.14 = [34 x i8] c"ERROR: pk is different from <%s>\0A\00"
@.str.15 = [34 x i8] c"ERROR: sk is different from <%s>\0A\00"
@.str.16 = [30 x i8] c"crypto_kem_enc returned <%d>\0A\00"
@.str.17 = [6 x i8] c"ct = \00"
@.str.18 = [6 x i8] c"ss = \00"
@.str.19 = [34 x i8] c"ERROR: ct is different from <%s>\0A\00"
@.str.20 = [34 x i8] c"ERROR: ss is different from <%s>\0A\00"
@.str.21 = [30 x i8] c"crypto_kem_dec returned <%d>\0A\00"
@.str.22 = [40 x i8] c"crypto_kem_dec returned bad 'ss' value\0A\00"
@.str.23 = [29 x i8] c"Known Answer Tests PASSED. \0A\00"
@.str.24 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = alloca i32*
%4 = alloca [48 x i8]
%5 = alloca [280 x i8]
%6 = alloca [24 x i8]
%7 = alloca [24 x i8]
%8 = alloca [280 x i8]
%9 = alloca [24 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca [225 x i8]
%13 = alloca [407 x i8]
%14 = alloca [225 x i8]
%15 = alloca [407 x i8]
%16 = alloca i32
store i32 0, i32* %1
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%18 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 407)
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %3
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %0
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %23)
store i32 -1, i32* %1
br label %155
25: ; preds = %0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %11
br label %27
27: ; preds = %146, %25
%28 = load i32*, i32** %3
%29 = call i64 @FindMarker(i32* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %27
%32 = load i32*, i32** %3
%33 = call i32 @fscanf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %10)
%34 = icmp ne i32 %33, 1
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 1, i32* %11
br label %150
36: ; preds = %31
br label %38
37: ; preds = %27
store i32 1, i32* %11
br label %150
38: ; preds = %36
%39 = load i32*, i32** %3
%40 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 0
%41 = call i32 @ReadHex(i32* %39, i8* %40, i32 48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %38
%44 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %44)
store i32 -3, i32* %1
br label %155
46: ; preds = %38
%47 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 0
%48 = call i32 @randombytes_init(i8* %47, i32* null, i32 256)
%49 = getelementptr inbounds [225 x i8], [225 x i8]* %12, i64 0, i64 0
%50 = getelementptr inbounds [407 x i8], [407 x i8]* %13, i64 0, i64 0
%51 = call i32 @crypto_kem_keypair_SIKEp503_compressed(i8* %49, i8* %50)
store i32 %51, i32* %16
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %46
%54 = load i32, i32* %16
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %54)
store i32 -4, i32* %1
br label %155
56: ; preds = %46
%57 = load i32*, i32** %3
%58 = getelementptr inbounds [225 x i8], [225 x i8]* %14, i64 0, i64 0
%59 = call i32 @ReadHex(i32* %57, i8* %58, i32 225, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%60 = icmp ne i32 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %56
%62 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %62)
store i32 -3, i32* %1
br label %155
64: ; preds = %56
%65 = load i32*, i32** %3
%66 = getelementptr inbounds [407 x i8], [407 x i8]* %15, i64 0, i64 0
%67 = call i32 @ReadHex(i32* %65, i8* %66, i32 407, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%68 = icmp ne i32 %67, 0
br i1 %68, label %72, label %69
69: ; preds = %64
%70 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i8* %70)
store i32 -3, i32* %1
br label %155
72: ; preds = %64
%73 = getelementptr inbounds [225 x i8], [225 x i8]* %12, i64 0, i64 0
%74 = getelementptr inbounds [225 x i8], [225 x i8]* %14, i64 0, i64 0
%75 = call i64 @memcmp(i8* %73, i8* %74, i32 225)
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %72
%78 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i8* %78)
store i32 -2, i32* %1
br label %155
80: ; preds = %72
%81 = getelementptr inbounds [407 x i8], [407 x i8]* %13, i64 0, i64 0
%82 = getelementptr inbounds [407 x i8], [407 x i8]* %15, i64 0, i64 0
%83 = call i64 @memcmp(i8* %81, i8* %82, i32 407)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %80
%86 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i8* %86)
store i32 -2, i32* %1
br label %155
88: ; preds = %80
%89 = getelementptr inbounds [280 x i8], [280 x i8]* %5, i64 0, i64 0
%90 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%91 = getelementptr inbounds [225 x i8], [225 x i8]* %12, i64 0, i64 0
%92 = call i32 @crypto_kem_enc_SIKEp503_compressed(i8* %89, i8* %90, i8* %91)
store i32 %92, i32* %16
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %88
%95 = load i32, i32* %16
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0), i32 %95)
store i32 -4, i32* %1
br label %155
97: ; preds = %88
%98 = load i32*, i32** %3
%99 = getelementptr inbounds [280 x i8], [280 x i8]* %8, i64 0, i64 0
%100 = call i32 @ReadHex(i32* %98, i8* %99, i32 280, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%101 = icmp ne i32 %100, 0
br i1 %101, label %105, label %102
102: ; preds = %97
%103 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %103)
store i32 -3, i32* %1
br label %155
105: ; preds = %97
%106 = load i32*, i32** %3
%107 = getelementptr inbounds [24 x i8], [24 x i8]* %9, i64 0, i64 0
%108 = call i32 @ReadHex(i32* %106, i8* %107, i32 24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
%109 = icmp ne i32 %108, 0
br i1 %109, label %113, label %110
110: ; preds = %105
%111 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i8* %111)
store i32 -3, i32* %1
br label %155
113: ; preds = %105
%114 = getelementptr inbounds [280 x i8], [280 x i8]* %5, i64 0, i64 0
%115 = getelementptr inbounds [280 x i8], [280 x i8]* %8, i64 0, i64 0
%116 = call i64 @memcmp(i8* %114, i8* %115, i32 280)
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %121
118: ; preds = %113
%119 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0), i8* %119)
store i32 -2, i32* %1
br label %155
121: ; preds = %113
%122 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%123 = getelementptr inbounds [24 x i8], [24 x i8]* %9, i64 0, i64 0
%124 = call i64 @memcmp(i8* %122, i8* %123, i32 24)
%125 = icmp ne i64 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %121
%127 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.20, i64 0, i64 0), i8* %127)
store i32 -2, i32* %1
br label %155
129: ; preds = %121
%130 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%131 = getelementptr inbounds [280 x i8], [280 x i8]* %5, i64 0, i64 0
%132 = getelementptr inbounds [407 x i8], [407 x i8]* %13, i64 0, i64 0
%133 = call i32 @crypto_kem_dec_SIKEp503_compressed(i8* %130, i8* %131, i8* %132)
store i32 %133, i32* %16
%134 = icmp ne i32 %133, 0
br i1 %134, label %135, label %138
135: ; preds = %129
%136 = load i32, i32* %16
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.21, i64 0, i64 0), i32 %136)
store i32 -4, i32* %1
br label %155
138: ; preds = %129
%139 = getelementptr inbounds [24 x i8], [24 x i8]* %6, i64 0, i64 0
%140 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%141 = call i64 @memcmp(i8* %139, i8* %140, i32 24)
%142 = icmp ne i64 %141, 0
br i1 %142, label %143, label %145
143: ; preds = %138
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.22, i64 0, i64 0))
store i32 -4, i32* %1
br label %155
145: ; preds = %138
br label %146
146: ; preds = %145
%147 = load i32, i32* %11
%148 = icmp ne i32 %147, 0
%149 = xor i1 %148, true
br i1 %149, label %27, label %150
150: ; preds = %146, %37, %35
%151 = load i32*, i32** %3
%152 = call i32 @fclose(i32* %151)
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.23, i64 0, i64 0))
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0))
store i32 0, i32* %1
br label %155
155: ; preds = %150, %143, %135, %126, %118, %110, %102, %94, %85, %77, %69, %61, %53, %43, %22
%156 = load i32, i32* %1
ret i32 %156
}

LLVM IR (-O2):
@.str = [21 x i8] c"KAT/PQCkemKAT_%d.rsp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [29 x i8] c"Couldn't open <%s> for read\0A\00"
@.str.3 = [7 x i8] c"# %s\0A\0A\00"
@.str.4 = [20 x i8] c"SIKEp503_compressed\00"
@.str.5 = [9 x i8] c"count = \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [8 x i8] c"seed = \00"
@.str.8 = [40 x i8] c"ERROR: unable to read 'seed' from <%s>\0A\00"
@.str.9 = [34 x i8] c"crypto_kem_keypair returned <%d>\0A\00"
@.str.10 = [6 x i8] c"pk = \00"
@.str.11 = [38 x i8] c"ERROR: unable to read 'pk' from <%s>\0A\00"
@.str.12 = [6 x i8] c"sk = \00"
@.str.13 = [38 x i8] c"ERROR: unable to read 'sk' from <%s>\0A\00"
@.str.14 = [34 x i8] c"ERROR: pk is different from <%s>\0A\00"
@.str.15 = [34 x i8] c"ERROR: sk is different from <%s>\0A\00"
@.str.16 = [30 x i8] c"crypto_kem_enc returned <%d>\0A\00"
@.str.17 = [6 x i8] c"ct = \00"
@.str.18 = [6 x i8] c"ss = \00"
@.str.19 = [34 x i8] c"ERROR: ct is different from <%s>\0A\00"
@.str.20 = [34 x i8] c"ERROR: ss is different from <%s>\0A\00"
@.str.21 = [30 x i8] c"crypto_kem_dec returned <%d>\0A\00"
@str = [28 x i8] c"Known Answer Tests PASSED. \00"
@str.25 = [2 x i8] c"\0A\00"
@str.26 = [39 x i8] c"crypto_kem_dec returned bad 'ss' value\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = alloca [48 x i8]
%3 = alloca [280 x i8]
%4 = alloca [24 x i8]
%5 = alloca [24 x i8]
%6 = alloca [280 x i8]
%7 = alloca [24 x i8]
%8 = alloca i32
%9 = alloca [225 x i8]
%10 = alloca [407 x i8]
%11 = alloca [225 x i8]
%12 = alloca [407 x i8]
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%14 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [280 x i8], [280 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [24 x i8], [24 x i8]* %4, i64 0, i64 0
%17 = getelementptr inbounds [24 x i8], [24 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [280 x i8], [280 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%20 = bitcast i32* %8 to i8*
%21 = getelementptr inbounds [225 x i8], [225 x i8]* %9, i64 0, i64 0
%22 = getelementptr inbounds [407 x i8], [407 x i8]* %10, i64 0, i64 0
%23 = getelementptr inbounds [225 x i8], [225 x i8]* %11, i64 0, i64 0
%24 = getelementptr inbounds [407 x i8], [407 x i8]* %12, i64 0, i64 0
%25 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 407)
%26 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %0
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %108
30: ; preds = %0
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %99, %30
%33 = call i64 @FindMarker(i32* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %104, label %35
35: ; preds = %32
%36 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %8)
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %104
38: ; preds = %35
%39 = call i32 @ReadHex(i32* %26, i8* %14, i32 48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %13)
br label %108
43: ; preds = %38
%44 = call i32 @randombytes_init(i8* %14, i32* null, i32 256)
%45 = call i32 @crypto_kem_keypair_SIKEp503_compressed(i8* %21, i8* %22)
%46 = icmp eq i32 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %45)
br label %108
49: ; preds = %43
%50 = call i32 @ReadHex(i32* %26, i8* %23, i32 225, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %13)
br label %108
54: ; preds = %49
%55 = call i32 @ReadHex(i32* %26, i8* %24, i32 407, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i8* %13)
br label %108
59: ; preds = %54
%60 = call i64 @memcmp(i8* %21, i8* %23, i32 225)
%61 = icmp eq i64 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.14, i64 0, i64 0), i8* %13)
br label %108
64: ; preds = %59
%65 = call i64 @memcmp(i8* %22, i8* %24, i32 407)
%66 = icmp eq i64 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %64
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i8* %13)
br label %108
69: ; preds = %64
%70 = call i32 @crypto_kem_enc_SIKEp503_compressed(i8* %15, i8* %16, i8* %21)
%71 = icmp eq i32 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0), i32 %70)
br label %108
74: ; preds = %69
%75 = call i32 @ReadHex(i32* %26, i8* %18, i32 280, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %13)
br label %108
79: ; preds = %74
%80 = call i32 @ReadHex(i32* %26, i8* %19, i32 24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0))
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i8* %13)
br label %108
84: ; preds = %79
%85 = call i64 @memcmp(i8* %15, i8* %18, i32 280)
%86 = icmp eq i64 %85, 0
br i1 %86, label %89, label %87
87: ; preds = %84
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0), i8* %13)
br label %108
89: ; preds = %84
%90 = call i64 @memcmp(i8* %16, i8* %19, i32 24)
%91 = icmp eq i64 %90, 0
br i1 %91, label %94, label %92
92: ; preds = %89
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.20, i64 0, i64 0), i8* %13)
br label %108
94: ; preds = %89
%95 = call i32 @crypto_kem_dec_SIKEp503_compressed(i8* %17, i8* %15, i8* %22)
%96 = icmp eq i32 %95, 0
br i1 %96, label %99, label %97
97: ; preds = %94
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.21, i64 0, i64 0), i32 %95)
br label %108
99: ; preds = %94
%100 = call i64 @memcmp(i8* %16, i8* %17, i32 24)
%101 = icmp eq i64 %100, 0
br i1 %101, label %32, label %102
102: ; preds = %99
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.26, i64 0, i64 0))
br label %108
104: ; preds = %32, %35
%105 = call i32 @fclose(i32* %26)
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.25, i64 0, i64 0))
br label %108
108: ; preds = %104, %102, %97, %92, %87, %82, %77, %72, %67, %62, %57, %52, %47, %41, %28
%109 = phi i32 [ -1, %28 ], [ 0, %104 ], [ -4, %47 ], [ -2, %62 ], [ -2, %67 ], [ -4, %72 ], [ -2, %87 ], [ -2, %92 ], [ -4, %97 ], [ -4, %102 ], [ -3, %82 ], [ -3, %77 ], [ -3, %57 ], [ -3, %52 ], [ -3, %41 ]
ret i32 %109
}