#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 PHS(unsigned char *, unsigned int, char *, unsigned int, char *,
        unsigned int, unsigned int, unsigned int);
unsigned int atoi(char *);
unsigned int atol(char *);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
unsigned int strlen(char *);
int /*<<< orphan*/ testVectors(unsigned int, unsigned int);
int main(int argc, char *argv[]) {
  unsigned int kLen = 64;
  unsigned int t_cost = 0;
  unsigned int m_cost = 0;
  char *pwd = "Lyra2 PHS";
  unsigned int pwdLen = 9;
  char *salt = "saltsaltsaltsalt";
  unsigned int saltLen = 16;
  switch (argc) {
  case 2:
    if (strcmp(argv[1], "--help") == 0) {
      printf("Usage: \n");
      printf("       %s pwd salt kLen tCost nRows \n\n", argv[0]);
      printf("Inputs:\n");
      printf(" - pwd: the password\n");
      printf(" - salt: the salt\n");
      printf(" - kLen: output size\n");
      printf(" - tCost: the time cost parameter\n");
      printf(" - nRows: the number of rows parameter\n");
      printf("\n");
      printf("Or:\n");
      printf("       %s tCost nRows --testVectors     (to generate test "
             "vectors and test Lyra2 operation)\n\n",
             argv[0]);
      return 0;
    } else {
      printf("Invalid options.\nFor more information, try \"%s --help\".\n",
             argv[0]);
      return 0;
    }
    break;
  case 6:
    pwd = argv[1];
    pwdLen = strlen(pwd);
    salt = argv[2];
    saltLen = strlen(salt);
    kLen = atol(argv[3]);
    t_cost = atol(argv[4]);
    m_cost = atol(argv[5]);
    break;
  case 4:
    if (strcmp(argv[3], "--testVectors") == 0) {
      t_cost = atoi(argv[1]);
      m_cost = atoi(argv[2]);
      testVectors(t_cost, m_cost);
      return 0;
    } else {
      printf("Invalid options.\nFor more information, try \"%s --help\".\n",
             argv[0]);
      return 0;
    }
    break;
  default:
    printf("Invalid options.\nTry \"%s --help\".\n", argv[0]);
    return 0;
  }
  if (m_cost < 3) {
    printf("nRows must be >= 3\n");
    return 1;
  }
  if ((m_cost / 2) % 2 != 0) {
    printf("(nRows / 2) mod p must be = 0\n");
    return 1;
  }
  unsigned char *K = malloc(kLen);
  printf("Inputs: \n");
  printf("\tPassword: %s\n", pwd);
  printf("\tPassword Length: %u\n", pwdLen);
  printf("\tSalt: %s\n", salt);
  printf("\tSalt Length: %u\n", saltLen);
  printf("\tOutput Length: %u\n", kLen);
  printf(
      "------------------------------------------------------------------------"
      "------------------------------------------------------------------\n");
  printf("Parameters: \n");
  printf("\tT: %u\n", t_cost);
  printf("\tR: %u\n", m_cost);
  printf("\tC: %u\n", 256);
  printf("\tParallelism: %u\n", 2);
  char *spongeName = "";
  if (0 == 0) {
    spongeName = "Blake2";
  } else if (0 == 1) {
    spongeName = "BlaMka";
  } else {
    spongeName = "half-round BlaMka";
  }
  printf("\tSponge: %s\n", spongeName);
  printf("\tSponge Blocks (bitrate): %u = %u bits\n", 12, 12 * 64);
  size_t sizeMemMatrix = (size_t)((size_t)m_cost * (size_t)((12 * 256) * 8));
  if (sizeMemMatrix > (1610612736)) {
    printf(
        "\tMemory: %ld bytes (IMPORTANT: This implementation is known to have "
        "issues for such a large memory usage)\n",
        sizeMemMatrix);
  } else {
    printf("\tMemory: %ld bytes\n", sizeMemMatrix);
  }
  printf(
      "------------------------------------------------------------------------"
      "------------------------------------------------------------------\n");
  int result;
  result = PHS(K, kLen, pwd, pwdLen, salt, saltLen, t_cost, m_cost);
  switch (result) {
  case 0:
    printf("Output: \n");
    printf("\n\tK: ");
    int i;
    for (i = 0; i < kLen; i++) {
      printf("%x|", K[i]);
    }
    break;
  case -1:
    printf("Error: unable to allocate memory (nRows too large?)\n");
    break;
  default:
    printf("Unexpected error\n");
    break;
  }
  printf("\n");
  printf(
      "------------------------------------------------------------------------"
      "------------------------------------------------------------------\n");
  free(K);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x40,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe3b(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x9,-0x2c(%rbp)
lea    0xe33(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x10,-0x3c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x64(%rbp)
sub    $0x2,%eax
je     1218 <main+0x88>
jmp    11f6 <main+0x66>
mov    -0x64(%rbp),%eax
sub    $0x4,%eax
je     136f <main+0x1df>
jmp    1207 <main+0x77>
mov    -0x64(%rbp),%eax
sub    $0x6,%eax
je     130a <main+0x17a>
jmp    13e4 <main+0x254>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf4(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    12e9 <main+0x159>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16ba <main+0x52a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16ba <main+0x52a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10a0 <atol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10a0 <atol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10a0 <atol@plt>
mov    %eax,-0x1c(%rbp)
jmp    1405 <main+0x275>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe03(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    13c3 <main+0x233>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <testVectors@plt>
movl   $0x0,-0x4(%rbp)
jmp    16ba <main+0x52a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16ba <main+0x52a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    16ba <main+0x52a>
cmpl   $0x3,-0x1c(%rbp)
jae    1429 <main+0x299>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16ba <main+0x52a>
mov    -0x1c(%rbp),%eax
shr    $0x1,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1455 <main+0x2c5>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16ba <main+0x52a>
mov    -0x14(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xde4(%rip),%rdi
mov    $0x100,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdd9(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb20(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xdcd(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdc4(%rip),%rdi
mov    $0xc,%esi
mov    $0x300,%edx
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
imul   $0x6000,%rax,%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x60000000,-0x58(%rbp)
60
jbe    159d <main+0x40d>
mov    -0x58(%rbp),%rsi
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15af <main+0x41f>
mov    -0x58(%rbp),%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc8f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x38(%rbp),%r8
mov    -0x3c(%rbp),%r9d
mov    -0x18(%rbp),%r10d
mov    -0x1c(%rbp),%r11d
mov    %rsp,%rax
mov    %r11d,0x8(%rax)
mov    %r10d,(%rax)
call   1070 <PHS@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x68(%rbp)
sub    $0xffffffff,%eax
je     166d <main+0x4dd>
jmp    1601 <main+0x471>
mov    -0x68(%rbp),%eax
test   %eax,%eax
jne    1680 <main+0x4f0>
jmp    1611 <main+0x481>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1668 <main+0x4d8>
mov    -0x48(%rbp),%rax
movslq -0x60(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1634 <main+0x4a4>
jmp    168e <main+0x4fe>
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    168e <main+0x4fe>
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0x9bb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xba2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
cmp    $0x6,%edi
je     1282 <main+0xd2>
cmp    $0x4,%edi
je     12d1 <main+0x121>
cmp    $0x2,%edi
jne    12f6 <main+0x146>
mov    0x8(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
jne    12e9 <main+0x139>
lea    0x1160(%rip),%rdi
call   1060 <puts@plt>
mov    0x0(%rbp),%rsi
lea    0xdfc(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x1148(%rip),%rdi
call   1060 <puts@plt>
lea    0x1144(%rip),%rdi
call   1060 <puts@plt>
lea    0x114d(%rip),%rdi
call   1060 <puts@plt>
lea    0x1153(%rip),%rdi
call   1060 <puts@plt>
lea    0x115c(%rip),%rdi
call   1060 <puts@plt>
lea    0x1172(%rip),%rdi
call   1060 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0x1183(%rip),%rdi
call   1060 <puts@plt>
mov    0x0(%rbp),%rsi
lea    0xdb1(%rip),%rdi
jmp    1303 <main+0x153>
mov    0x8(%rbp),%r14
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %eax,(%rsp)
mov    0x10(%rbp),%r15
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%r12d
mov    0x18(%rbp),%rdi
call   10c0 <atol@plt>
mov    %eax,%ebx
mov    0x20(%rbp),%rdi
call   10c0 <atol@plt>
mov    %eax,%r13d
mov    0x28(%rbp),%rdi
call   10c0 <atol@plt>
cmp    $0x3,%eax
jae    130f <main+0x15f>
lea    0x107c(%rip),%rdi
jmp    1510 <main+0x360>
mov    0x18(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     14ea <main+0x33a>
mov    0x0(%rbp),%rsi
lea    0xd98(%rip),%rdi
jmp    1301 <main+0x151>
mov    0x0(%rbp),%rsi
lea    0xdd2(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1551 <main+0x3a1>
mov    %eax,%ebp
mov    %r13,0x10(%rsp)
test   $0x2,%bpl
jne    1509 <main+0x359>
mov    %ebx,%edi
call   10b0 <malloc@plt>
mov    %ebx,%r13d
mov    %rax,%rbx
lea    0xf07(%rip),%rdi
call   1060 <puts@plt>
lea    0xdb6(%rip),%rdi
mov    %r14,0x8(%rsp)
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdaf(%rip),%rdi
mov    (%rsp),%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdb4(%rip),%rdi
mov    %r15,%r14
mov    %rbx,%r15
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xda8(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xda9(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xee5(%rip),%rdi
call   1060 <puts@plt>
lea    0xe98(%rip),%rdi
call   1060 <puts@plt>
lea    0xd94(%rip),%rdi
mov    0x10(%rsp),%rbx
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd87(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd7f(%rip),%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd74(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd7a(%rip),%rdi
lea    0xd6c(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd72(%rip),%rdi
mov    $0xc,%esi
mov    $0x300,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebp,%eax
shl    $0xd,%rax
lea    (%rax,%rax,2),%rsi
cmp    $0x60000001,%rsi
lea    0xd71(%rip),%rax
lea    0xdd5(%rip),%rdi
cmovae %rax,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe2b(%rip),%rdi
call   1060 <puts@plt>
mov    %r15,%rdi
mov    %r13d,0x4(%rsp)
mov    %r13d,%esi
mov    0x8(%rsp),%rdx
mov    (%rsp),%ecx
mov    %r14,%r8
mov    %r12d,%r9d
push   %rbp
push   %rbx
call   1090 <PHS@plt>
add    $0x10,%rsp
cmp    $0xffffffff,%eax
je     151c <main+0x36c>
test   %eax,%eax
jne    1525 <main+0x375>
lea    0xe75(%rip),%rdi
call   1060 <puts@plt>
lea    0xd8a(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
je     1531 <main+0x381>
mov    %ebp,%ebp
lea    0xd78(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    14d0 <main+0x320>
jmp    1531 <main+0x381>
mov    0x8(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <testVectors@plt>
jmp    154f <main+0x39f>
lea    0xe1a(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%ebx
jmp    1551 <main+0x3a1>
lea    0xd2e(%rip),%rdi
jmp    152c <main+0x37c>
lea    0xded(%rip),%rdi
call   1060 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xd43(%rip),%rdi
call   1060 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Lyra2 PHS\00"
@.str.1 = [17 x i8] c"saltsaltsaltsalt\00"
@.str.2 = [7 x i8] c"--help\00"
@.str.3 = [9 x i8] c"Usage: \0A\00"
@.str.4 = [39 x i8] c" %s pwd salt kLen tCost nRows \0A\0A\00"
@.str.5 = [9 x i8] c"Inputs:\0A\00"
@.str.6 = [22 x i8] c" - pwd: the password\0A\00"
@.str.7 = [19 x i8] c" - salt: the salt\0A\00"
@.str.8 = [22 x i8] c" - kLen: output size\0A\00"
@.str.9 = [35 x i8] c" - tCost: the time cost parameter\0A\00"
@.str.10 = [40 x i8] c" - nRows: the number of rows parameter\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [5 x i8] c"Or:\0A\00"
@.str.13 = [94 x i8] c" %s tCost nRows --testVectors (to generate test vectors and test Lyra2 operation)\0A\0A\00"
@.str.14 = [57 x i8] c"Invalid options.\0AFor more information, try \22%s --help\22.\0A\00"
@.str.15 = [14 x i8] c"--testVectors\00"
@.str.16 = [35 x i8] c"Invalid options.\0ATry \22%s --help\22.\0A\00"
@.str.17 = [20 x i8] c"nRows must be >= 3\0A\00"
@.str.18 = [31 x i8] c"(nRows / 2) mod p must be = 0\0A\00"
@.str.19 = [10 x i8] c"Inputs: \0A\00"
@.str.20 = [15 x i8] c"\09Password: %s\0A\00"
@.str.21 = [22 x i8] c"\09Password Length: %u\0A\00"
@.str.22 = [11 x i8] c"\09Salt: %s\0A\00"
@.str.23 = [18 x i8] c"\09Salt Length: %u\0A\00"
@.str.24 = [20 x i8] c"\09Output Length: %u\0A\00"
@.str.25 = [140 x i8] c"------------------------------------------------------------------------------------------------------------------------------------------\0A\00"
@.str.26 = [14 x i8] c"Parameters: \0A\00"
@.str.27 = [8 x i8] c"\09T: %u\0A\00"
@.str.28 = [8 x i8] c"\09R: %u\0A\00"
@.str.29 = [8 x i8] c"\09C: %u\0A\00"
@.str.30 = [18 x i8] c"\09Parallelism: %u\0A\00"
@.str.31 = [1 x i8] zeroinitializer
@.str.32 = [7 x i8] c"Blake2\00"
@.str.33 = [13 x i8] c"\09Sponge: %s\0A\00"
@.str.34 = [40 x i8] c"\09Sponge Blocks (bitrate): %u = %u bits\0A\00"
@.str.35 = [107 x i8] c"\09Memory: %ld bytes (IMPORTANT: This implementation is known to have issues for such a large memory usage)\0A\00"
@.str.36 = [20 x i8] c"\09Memory: %ld bytes\0A\00"
@.str.37 = [10 x i8] c"Output: \0A\00"
@.str.38 = [6 x i8] c"\0A\09K: \00"
@.str.39 = [4 x i8] c"%x|\00"
@.str.40 = [53 x i8] c"Error: unable to allocate memory (nRows too large?)\0A\00"
@.str.41 = [18 x i8] c"Unexpected error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 64, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %9
store i32 9, i32* %10
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %11
store i32 16, i32* %12
%18 = load i32, i32* %4
switch i32 %18, label %94 [
i32 2, label %19
i32 6, label %48
i32 4, label %71
]
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %43
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.13, i64 0, i64 0), i8* %41)
store i32 0, i32* %3
br label %187
43: ; preds = %19
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0), i8* %46)
store i32 0, i32* %3
br label %187
48: ; preds = %2
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
store i8* %51, i8** %9
%52 = load i8*, i8** %9
%53 = call i32 @strlen(i8* %52)
store i32 %53, i32* %10
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
store i8* %56, i8** %11
%57 = load i8*, i8** %11
%58 = call i32 @strlen(i8* %57)
store i32 %58, i32* %12
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 3
%61 = load i8*, i8** %60
%62 = call i32 @atol(i8* %61)
store i32 %62, i32* %6
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 4
%65 = load i8*, i8** %64
%66 = call i32 @atol(i8* %65)
store i32 %66, i32* %7
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 5
%69 = load i8*, i8** %68
%70 = call i32 @atol(i8* %69)
store i32 %70, i32* %8
br label %99
71: ; preds = %2
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 3
%74 = load i8*, i8** %73
%75 = call i32 @strcmp(i8* %74, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0))
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %89
77: ; preds = %71
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 1
%80 = load i8*, i8** %79
%81 = call i32 @atoi(i8* %80)
store i32 %81, i32* %7
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 2
%84 = load i8*, i8** %83
%85 = call i32 @atoi(i8* %84)
store i32 %85, i32* %8
%86 = load i32, i32* %7
%87 = load i32, i32* %8
%88 = call i32 @testVectors(i32 %86, i32 %87)
store i32 0, i32* %3
br label %187
89: ; preds = %71
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 0
%92 = load i8*, i8** %91
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0), i8* %92)
store i32 0, i32* %3
br label %187
94: ; preds = %2
%95 = load i8**, i8*** %5
%96 = getelementptr inbounds i8*, i8** %95, i64 0
%97 = load i8*, i8** %96
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.16, i64 0, i64 0), i8* %97)
store i32 0, i32* %3
br label %187
99: ; preds = %48
%100 = load i32, i32* %8
%101 = icmp ult i32 %100, 3
br i1 %101, label %102, label %104
102: ; preds = %99
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.17, i64 0, i64 0))
store i32 1, i32* %3
br label %187
104: ; preds = %99
%105 = load i32, i32* %8
%106 = udiv i32 %105, 2
%107 = urem i32 %106, 2
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %104
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.18, i64 0, i64 0))
store i32 1, i32* %3
br label %187
111: ; preds = %104
%112 = load i32, i32* %6
%113 = call i8* @malloc(i32 %112)
store i8* %113, i8** %13
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.19, i64 0, i64 0))
%115 = load i8*, i8** %9
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.20, i64 0, i64 0), i8* %115)
%117 = load i32, i32* %10
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.21, i64 0, i64 0), i32 %117)
%119 = load i8*, i8** %11
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0), i8* %119)
%121 = load i32, i32* %12
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.23, i64 0, i64 0), i32 %121)
%123 = load i32, i32* %6
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.24, i64 0, i64 0), i32 %123)
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.25, i64 0, i64 0))
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.26, i64 0, i64 0))
%127 = load i32, i32* %7
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.27, i64 0, i64 0), i32 %127)
%129 = load i32, i32* %8
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i64 0, i64 0), i32 %129)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.29, i64 0, i64 0), i32 256)
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.30, i64 0, i64 0), i32 2)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.31, i64 0, i64 0), i8** %14
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.32, i64 0, i64 0), i8** %14
%133 = load i8*, i8** %14
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.33, i64 0, i64 0), i8* %133)
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.34, i64 0, i64 0), i32 12, i32 768)
%136 = load i32, i32* %8
%137 = zext i32 %136 to i64
%138 = mul i64 %137, 24576
store i64 %138, i64* %15
%139 = load i64, i64* %15
%140 = icmp ugt i64 %139, 1610612736
br i1 %140, label %141, label %144
141: ; preds = %111
%142 = load i64, i64* %15
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.35, i64 0, i64 0), i64 %142)
br label %147
144: ; preds = %111
%145 = load i64, i64* %15
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.36, i64 0, i64 0), i64 %145)
br label %147
147: ; preds = %144, %141
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.25, i64 0, i64 0))
%149 = load i8*, i8** %13
%150 = load i32, i32* %6
%151 = load i8*, i8** %9
%152 = load i32, i32* %10
%153 = load i8*, i8** %11
%154 = load i32, i32* %12
%155 = load i32, i32* %7
%156 = load i32, i32* %8
%157 = call i32 @PHS(i8* %149, i32 %150, i8* %151, i32 %152, i8* %153, i32 %154, i32 %155, i32 %156)
store i32 %157, i32* %16
%158 = load i32, i32* %16
switch i32 %158, label %180 [
i32 0, label %159
i32 -1, label %178
]
159: ; preds = %147
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.37, i64 0, i64 0))
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.38, i64 0, i64 0))
store i32 0, i32* %17
br label %162
162: ; preds = %174, %159
%163 = load i32, i32* %17
%164 = load i32, i32* %6
%165 = icmp ult i32 %163, %164
br i1 %165, label %166, label %177
166: ; preds = %162
%167 = load i8*, i8** %13
%168 = load i32, i32* %17
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds i8, i8* %167, i64 %169
%171 = load i8, i8* %170
%172 = zext i8 %171 to i32
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.39, i64 0, i64 0), i32 %172)
br label %174
174: ; preds = %166
%175 = load i32, i32* %17
%176 = add nsw i32 %175, 1
store i32 %176, i32* %17
br label %162
177: ; preds = %162
br label %182
178: ; preds = %147
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.40, i64 0, i64 0))
br label %182
180: ; preds = %147
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.41, i64 0, i64 0))
br label %182
182: ; preds = %180, %178, %177
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.25, i64 0, i64 0))
%185 = load i8*, i8** %13
%186 = call i32 @free(i8* %185)
store i32 0, i32* %3
br label %187
187: ; preds = %182, %109, %102, %94, %89, %77, %43, %25
%188 = load i32, i32* %3
ret i32 %188
}

LLVM IR (-O2):
@.str.2 = [7 x i8] c"--help\00"
@.str.4 = [39 x i8] c" %s pwd salt kLen tCost nRows \0A\0A\00"
@.str.13 = [94 x i8] c" %s tCost nRows --testVectors (to generate test vectors and test Lyra2 operation)\0A\0A\00"
@.str.14 = [57 x i8] c"Invalid options.\0AFor more information, try \22%s --help\22.\0A\00"
@.str.15 = [14 x i8] c"--testVectors\00"
@.str.16 = [35 x i8] c"Invalid options.\0ATry \22%s --help\22.\0A\00"
@.str.20 = [15 x i8] c"\09Password: %s\0A\00"
@.str.21 = [22 x i8] c"\09Password Length: %u\0A\00"
@.str.22 = [11 x i8] c"\09Salt: %s\0A\00"
@.str.23 = [18 x i8] c"\09Salt Length: %u\0A\00"
@.str.24 = [20 x i8] c"\09Output Length: %u\0A\00"
@.str.27 = [8 x i8] c"\09T: %u\0A\00"
@.str.28 = [8 x i8] c"\09R: %u\0A\00"
@.str.29 = [8 x i8] c"\09C: %u\0A\00"
@.str.30 = [18 x i8] c"\09Parallelism: %u\0A\00"
@.str.32 = [7 x i8] c"Blake2\00"
@.str.33 = [13 x i8] c"\09Sponge: %s\0A\00"
@.str.34 = [40 x i8] c"\09Sponge Blocks (bitrate): %u = %u bits\0A\00"
@.str.35 = [107 x i8] c"\09Memory: %ld bytes (IMPORTANT: This implementation is known to have issues for such a large memory usage)\0A\00"
@.str.36 = [20 x i8] c"\09Memory: %ld bytes\0A\00"
@.str.38 = [6 x i8] c"\0A\09K: \00"
@.str.39 = [4 x i8] c"%x|\00"
@str = [9 x i8] c"Inputs: \00"
@str.43 = [13 x i8] c"Parameters: \00"
@str.45 = [52 x i8] c"Error: unable to allocate memory (nRows too large?)\00"
@str.46 = [139 x i8] c"------------------------------------------------------------------------------------------------------------------------------------------\00"
@str.47 = [9 x i8] c"Output: \00"
@str.48 = [17 x i8] c"Unexpected error\00"
@str.49 = [30 x i8] c"(nRows / 2) mod p must be = 0\00"
@str.50 = [19 x i8] c"nRows must be >= 3\00"
@str.51 = [8 x i8] c"Usage: \00"
@str.52 = [8 x i8] c"Inputs:\00"
@str.53 = [21 x i8] c" - pwd: the password\00"
@str.54 = [18 x i8] c" - salt: the salt\00"
@str.55 = [21 x i8] c" - kLen: output size\00"
@str.56 = [34 x i8] c" - tCost: the time cost parameter\00"
@str.57 = [39 x i8] c" - nRows: the number of rows parameter\00"
@str.58 = [4 x i8] c"Or:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %58 [
i32 2, label %3
i32 6, label %25
i32 4, label %42
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.51, i64 0, i64 0))
%10 = load i8*, i8** %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.52, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.53, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.54, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.55, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.56, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.57, i64 0, i64 0))
%18 = tail call i32 @putchar(i32 10)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.58, i64 0, i64 0))
%20 = load i8*, i8** %1
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 x i8]* @.str.13, i64 0, i64 0), i8* %20)
br label %113
22: ; preds = %3
%23 = load i8*, i8** %1
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0), i8* %23)
br label %113
25: ; preds = %2
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = tail call i32 @strlen(i8* %27)
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = tail call i32 @strlen(i8* %30)
%32 = getelementptr inbounds i8*, i8** %1, i64 3
%33 = load i8*, i8** %32
%34 = tail call i32 @atol(i8* %33)
%35 = getelementptr inbounds i8*, i8** %1, i64 4
%36 = load i8*, i8** %35
%37 = tail call i32 @atol(i8* %36)
%38 = getelementptr inbounds i8*, i8** %1, i64 5
%39 = load i8*, i8** %38
%40 = tail call i32 @atol(i8* %39)
%41 = icmp ult i32 %40, 3
br i1 %41, label %61, label %63
42: ; preds = %2
%43 = getelementptr inbounds i8*, i8** %1, i64 3
%44 = load i8*, i8** %43
%45 = tail call i32 @strcmp(i8* dereferenceable(1) %44, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0))
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %55
47: ; preds = %42
%48 = getelementptr inbounds i8*, i8** %1, i64 1
%49 = load i8*, i8** %48
%50 = tail call i32 @atoi(i8* %49)
%51 = getelementptr inbounds i8*, i8** %1, i64 2
%52 = load i8*, i8** %51
%53 = tail call i32 @atoi(i8* %52)
%54 = tail call i32 @testVectors(i32 %50, i32 %53)
br label %113
55: ; preds = %42
%56 = load i8*, i8** %1
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.14, i64 0, i64 0), i8* %56)
br label %113
58: ; preds = %2
%59 = load i8*, i8** %1
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.16, i64 0, i64 0), i8* %59)
br label %113
61: ; preds = %25
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.50, i64 0, i64 0))
br label %113
63: ; preds = %25
%64 = and i32 %40, 2
%65 = icmp eq i32 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.49, i64 0, i64 0))
br label %113
68: ; preds = %63
%69 = tail call i8* @malloc(i32 %34)
%70 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.20, i64 0, i64 0), i8* %27)
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.21, i64 0, i64 0), i32 %28)
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0), i8* %30)
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.23, i64 0, i64 0), i32 %31)
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.24, i64 0, i64 0), i32 %34)
%76 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([139 x i8], [139 x i8]* @str.46, i64 0, i64 0))
%77 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.43, i64 0, i64 0))
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.27, i64 0, i64 0), i32 %37)
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i64 0, i64 0), i32 %40)
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.29, i64 0, i64 0), i32 256)
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.30, i64 0, i64 0), i32 2)
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.33, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.32, i64 0, i64 0))
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.34, i64 0, i64 0), i32 12, i32 768)
%84 = zext i32 %40 to i64
%85 = mul nuw nsw i64 %84, 24576
%86 = icmp ugt i64 %85, 1610612736
%87 = select i1 %86, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.35, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.36, i64 0, i64 0)
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %87, i64 %85)
%89 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([139 x i8], [139 x i8]* @str.46, i64 0, i64 0))
%90 = tail call i32 @PHS(i8* %69, i32 %34, i8* %27, i32 %28, i8* %30, i32 %31, i32 %37, i32 %40)
switch i32 %90, label %105 [
i32 0, label %91
i32 -1, label %106
]
91: ; preds = %68
%92 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.47, i64 0, i64 0))
%93 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.38, i64 0, i64 0))
%94 = icmp eq i32 %34, 0
br i1 %94, label %109, label %95
95: ; preds = %91
%96 = zext i32 %34 to i64
br label %97
97: ; preds = %95, %97
%98 = phi i64 [ 0, %95 ], [ %103, %97 ]
%99 = getelementptr inbounds i8, i8* %69, i64 %98
%100 = load i8, i8* %99
%101 = zext i8 %100 to i32
%102 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.39, i64 0, i64 0), i32 %101)
%103 = add nuw nsw i64 %98, 1
%104 = icmp eq i64 %103, %96
br i1 %104, label %109, label %97
105: ; preds = %68
br label %106
106: ; preds = %68, %105
%107 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.48, i64 0, i64 0), %105 ], [ getelementptr inbounds ([52 x i8], [52 x i8]* @str.45, i64 0, i64 0), %68 ]
%108 = tail call i32 @puts(i8* dereferenceable(1) %107)
br label %109
109: ; preds = %97, %106, %91
%110 = tail call i32 @putchar(i32 10)
%111 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([139 x i8], [139 x i8]* @str.46, i64 0, i64 0))
%112 = tail call i32 @free(i8* %69)
br label %113
113: ; preds = %109, %66, %61, %58, %55, %47, %22, %8
%114 = phi i32 [ 0, %58 ], [ 0, %47 ], [ 0, %55 ], [ 1, %61 ], [ 1, %66 ], [ 0, %109 ], [ 0, %8 ], [ 0, %22 ]
ret i32 %114
}