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

/* Variables and functions */
int /*<<< orphan*/ CRTTwo(int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ GetHash(unsigned char *, unsigned char **, int, char **);
int /*<<< orphan*/ GetHexHash(unsigned char *, unsigned char **, char **);
int /*<<< orphan*/ GetJnHash(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ Q(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
                     int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
                     int /*<<< orphan*/);
int TonelliShanks(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ f(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
                     int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned char);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ g(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
                     int /*<<< orphan*/);
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ gmp_randinit_mt(int /*<<< orphan*/);
int /*<<< orphan*/ gmp_randseed_ui(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int mpz_inp_str(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int mpz_jacobi(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mod(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_powm_ui(int /*<<< orphan*/, int /*<<< orphan*/, int,
                               int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_str(int /*<<< orphan*/, unsigned char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void Decrypt(char *filename, unsigned char *identity, int l, mpz_t p, mpz_t q,
             mpz_t n, mpz_t u, mpz_t *r, char **error) {
  int j, i, read_length, bit, m, mrev;
  mpz_t rp, S, *R, *uR, cR, x, y, s, tmp1, tmp2;
  gmp_randstate_t r_state;
  FILE *fd, *fd_write;
  unsigned char *hash, *hex_hash, c1, c2, decrypted_character;
  mpz_init(rp);
  mpz_init(S);
  mpz_init(cR);
  mpz_init(x);
  mpz_init(y);
  mpz_init(s);
  mpz_init(tmp1);
  mpz_init(tmp2);
  fd = fopen(filename, "r");
  if (fd == NULL) {
    *error = "file open failed";
    return;
  }
  fd_write = fopen("decrypted_text", "w");
  if (fd_write == NULL) {
    *error = "file open failed";
    return;
  }
  R = (mpz_t *)malloc(l * sizeof(mpz_t));
  if (R == NULL) {
    *error = "malloc";
    return;
  }
  uR = (mpz_t *)malloc(l * sizeof(mpz_t));
  if (uR == NULL) {
    *error = "malloc";
    return;
  }
  for (i = 0; i < l; i++) {
    mpz_init(R[i]);
    mpz_init(uR[i]);
    GetHash(identity, &hash, i, error);
    if (strcmp(*error, "success") != 0)
      return;
    GetHexHash(hash, &hex_hash, error);
    if (strcmp(*error, "success") != 0)
      return;
    mpz_set_str(R[i], hex_hash, 16);
    mpz_mod(R[i], R[i], n);
    GetJnHash(n, R[i]);
    mpz_mul(uR[i], R[i], u);
    mpz_mod(uR[i], uR[i], n);
  }
  gmp_randinit_mt(r_state);
  gmp_randseed_ui(r_state, time(NULL));
  i = 0;
  while (1) {
    if (i % l == 0) {
      i = 0;
      read_length = mpz_inp_str(S, fd, 10);
      if (read_length == 0)
        break;
      if (TonelliShanks(tmp1, S, p) == 1) {
        *error = " calculate square root modulo";
        return;
      }
      if (TonelliShanks(tmp2, S, q) == 1) {
        *error = " calculate square root modulo";
        return;
      }
      CRTTwo(s, tmp1, p, tmp2, q, n);
      gmp_printf("%Zd\n", s);
    }
    decrypted_character ^= decrypted_character;
    fgetc(fd);
    c1 = (unsigned char)fgetc(fd);
    c2 = (unsigned char)fgetc(fd);
    fgetc(fd);
    for (j = 0; j < 8; j++, i++) {
      int xa;
      mpz_powm_ui(rp, r[i], 2, n);
      if (mpz_cmp(rp, R[i]) == 0) {
        bit = ((1 << (7 - j)) & c1) == 0 ? 1 : -1;
        mpz_set(cR, R[i]);
        xa = 1;
      } else {
        bit = ((1 << (7 - j)) & c2) == 0 ? 1 : -1;
        mpz_set(cR, uR[i]);
        xa = 2;
      }
      Q(cR, S, s, n, x, y, r_state);
      g(tmp1, s, y, n);
      gmp_printf("\ng=%Zd\n\n", tmp1);
      f(tmp1, r[i], x, n);
      m = bit * mpz_jacobi(tmp1, n);
      mrev = (m == -1) ? 1 : 0;
      decrypted_character |= (mrev << (7 - j));
    }
    fprintf(fd_write, "%c", decrypted_character);
  }
  for (i = 0; i < l; i++)
    mpz_clear(R[i]);
  for (i = 0; i < l; i++)
    mpz_clear(uR[i]);
  free(R);
  free(uR);
  mpz_clear(tmp1);
  mpz_clear(tmp2);
  mpz_clear(s);
  mpz_clear(x);
  mpz_clear(y);
  mpz_clear(cR);
  mpz_clear(S);
  mpz_clear(rp);
  fclose(fd);
  fclose(fd_write);
}


x86 assembly (clang, -O0):
<Decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x3c(%rbp),%edi
call   10a0 <mpz_init@plt>
mov    -0x40(%rbp),%edi
call   10a0 <mpz_init@plt>
mov    -0x54(%rbp),%edi
call   10a0 <mpz_init@plt>
mov    -0x58(%rbp),%edi
call   10a0 <mpz_init@plt>
mov    -0x5c(%rbp),%edi
call   10a0 <mpz_init@plt>
mov    -0x60(%rbp),%edi
call   10a0 <mpz_init@plt>
mov    -0x64(%rbp),%edi
call   10a0 <mpz_init@plt>
mov    -0x68(%rbp),%edi
call   10a0 <mpz_init@plt>
mov    -0x8(%rbp),%rdi
lea    0xcb9(%rip),%rsi
call   1180 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    136e <Decrypt+0x9e>
mov    0x20(%rbp),%rax
lea    0xc9c(%rip),%rcx
mov    %rcx,(%rax)
jmp    18ed <Decrypt+0x61d>
lea    0xc9e(%rip),%rdi
lea    0xca6(%rip),%rsi
call   1180 <fopen@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
jne    13a3 <Decrypt+0xd3>
mov    0x20(%rbp),%rax
lea    0xc67(%rip),%rcx
mov    %rcx,(%rax)
jmp    18ed <Decrypt+0x61d>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10f0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    13d4 <Decrypt+0x104>
mov    0x20(%rbp),%rax
lea    0xc58(%rip),%rcx
mov    %rcx,(%rax)
jmp    18ed <Decrypt+0x61d>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10f0 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1405 <Decrypt+0x135>
mov    0x20(%rbp),%rax
lea    0xc27(%rip),%rcx
mov    %rcx,(%rax)
jmp    18ed <Decrypt+0x61d>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1541 <Decrypt+0x271>
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   10a0 <mpz_init@plt>
mov    -0x50(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   10a0 <mpz_init@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    0x20(%rbp),%rcx
lea    -0x88(%rbp),%rsi
call   11e0 <GetHash@plt>
mov    0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xbce(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1471 <Decrypt+0x1a1>
jmp    18ed <Decrypt+0x61d>
mov    -0x88(%rbp),%rdi
mov    0x20(%rbp),%rdx
lea    -0x90(%rbp),%rsi
call   1080 <GetHexHash@plt>
mov    0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xb95(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     14aa <Decrypt+0x1da>
jmp    18ed <Decrypt+0x61d>
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x90(%rbp),%rsi
mov    $0x10,%edx
call   1120 <mpz_set_str@plt>
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x20(%rbp),%edx
call   1160 <mpz_mod@plt>
mov    -0x20(%rbp),%edi
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   11a0 <GetJnHash@plt>
mov    -0x50(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    0x10(%rbp),%edx
call   10d0 <mpz_mul@plt>
mov    -0x50(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x50(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x20(%rbp),%edx
call   1160 <mpz_mod@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    140c <Decrypt+0x13c>
mov    -0x6c(%rbp),%edi
call   11c0 <gmp_randinit_mt@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <time@plt>
mov    -0x9c(%rbp),%edi
mov    %eax,%esi
call   1190 <gmp_randseed_ui@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    1625 <Decrypt+0x355>
movl   $0x0,-0x28(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    $0xa,%edx
call   1130 <mpz_inp_str@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    15a9 <Decrypt+0x2d9>
jmp    1827 <Decrypt+0x557>
mov    -0x64(%rbp),%edi
mov    -0x40(%rbp),%esi
mov    -0x18(%rbp),%edx
call   11f0 <TonelliShanks@plt>
cmp    $0x1,%eax
jne    15d3 <Decrypt+0x303>
mov    0x20(%rbp),%rax
lea    0xa68(%rip),%rcx
mov    %rcx,(%rax)
jmp    18ed <Decrypt+0x61d>
mov    -0x68(%rbp),%edi
mov    -0x40(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   11f0 <TonelliShanks@plt>
cmp    $0x1,%eax
jne    15fd <Decrypt+0x32d>
mov    0x20(%rbp),%rax
lea    0xa3e(%rip),%rcx
mov    %rcx,(%rax)
jmp    18ed <Decrypt+0x61d>
mov    -0x60(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x68(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
call   1090 <CRTTwo@plt>
mov    -0x60(%rbp),%esi
lea    0xa31(%rip),%rdi
call   11d0 <gmp_printf@plt>
movzbl -0x93(%rbp),%ecx
movzbl -0x93(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x93(%rbp)
mov    -0x78(%rbp),%rdi
call   1070 <fgetc@plt>
mov    -0x78(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x91(%rbp)
mov    -0x78(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x92(%rbp)
mov    -0x78(%rbp),%rdi
call   1070 <fgetc@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
jge    180b <Decrypt+0x53b>
mov    -0x3c(%rbp),%edi
mov    0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x20(%rbp),%ecx
mov    $0x2,%edx
call   1140 <mpz_powm_ui@plt>
mov    -0x3c(%rbp),%edi
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1150 <mpz_cmp@plt>
cmp    $0x0,%rax
jne    1701 <Decrypt+0x431>
mov    $0x7,%ecx
sub    -0x24(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
movzbl -0x91(%rbp),%eax
and    %eax,%edx
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x54(%rbp),%edi
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <mpz_set@plt>
movl   $0x1,-0x98(%rbp)
jmp    1749 <Decrypt+0x479>
mov    $0x7,%ecx
sub    -0x24(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
movzbl -0x92(%rbp),%eax
and    %eax,%edx
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <mpz_set@plt>
movl   $0x2,-0x98(%rbp)
mov    -0x54(%rbp),%edi
mov    -0x40(%rbp),%esi
mov    -0x60(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x58(%rbp),%r8d
mov    -0x5c(%rbp),%r9d
mov    -0x6c(%rbp),%eax
mov    %eax,(%rsp)
call   1100 <Q@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%esi
mov    -0x5c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1110 <g@plt>
mov    -0x64(%rbp),%esi
lea    0x8d3(%rip),%rdi
call   11d0 <gmp_printf@plt>
mov    -0x64(%rbp),%edi
mov    0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x58(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1060 <f@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0xa0(%rbp)
mov    -0x64(%rbp),%edi
mov    -0x20(%rbp),%esi
call   11b0 <mpz_jacobi@plt>
mov    %eax,%ecx
mov    -0xa0(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0xffffffff,%edx
cmove  %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    $0x7,%ecx
sub    -0x24(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%ecx
movzbl -0x93(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x93(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1672 <Decrypt+0x3a2>
mov    -0x80(%rbp),%rdi
lea    0x849(%rip),%rsi
movzbl -0x93(%rbp),%edx
call   10c0 <fprintf@plt>
jmp    156f <Decrypt+0x29f>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1858 <Decrypt+0x588>
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1170 <mpz_clear@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    182e <Decrypt+0x55e>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1889 <Decrypt+0x5b9>
mov    -0x50(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1170 <mpz_clear@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    185f <Decrypt+0x58f>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x64(%rbp),%edi
call   1170 <mpz_clear@plt>
mov    -0x68(%rbp),%edi
call   1170 <mpz_clear@plt>
mov    -0x60(%rbp),%edi
call   1170 <mpz_clear@plt>
mov    -0x58(%rbp),%edi
call   1170 <mpz_clear@plt>
mov    -0x5c(%rbp),%edi
call   1170 <mpz_clear@plt>
mov    -0x54(%rbp),%edi
call   1170 <mpz_clear@plt>
mov    -0x40(%rbp),%edi
call   1170 <mpz_clear@plt>
mov    -0x3c(%rbp),%edi
call   1170 <mpz_clear@plt>
mov    -0x78(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x80(%rbp),%rdi
call   1050 <fclose@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9d,%r13d
mov    %r8d,0x3c(%rsp)
mov    %ecx,0x14(%rsp)
mov    %edx,%r12d
mov    %rsi,0x30(%rsp)
mov    %rdi,%rbx
mov    0xc0(%rsp),%r15
call   10b0 <mpz_init@plt>
call   10b0 <mpz_init@plt>
call   10b0 <mpz_init@plt>
call   10b0 <mpz_init@plt>
call   10b0 <mpz_init@plt>
call   10b0 <mpz_init@plt>
call   10b0 <mpz_init@plt>
call   10b0 <mpz_init@plt>
lea    0xcd4(%rip),%rsi
mov    %rbx,%rdi
call   1180 <fopen@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     1677 <Decrypt+0x3a7>
lea    0xcca(%rip),%rdi
lea    0xcd2(%rip),%rsi
call   1180 <fopen@plt>
mov    %rax,0x50(%rsp)
test   %rax,%rax
je     1677 <Decrypt+0x3a7>
lea    0x0(,%r12,4),%ebp
mov    %ebp,%edi
call   10f0 <malloc@plt>
test   %rax,%rax
je     1680 <Decrypt+0x3b0>
mov    %rax,%r14
mov    %ebp,%edi
call   10f0 <malloc@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     1680 <Decrypt+0x3b0>
mov    %r13d,0x10(%rsp)
test   %r12d,%r12d
mov    0x18(%rsp),%r13
jle    1499 <Decrypt+0x1c9>
mov    %r12d,%eax
mov    %rax,0x28(%rsp)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%r15,4),%edi
call   10b0 <mpz_init@plt>
mov    0x0(%r13,%r15,4),%edi
call   10b0 <mpz_init@plt>
mov    0x30(%rsp),%rdi
lea    0x70(%rsp),%rsi
mov    %r15d,%edx
mov    0xc0(%rsp),%rbp
mov    %rbp,%rcx
call   11e0 <GetHash@plt>
mov    0x0(%rbp),%rdi
lea    0xc30(%rip),%rbx
mov    %rbx,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    168a <Decrypt+0x3ba>
mov    0x70(%rsp),%rdi
lea    0x68(%rsp),%rsi
mov    %rbp,%rdx
call   1080 <GetHexHash@plt>
mov    0x0(%rbp),%rdi
mov    %rbx,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    168a <Decrypt+0x3ba>
mov    (%r14,%r15,4),%edi
mov    0x68(%rsp),%rsi
mov    $0x10,%edx
call   1120 <mpz_set_str@plt>
mov    (%r14,%r15,4),%edi
mov    %edi,%esi
mov    0x10(%rsp),%ebp
mov    %ebp,%edx
call   1160 <mpz_mod@plt>
mov    (%r14,%r15,4),%esi
mov    %ebp,%edi
call   11a0 <GetJnHash@plt>
mov    0x18(%rsp),%r13
mov    0x0(%r13,%r15,4),%edi
mov    (%r14,%r15,4),%esi
mov    0xb0(%rsp),%edx
call   10d0 <mpz_mul@plt>
mov    0x0(%r13,%r15,4),%edi
mov    %edi,%esi
mov    %ebp,%edx
call   1160 <mpz_mod@plt>
add    $0x1,%r15
cmp    %r15,0x28(%rsp)
jne    13c0 <Decrypt+0xf0>
mov    %r14,0x48(%rsp)
call   11c0 <gmp_randinit_mt@plt>
xor    %r14d,%r14d
xor    %edi,%edi
call   10e0 <time@plt>
mov    %eax,%esi
call   1190 <gmp_randseed_ui@plt>
mov    %r12,0x58(%rsp)
jmp    14dd <Decrypt+0x20d>
nopl   0x0(%rax,%rax,1)
mov    0x60(%rsp),%rax
sub    %r14d,%eax
mov    %rax,%r14
movsbl %cl,%edi
mov    0x50(%rsp),%rsi
call   1090 <fputc@plt>
mov    0x58(%rsp),%r12
mov    %r14d,%eax
cltd
idiv   %r12d
test   %edx,%edx
jne    1545 <Decrypt+0x275>
mov    0x20(%rsp),%rsi
mov    $0xa,%edx
call   1130 <mpz_inp_str@plt>
test   %eax,%eax
je     16ad <Decrypt+0x3dd>
mov    0x14(%rsp),%edx
call   11f0 <TonelliShanks@plt>
cmp    $0x1,%eax
je     1699 <Decrypt+0x3c9>
mov    0x3c(%rsp),%ebx
mov    %ebx,%edx
call   11f0 <TonelliShanks@plt>
cmp    $0x1,%eax
je     1699 <Decrypt+0x3c9>
mov    0x14(%rsp),%edx
mov    %ebx,%r8d
mov    0x10(%rsp),%r9d
call   10a0 <CRTTwo@plt>
lea    0xb14(%rip),%rdi
call   11d0 <gmp_printf@plt>
xor    %r14d,%r14d
mov    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1070 <fgetc@plt>
mov    %rbp,%rdi
call   1070 <fgetc@plt>
mov    %rax,%r13
mov    %rbp,%rdi
call   1070 <fgetc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1070 <fgetc@plt>
movzbl %bl,%eax
mov    %eax,0x44(%rsp)
movzbl %r13b,%eax
mov    %eax,0x40(%rsp)
mov    %r14,0x60(%rsp)
movslq %r14d,%r12
mov    0xb8(%rsp),%rax
lea    (%rax,%r12,4),%r15
mov    0x48(%rsp),%rax
lea    (%rax,%r12,4),%rbx
xor    %r14d,%r14d
xor    %ecx,%ecx
mov    0x10(%rsp),%ebp
jmp    1629 <Decrypt+0x359>
nopw   0x0(%rax,%rax,1)
and    0x40(%rsp),%edx
neg    %edx
sbb    %r13d,%r13d
or     $0x1,%r13d
mov    %rbx,%rax
mov    (%rax),%esi
call   1040 <mpz_set@plt>
mov    0x10(%rsp),%ebp
mov    %ebp,%ecx
call   1100 <Q@plt>
mov    %ebp,%ecx
call   1110 <g@plt>
lea    0xa76(%rip),%rdi
call   11d0 <gmp_printf@plt>
mov    (%r15),%esi
mov    %ebp,%ecx
call   1060 <f@plt>
mov    %ebp,%esi
call   11b0 <mpz_jacobi@plt>
imul   %r13d,%eax
xor    %edx,%edx
cmp    $0xffffffff,%eax
sete   %dl
mov    0x28(%rsp),%ecx
shl    %cl,%edx
mov    0x30(%rsp),%rcx
or     %dl,%cl
add    $0x1,%r12
add    $0x4,%r15
add    $0x4,%rbx
add    $0xffffffff,%r14d
cmp    $0xfffffff8,%r14d
je     14c0 <Decrypt+0x1f0>
mov    %rcx,0x30(%rsp)
mov    (%r15),%esi
mov    $0x2,%edx
mov    %ebp,%ecx
call   1140 <mpz_powm_ui@plt>
mov    (%rbx),%esi
call   1150 <mpz_cmp@plt>
lea    0x7(%r14),%ecx
mov    $0x1,%edx
mov    %ecx,0x28(%rsp)
shl    %cl,%edx
test   %rax,%rax
je     15b0 <Decrypt+0x2e0>
and    0x44(%rsp),%edx
neg    %edx
sbb    %r13d,%r13d
or     $0x1,%r13d
mov    0x18(%rsp),%rax
lea    (%rax,%r12,4),%rax
jmp    15c0 <Decrypt+0x2f0>
lea    0x984(%rip),%rax
jmp    1687 <Decrypt+0x3b7>
lea    0x99d(%rip),%rax
mov    %rax,(%r15)
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x993(%rip),%rax
mov    0xc0(%rsp),%rcx
mov    %rax,(%rcx)
jmp    168a <Decrypt+0x3ba>
test   %r12d,%r12d
mov    0x48(%rsp),%r14
mov    0x18(%rsp),%r15
jle    1702 <Decrypt+0x432>
mov    %r12d,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbp,4),%edi
call   1170 <mpz_clear@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    16d0 <Decrypt+0x400>
test   %r12d,%r12d
jle    1702 <Decrypt+0x432>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r15,%rbp,4),%edi
call   1170 <mpz_clear@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    16f0 <Decrypt+0x420>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
mov    0x20(%rsp),%rdi
call   1050 <fclose@plt>
mov    0x50(%rsp),%rdi
call   1050 <fclose@plt>
jmp    168a <Decrypt+0x3ba>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"file open failed\00"
@.str.2 = [15 x i8] c"decrypted_text\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"malloc\00"
@.str.5 = [8 x i8] c"success\00"
@.str.6 = [30 x i8] c" calculate square root modulo\00"
@.str.7 = [5 x i8] c"%Zd\0A\00"
@.str.8 = [9 x i8] c"\0Ag=%Zd\0A\0A\00"
@.str.9 = [3 x i8] c"%c\00"
define void @Decrypt(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* %7, i8** %8) {
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca i8**
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32*
%28 = alloca i32*
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
%36 = alloca i32*
%37 = alloca i32*
%38 = alloca i8*
%39 = alloca i8*
%40 = alloca i8
%41 = alloca i8
%42 = alloca i8
%43 = alloca i32
store i8* %0, i8** %10
store i8* %1, i8** %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32* %7, i32** %17
store i8** %8, i8*** %18
%44 = load i32, i32* %25
%45 = call i32 @mpz_init(i32 %44)
%46 = load i32, i32* %26
%47 = call i32 @mpz_init(i32 %46)
%48 = load i32, i32* %29
%49 = call i32 @mpz_init(i32 %48)
%50 = load i32, i32* %30
%51 = call i32 @mpz_init(i32 %50)
%52 = load i32, i32* %31
%53 = call i32 @mpz_init(i32 %52)
%54 = load i32, i32* %32
%55 = call i32 @mpz_init(i32 %54)
%56 = load i32, i32* %33
%57 = call i32 @mpz_init(i32 %56)
%58 = load i32, i32* %34
%59 = call i32 @mpz_init(i32 %58)
%60 = load i8*, i8** %10
%61 = call i32* @fopen(i8* %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %61, i32** %36
%62 = load i32*, i32** %36
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %66
64: ; preds = %9
%65 = load i8**, i8*** %18
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %65
br label %405
66: ; preds = %9
%67 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %67, i32** %37
%68 = load i32*, i32** %37
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = load i8**, i8*** %18
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %71
br label %405
72: ; preds = %66
%73 = load i32, i32* %12
%74 = sext i32 %73 to i64
%75 = mul i64 %74, 4
%76 = trunc i64 %75 to i32
%77 = call i64 @malloc(i32 %76)
%78 = inttoptr i64 %77 to i32*
store i32* %78, i32** %27
%79 = load i32*, i32** %27
%80 = icmp eq i32* %79, null
br i1 %80, label %81, label %83
81: ; preds = %72
%82 = load i8**, i8*** %18
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %82
br label %405
83: ; preds = %72
%84 = load i32, i32* %12
%85 = sext i32 %84 to i64
%86 = mul i64 %85, 4
%87 = trunc i64 %86 to i32
%88 = call i64 @malloc(i32 %87)
%89 = inttoptr i64 %88 to i32*
store i32* %89, i32** %28
%90 = load i32*, i32** %28
%91 = icmp eq i32* %90, null
br i1 %91, label %92, label %94
92: ; preds = %83
%93 = load i8**, i8*** %18
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %93
br label %405
94: ; preds = %83
store i32 0, i32* %20
br label %95
95: ; preds = %181, %94
%96 = load i32, i32* %20
%97 = load i32, i32* %12
%98 = icmp slt i32 %96, %97
br i1 %98, label %99, label %184
99: ; preds = %95
%100 = load i32*, i32** %27
%101 = load i32, i32* %20
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i32, i32* %100, i64 %102
%104 = load i32, i32* %103
%105 = call i32 @mpz_init(i32 %104)
%106 = load i32*, i32** %28
%107 = load i32, i32* %20
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i32, i32* %106, i64 %108
%110 = load i32, i32* %109
%111 = call i32 @mpz_init(i32 %110)
%112 = load i8*, i8** %11
%113 = load i32, i32* %20
%114 = load i8**, i8*** %18
%115 = call i32 @GetHash(i8* %112, i8** %38, i32 %113, i8** %114)
%116 = load i8**, i8*** %18
%117 = load i8*, i8** %116
%118 = call i64 @strcmp(i8* %117, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%119 = icmp ne i64 %118, 0
br i1 %119, label %120, label %121
120: ; preds = %99
br label %405
121: ; preds = %99
%122 = load i8*, i8** %38
%123 = load i8**, i8*** %18
%124 = call i32 @GetHexHash(i8* %122, i8** %39, i8** %123)
%125 = load i8**, i8*** %18
%126 = load i8*, i8** %125
%127 = call i64 @strcmp(i8* %126, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%128 = icmp ne i64 %127, 0
br i1 %128, label %129, label %130
129: ; preds = %121
br label %405
130: ; preds = %121
%131 = load i32*, i32** %27
%132 = load i32, i32* %20
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i32, i32* %131, i64 %133
%135 = load i32, i32* %134
%136 = load i8*, i8** %39
%137 = call i32 @mpz_set_str(i32 %135, i8* %136, i32 16)
%138 = load i32*, i32** %27
%139 = load i32, i32* %20
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i32, i32* %138, i64 %140
%142 = load i32, i32* %141
%143 = load i32*, i32** %27
%144 = load i32, i32* %20
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i32, i32* %143, i64 %145
%147 = load i32, i32* %146
%148 = load i32, i32* %15
%149 = call i32 @mpz_mod(i32 %142, i32 %147, i32 %148)
%150 = load i32, i32* %15
%151 = load i32*, i32** %27
%152 = load i32, i32* %20
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i32, i32* %151, i64 %153
%155 = load i32, i32* %154
%156 = call i32 @GetJnHash(i32 %150, i32 %155)
%157 = load i32*, i32** %28
%158 = load i32, i32* %20
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds i32, i32* %157, i64 %159
%161 = load i32, i32* %160
%162 = load i32*, i32** %27
%163 = load i32, i32* %20
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds i32, i32* %162, i64 %164
%166 = load i32, i32* %165
%167 = load i32, i32* %16
%168 = call i32 @mpz_mul(i32 %161, i32 %166, i32 %167)
%169 = load i32*, i32** %28
%170 = load i32, i32* %20
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i32, i32* %169, i64 %171
%173 = load i32, i32* %172
%174 = load i32*, i32** %28
%175 = load i32, i32* %20
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds i32, i32* %174, i64 %176
%178 = load i32, i32* %177
%179 = load i32, i32* %15
%180 = call i32 @mpz_mod(i32 %173, i32 %178, i32 %179)
br label %181
181: ; preds = %130
%182 = load i32, i32* %20
%183 = add nsw i32 %182, 1
store i32 %183, i32* %20
br label %95
184: ; preds = %95
%185 = load i32, i32* %35
%186 = call i32 @gmp_randinit_mt(i32 %185)
%187 = load i32, i32* %35
%188 = call i32 @time(i32* null)
%189 = call i32 @gmp_randseed_ui(i32 %187, i32 %188)
store i32 0, i32* %20
br label %190
190: ; preds = %184, %346
%191 = load i32, i32* %20
%192 = load i32, i32* %12
%193 = srem i32 %191, %192
%194 = icmp eq i32 %193, 0
br i1 %194, label %195, label %228
195: ; preds = %190
store i32 0, i32* %20
%196 = load i32, i32* %26
%197 = load i32*, i32** %36
%198 = call i32 @mpz_inp_str(i32 %196, i32* %197, i32 10)
store i32 %198, i32* %21
%199 = load i32, i32* %21
%200 = icmp eq i32 %199, 0
br i1 %200, label %201, label %202
201: ; preds = %195
br label %350
202: ; preds = %195
%203 = load i32, i32* %33
%204 = load i32, i32* %26
%205 = load i32, i32* %13
%206 = call i32 @TonelliShanks(i32 %203, i32 %204, i32 %205)
%207 = icmp eq i32 %206, 1
br i1 %207, label %208, label %210
208: ; preds = %202
%209 = load i8**, i8*** %18
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8** %209
br label %405
210: ; preds = %202
%211 = load i32, i32* %34
%212 = load i32, i32* %26
%213 = load i32, i32* %14
%214 = call i32 @TonelliShanks(i32 %211, i32 %212, i32 %213)
%215 = icmp eq i32 %214, 1
br i1 %215, label %216, label %218
216: ; preds = %210
%217 = load i8**, i8*** %18
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8** %217
br label %405
218: ; preds = %210
%219 = load i32, i32* %32
%220 = load i32, i32* %33
%221 = load i32, i32* %13
%222 = load i32, i32* %34
%223 = load i32, i32* %14
%224 = load i32, i32* %15
%225 = call i32 @CRTTwo(i32 %219, i32 %220, i32 %221, i32 %222, i32 %223, i32 %224)
%226 = load i32, i32* %32
%227 = call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %226)
br label %228
228: ; preds = %218, %190
%229 = load i8, i8* %42
%230 = zext i8 %229 to i32
%231 = load i8, i8* %42
%232 = zext i8 %231 to i32
%233 = xor i32 %232, %230
%234 = trunc i32 %233 to i8
store i8 %234, i8* %42
%235 = load i32*, i32** %36
%236 = call i64 @fgetc(i32* %235)
%237 = load i32*, i32** %36
%238 = call i64 @fgetc(i32* %237)
%239 = trunc i64 %238 to i8
store i8 %239, i8* %40
%240 = load i32*, i32** %36
%241 = call i64 @fgetc(i32* %240)
%242 = trunc i64 %241 to i8
store i8 %242, i8* %41
%243 = load i32*, i32** %36
%244 = call i64 @fgetc(i32* %243)
store i32 0, i32* %19
br label %245
245: ; preds = %341, %228
%246 = load i32, i32* %19
%247 = icmp slt i32 %246, 8
br i1 %247, label %248, label %346
248: ; preds = %245
%249 = load i32, i32* %25
%250 = load i32*, i32** %17
%251 = load i32, i32* %20
%252 = sext i32 %251 to i64
%253 = getelementptr inbounds i32, i32* %250, i64 %252
%254 = load i32, i32* %253
%255 = load i32, i32* %15
%256 = call i32 @mpz_powm_ui(i32 %249, i32 %254, i32 2, i32 %255)
%257 = load i32, i32* %25
%258 = load i32*, i32** %27
%259 = load i32, i32* %20
%260 = sext i32 %259 to i64
%261 = getelementptr inbounds i32, i32* %258, i64 %260
%262 = load i32, i32* %261
%263 = call i64 @mpz_cmp(i32 %257, i32 %262)
%264 = icmp eq i64 %263, 0
br i1 %264, label %265, label %282
265: ; preds = %248
%266 = load i32, i32* %19
%267 = sub nsw i32 7, %266
%268 = shl i32 1, %267
%269 = load i8, i8* %40
%270 = zext i8 %269 to i32
%271 = and i32 %268, %270
%272 = icmp eq i32 %271, 0
%273 = zext i1 %272 to i64
%274 = select i1 %272, i32 1, i32 -1
store i32 %274, i32* %22
%275 = load i32, i32* %29
%276 = load i32*, i32** %27
%277 = load i32, i32* %20
%278 = sext i32 %277 to i64
%279 = getelementptr inbounds i32, i32* %276, i64 %278
%280 = load i32, i32* %279
%281 = call i32 @mpz_set(i32 %275, i32 %280)
store i32 1, i32* %43
br label %299
282: ; preds = %248
%283 = load i32, i32* %19
%284 = sub nsw i32 7, %283
%285 = shl i32 1, %284
%286 = load i8, i8* %41
%287 = zext i8 %286 to i32
%288 = and i32 %285, %287
%289 = icmp eq i32 %288, 0
%290 = zext i1 %289 to i64
%291 = select i1 %289, i32 1, i32 -1
store i32 %291, i32* %22
%292 = load i32, i32* %29
%293 = load i32*, i32** %28
%294 = load i32, i32* %20
%295 = sext i32 %294 to i64
%296 = getelementptr inbounds i32, i32* %293, i64 %295
%297 = load i32, i32* %296
%298 = call i32 @mpz_set(i32 %292, i32 %297)
store i32 2, i32* %43
br label %299
299: ; preds = %282, %265
%300 = load i32, i32* %29
%301 = load i32, i32* %26
%302 = load i32, i32* %32
%303 = load i32, i32* %15
%304 = load i32, i32* %30
%305 = load i32, i32* %31
%306 = load i32, i32* %35
%307 = call i32 @Q(i32 %300, i32 %301, i32 %302, i32 %303, i32 %304, i32 %305, i32 %306)
%308 = load i32, i32* %33
%309 = load i32, i32* %32
%310 = load i32, i32* %31
%311 = load i32, i32* %15
%312 = call i32 @g(i32 %308, i32 %309, i32 %310, i32 %311)
%313 = load i32, i32* %33
%314 = call i32 @gmp_printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %313)
%315 = load i32, i32* %33
%316 = load i32*, i32** %17
%317 = load i32, i32* %20
%318 = sext i32 %317 to i64
%319 = getelementptr inbounds i32, i32* %316, i64 %318
%320 = load i32, i32* %319
%321 = load i32, i32* %30
%322 = load i32, i32* %15
%323 = call i32 @f(i32 %315, i32 %320, i32 %321, i32 %322)
%324 = load i32, i32* %22
%325 = load i32, i32* %33
%326 = load i32, i32* %15
%327 = call i32 @mpz_jacobi(i32 %325, i32 %326)
%328 = mul nsw i32 %324, %327
store i32 %328, i32* %23
%329 = load i32, i32* %23
%330 = icmp eq i32 %329, -1
%331 = zext i1 %330 to i64
%332 = select i1 %330, i32 1, i32 0
store i32 %332, i32* %24
%333 = load i32, i32* %24
%334 = load i32, i32* %19
%335 = sub nsw i32 7, %334
%336 = shl i32 %333, %335
%337 = load i8, i8* %42
%338 = zext i8 %337 to i32
%339 = or i32 %338, %336
%340 = trunc i32 %339 to i8
store i8 %340, i8* %42
br label %341
341: ; preds = %299
%342 = load i32, i32* %19
%343 = add nsw i32 %342, 1
store i32 %343, i32* %19
%344 = load i32, i32* %20
%345 = add nsw i32 %344, 1
store i32 %345, i32* %20
br label %245
346: ; preds = %245
%347 = load i32*, i32** %37
%348 = load i8, i8* %42
%349 = call i32 @fprintf(i32* %347, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8 zeroext %348)
br label %190
350: ; preds = %201
store i32 0, i32* %20
br label %351
351: ; preds = %362, %350
%352 = load i32, i32* %20
%353 = load i32, i32* %12
%354 = icmp slt i32 %352, %353
br i1 %354, label %355, label %365
355: ; preds = %351
%356 = load i32*, i32** %27
%357 = load i32, i32* %20
%358 = sext i32 %357 to i64
%359 = getelementptr inbounds i32, i32* %356, i64 %358
%360 = load i32, i32* %359
%361 = call i32 @mpz_clear(i32 %360)
br label %362
362: ; preds = %355
%363 = load i32, i32* %20
%364 = add nsw i32 %363, 1
store i32 %364, i32* %20
br label %351
365: ; preds = %351
store i32 0, i32* %20
br label %366
366: ; preds = %377, %365
%367 = load i32, i32* %20
%368 = load i32, i32* %12
%369 = icmp slt i32 %367, %368
br i1 %369, label %370, label %380
370: ; preds = %366
%371 = load i32*, i32** %28
%372 = load i32, i32* %20
%373 = sext i32 %372 to i64
%374 = getelementptr inbounds i32, i32* %371, i64 %373
%375 = load i32, i32* %374
%376 = call i32 @mpz_clear(i32 %375)
br label %377
377: ; preds = %370
%378 = load i32, i32* %20
%379 = add nsw i32 %378, 1
store i32 %379, i32* %20
br label %366
380: ; preds = %366
%381 = load i32*, i32** %27
%382 = call i32 @free(i32* %381)
%383 = load i32*, i32** %28
%384 = call i32 @free(i32* %383)
%385 = load i32, i32* %33
%386 = call i32 @mpz_clear(i32 %385)
%387 = load i32, i32* %34
%388 = call i32 @mpz_clear(i32 %387)
%389 = load i32, i32* %32
%390 = call i32 @mpz_clear(i32 %389)
%391 = load i32, i32* %30
%392 = call i32 @mpz_clear(i32 %391)
%393 = load i32, i32* %31
%394 = call i32 @mpz_clear(i32 %393)
%395 = load i32, i32* %29
%396 = call i32 @mpz_clear(i32 %395)
%397 = load i32, i32* %26
%398 = call i32 @mpz_clear(i32 %397)
%399 = load i32, i32* %25
%400 = call i32 @mpz_clear(i32 %399)
%401 = load i32*, i32** %36
%402 = call i32 @fclose(i32* %401)
%403 = load i32*, i32** %37
%404 = call i32 @fclose(i32* %403)
br label %405
405: ; preds = %380, %216, %208, %129, %120, %92, %81, %70, %64
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"file open failed\00"
@.str.2 = [15 x i8] c"decrypted_text\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [7 x i8] c"malloc\00"
@.str.5 = [8 x i8] c"success\00"
@.str.6 = [30 x i8] c" calculate square root modulo\00"
@.str.7 = [5 x i8] c"%Zd\0A\00"
@.str.8 = [9 x i8] c"\0Ag=%Zd\0A\0A\00"
define void @Decrypt(i8* nocapture %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32* nocapture %7, i8** %8) {
%10 = alloca i8*
%11 = alloca i8*
%12 = bitcast i8** %10 to i8*
%13 = bitcast i8** %11 to i8*
%14 = tail call i32 @mpz_init(i32 undef)
%15 = tail call i32 @mpz_init(i32 undef)
%16 = tail call i32 @mpz_init(i32 undef)
%17 = tail call i32 @mpz_init(i32 undef)
%18 = tail call i32 @mpz_init(i32 undef)
%19 = tail call i32 @mpz_init(i32 undef)
%20 = tail call i32 @mpz_init(i32 undef)
%21 = tail call i32 @mpz_init(i32 undef)
%22 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %25
24: ; preds = %9
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %8
br label %190
25: ; preds = %9
%26 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %29
28: ; preds = %25
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %8
br label %190
29: ; preds = %25
%30 = shl i32 %2, 2
%31 = tail call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to i32*
%33 = icmp eq i64 %31, 0
br i1 %33, label %34, label %35
34: ; preds = %29
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %8
br label %190
35: ; preds = %29
%36 = tail call i64 @malloc(i32 %30)
%37 = inttoptr i64 %36 to i32*
%38 = icmp eq i64 %36, 0
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = icmp sgt i32 %2, 0
br i1 %40, label %41, label %78
41: ; preds = %39
%42 = zext i32 %2 to i64
br label %44
43: ; preds = %35
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %8
br label %190
44: ; preds = %41, %63
%45 = phi i64 [ 0, %41 ], [ %76, %63 ]
%46 = getelementptr inbounds i32, i32* %32, i64 %45
%47 = load i32, i32* %46
%48 = call i32 @mpz_init(i32 %47)
%49 = getelementptr inbounds i32, i32* %37, i64 %45
%50 = load i32, i32* %49
%51 = call i32 @mpz_init(i32 %50)
%52 = trunc i64 %45 to i32
%53 = call i32 @GetHash(i8* %1, i8** %10, i32 %52, i8** %8)
%54 = load i8*, i8** %8
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %190
57: ; preds = %44
%58 = load i8*, i8** %10
%59 = call i32 @GetHexHash(i8* %58, i8** %11, i8** %8)
%60 = load i8*, i8** %8
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %190
63: ; preds = %57
%64 = load i32, i32* %46
%65 = load i8*, i8** %11
%66 = call i32 @mpz_set_str(i32 %64, i8* %65, i32 16)
%67 = load i32, i32* %46
%68 = call i32 @mpz_mod(i32 %67, i32 %67, i32 %5)
%69 = load i32, i32* %46
%70 = call i32 @GetJnHash(i32 %5, i32 %69)
%71 = load i32, i32* %49
%72 = load i32, i32* %46
%73 = call i32 @mpz_mul(i32 %71, i32 %72, i32 %6)
%74 = load i32, i32* %49
%75 = call i32 @mpz_mod(i32 %74, i32 %74, i32 %5)
%76 = add nuw nsw i64 %45, 1
%77 = icmp eq i64 %76, %42
br i1 %77, label %78, label %44
78: ; preds = %63, %39
%79 = call i32 @gmp_randinit_mt(i32 undef)
%80 = call i32 @time(i32* null)
%81 = call i32 @gmp_randseed_ui(i32 undef, i32 %80)
br label %82
82: ; preds = %156, %78
%83 = phi i32 [ 0, %78 ], [ %157, %156 ]
%84 = srem i32 %83, %2
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %103
86: ; preds = %82
%87 = call i32 @mpz_inp_str(i32 undef, i32* %22, i32 10)
%88 = icmp eq i32 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %86
br i1 %40, label %90, label %177
90: ; preds = %89
%91 = zext i32 %2 to i64
br label %163
92: ; preds = %86
%93 = call i32 @TonelliShanks(i32 undef, i32 undef, i32 %3)
%94 = icmp eq i32 %93, 1
br i1 %94, label %95, label %96
95: ; preds = %92
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8** %8
br label %190
96: ; preds = %92
%97 = call i32 @TonelliShanks(i32 undef, i32 undef, i32 %4)
%98 = icmp eq i32 %97, 1
br i1 %98, label %99, label %100
99: ; preds = %96
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8** %8
br label %190
100: ; preds = %96
%101 = call i32 @CRTTwo(i32 undef, i32 undef, i32 %3, i32 undef, i32 %4, i32 %5)
%102 = call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 undef)
br label %103
103: ; preds = %100, %82
%104 = phi i32 [ 0, %100 ], [ %83, %82 ]
%105 = call i64 @fgetc(i32* %22)
%106 = call i64 @fgetc(i32* %22)
%107 = trunc i64 %106 to i32
%108 = call i64 @fgetc(i32* %22)
%109 = trunc i64 %108 to i32
%110 = call i64 @fgetc(i32* %22)
%111 = and i32 %109, 255
%112 = and i32 %107, 255
%113 = sext i32 %104 to i64
br label %114
114: ; preds = %103, %136
%115 = phi i64 [ %113, %103 ], [ %154, %136 ]
%116 = phi i8 [ 0, %103 ], [ %152, %136 ]
%117 = phi i32 [ 0, %103 ], [ %153, %136 ]
%118 = getelementptr inbounds i32, i32* %7, i64 %115
%119 = load i32, i32* %118
%120 = call i32 @mpz_powm_ui(i32 undef, i32 %119, i32 2, i32 %5)
%121 = getelementptr inbounds i32, i32* %32, i64 %115
%122 = load i32, i32* %121
%123 = call i64 @mpz_cmp(i32 undef, i32 %122)
%124 = icmp eq i64 %123, 0
%125 = sub nuw nsw i32 7, %117
%126 = shl nuw nsw i32 1, %125
br i1 %124, label %127, label %131
127: ; preds = %114
%128 = and i32 %112, %126
%129 = icmp eq i32 %128, 0
%130 = select i1 %129, i32 1, i32 -1
br label %136
131: ; preds = %114
%132 = and i32 %111, %126
%133 = icmp eq i32 %132, 0
%134 = select i1 %133, i32 1, i32 -1
%135 = getelementptr inbounds i32, i32* %37, i64 %115
br label %136
136: ; preds = %131, %127
%137 = phi i32* [ %135, %131 ], [ %121, %127 ]
%138 = phi i32 [ %134, %131 ], [ %130, %127 ]
%139 = load i32, i32* %137
%140 = call i32 @mpz_set(i32 undef, i32 %139)
%141 = call i32 @Q(i32 undef, i32 undef, i32 undef, i32 %5, i32 undef, i32 undef, i32 undef)
%142 = call i32 @g(i32 undef, i32 undef, i32 undef, i32 %5)
%143 = call i32 @gmp_printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 undef)
%144 = load i32, i32* %118
%145 = call i32 @f(i32 undef, i32 %144, i32 undef, i32 %5)
%146 = call i32 @mpz_jacobi(i32 undef, i32 %5)
%147 = mul nsw i32 %146, %138
%148 = icmp eq i32 %147, -1
%149 = zext i1 %148 to i32
%150 = shl nuw nsw i32 %149, %125
%151 = trunc i32 %150 to i8
%152 = or i8 %116, %151
%153 = add nuw nsw i32 %117, 1
%154 = add nsw i64 %115, 1
%155 = icmp eq i32 %153, 8
br i1 %155, label %156, label %114
156: ; preds = %136
%157 = trunc i64 %154 to i32
%158 = sext i8 %152 to i32
%159 = call i32 @fputc(i32 %158, i32* %26)
br label %82
160: ; preds = %163
br i1 %40, label %161, label %177
161: ; preds = %160
%162 = zext i32 %2 to i64
br label %170
163: ; preds = %90, %163
%164 = phi i64 [ 0, %90 ], [ %168, %163 ]
%165 = getelementptr inbounds i32, i32* %32, i64 %164
%166 = load i32, i32* %165
%167 = call i32 @mpz_clear(i32 %166)
%168 = add nuw nsw i64 %164, 1
%169 = icmp eq i64 %168, %91
br i1 %169, label %160, label %163
170: ; preds = %161, %170
%171 = phi i64 [ 0, %161 ], [ %175, %170 ]
%172 = getelementptr inbounds i32, i32* %37, i64 %171
%173 = load i32, i32* %172
%174 = call i32 @mpz_clear(i32 %173)
%175 = add nuw nsw i64 %171, 1
%176 = icmp eq i64 %175, %162
br i1 %176, label %177, label %170
177: ; preds = %170, %89, %160
%178 = call i32 @free(i32* %32)
%179 = call i32 @free(i32* %37)
%180 = call i32 @mpz_clear(i32 undef)
%181 = call i32 @mpz_clear(i32 undef)
%182 = call i32 @mpz_clear(i32 undef)
%183 = call i32 @mpz_clear(i32 undef)
%184 = call i32 @mpz_clear(i32 undef)
%185 = call i32 @mpz_clear(i32 undef)
%186 = call i32 @mpz_clear(i32 undef)
%187 = call i32 @mpz_clear(i32 undef)
%188 = call i32 @fclose(i32* %22)
%189 = call i32 @fclose(i32* %26)
br label %190
190: ; preds = %57, %44, %177, %99, %95, %43, %34, %28, %24
ret void
}