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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/, ...);
int /*<<< orphan*/ gmp_randclear(int /*<<< orphan*/);
int /*<<< orphan*/ gmp_randinit_default(int /*<<< orphan*/);
int /*<<< orphan*/ gmp_randseed_ui(int /*<<< orphan*/, long);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(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(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ mpz_urandomb(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ time(scalar_t__ *);
int main() {
  mpz_t e, n, c, m1, m2, tmp, message;
  mpz_init(e);
  mpz_init(n);
  mpz_set_str(e, "1040674049", 10);
  mpz_set_str(n, "2081441641", 10);
  mpz_init(c);
  mpz_init(m1);
  mpz_init(m2);
  mpz_init(tmp);
  mpz_init(message);
  time_t seed;
  time(&seed);
  gmp_randstate_t state;
  gmp_randinit_default(state);
  gmp_randseed_ui(state, (long)seed);
  do {
    mpz_urandomb(m1, state, 16);
    mpz_urandomb(m2, state, 16);
    mpz_mul(message, m1, m2);
  } while (mpz_cmp(message, n) >= 0);
  mpz_powm(c, message, e, n);
  gmp_printf("Now, I have a message, %Zd.\n%Zd=%Zd*%Zd.\n", message, message,
             m1, m2);
  gmp_printf("And the cipher text is %Zd.\n", c);
  printf("Next, let us begin the attack.\n");
  printf("Enter to start.Go?");
  getchar();
  int x, y, result;
  int done = 0;
  char strx[35], stry[35];
  FILE *fp1, *fp2;
  if ((fp1 = fopen("tableCipherText1", "r")) == NULL) {
    printf("Failed to open file tableCipherText1\n");
    return -1;
  }
  if ((fp2 = fopen("tableCipherText2", "r")) == NULL) {
    printf("Failed to open file tableCipherText2\n");
    return -1;
  }
  for (x = 1; fgets(strx, 35, fp1) != NULL && done == 0; x++) {
    mpz_set_str(m1, strx, 10);
    fseek(fp2, 0, SEEK_SET);
    for (y = 1; fgets(stry, 35, fp2) != NULL; y++) {
      mpz_set_str(m2, stry, 10);
      mpz_mul(tmp, m1, m2);
      mpz_mod(tmp, tmp, n);
      if (mpz_cmp(c, tmp) == 0) {
        result = x * y;
        done = 1;
        break;
      }
    }
    if (x % 500 == 0)
      printf("Waiting...\n");
  }
  fclose(fp1);
  fclose(fp2);
  if (done == 0)
    printf("Failed, I am sorry 0.0\n");
  else
    printf("OK, I have done, the message is %d, ^_^\n", result);
  mpz_clear(c);
  mpz_clear(m1);
  mpz_clear(m2);
  mpz_clear(tmp);
  mpz_clear(message);
  mpz_clear(e);
  mpz_clear(n);
  gmp_randclear(state);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%edi
call   1080 <mpz_init@plt>
mov    -0xc(%rbp),%edi
call   1080 <mpz_init@plt>
mov    -0x8(%rbp),%edi
lea    0xda4(%rip),%rsi
mov    $0xa,%edx
call   10e0 <mpz_set_str@plt>
mov    -0xc(%rbp),%edi
lea    0xd9b(%rip),%rsi
mov    $0xa,%edx
call   10e0 <mpz_set_str@plt>
mov    -0x10(%rbp),%edi
call   1080 <mpz_init@plt>
mov    -0x14(%rbp),%edi
call   1080 <mpz_init@plt>
mov    -0x18(%rbp),%edi
call   1080 <mpz_init@plt>
mov    -0x1c(%rbp),%edi
call   1080 <mpz_init@plt>
mov    -0x20(%rbp),%edi
call   1080 <mpz_init@plt>
lea    -0x28(%rbp),%rdi
call   10c0 <time@plt>
mov    -0x2c(%rbp),%edi
call   1150 <gmp_randinit_default@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1130 <gmp_randseed_ui@plt>
mov    -0x14(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    $0x10,%edx
call   10a0 <mpz_urandomb@plt>
mov    -0x18(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    $0x10,%edx
call   10a0 <mpz_urandomb@plt>
mov    -0x20(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10b0 <mpz_mul@plt>
mov    -0x20(%rbp),%edi
mov    -0xc(%rbp),%esi
call   10f0 <mpz_cmp@plt>
cmp    $0x0,%rax
jge    12bf <main+0x8f>
mov    -0x10(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1030 <mpz_powm@plt>
mov    -0x20(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xcef(%rip),%rdi
mov    $0x0,%al
call   1140 <gmp_printf@plt>
mov    -0x10(%rbp),%esi
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1140 <gmp_printf@plt>
lea    0xd17(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
movl   $0x0,-0x3c(%rbp)
lea    0xd20(%rip),%rdi
lea    0xd2a(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmp    $0x0,%rax
jne    13a7 <main+0x177>
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b7 <main+0x387>
lea    0xd1b(%rip),%rdi
lea    0xcec(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0xa0(%rbp)
cmp    $0x0,%rax
jne    13e5 <main+0x1b5>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b7 <main+0x387>
movl   $0x1,-0x30(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x98(%rbp),%rdx
mov    $0x23,%esi
call   1070 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xa1(%rbp)
je     1423 <main+0x1f3>
cmpl   $0x0,-0x3c(%rbp)
sete   %al
mov    %al,-0xa1(%rbp)
mov    -0xa1(%rbp),%al
test   $0x1,%al
jne    1436 <main+0x206>
jmp    152a <main+0x2fa>
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0xa,%edx
call   10e0 <mpz_set_str@plt>
mov    -0xa0(%rbp),%rdi
mov    0x2b8b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10d0 <fseek@plt>
movl   $0x1,-0x34(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0xa0(%rbp),%rdx
mov    $0x23,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     14f5 <main+0x2c5>
mov    -0x18(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0xa,%edx
call   10e0 <mpz_set_str@plt>
mov    -0x1c(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10b0 <mpz_mul@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1100 <mpz_mod@plt>
mov    -0x10(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   10f0 <mpz_cmp@plt>
cmp    $0x0,%rax
jne    14e2 <main+0x2b2>
mov    -0x30(%rbp),%eax
imul   -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    14f5 <main+0x2c5>
jmp    14e7 <main+0x2b7>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1465 <main+0x235>
mov    -0x30(%rbp),%eax
mov    $0x1f4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1517 <main+0x2e7>
lea    0xbf0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    151c <main+0x2ec>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    13ec <main+0x1bc>
mov    -0x98(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0xa0(%rbp),%rdi
call   1050 <fclose@plt>
cmpl   $0x0,-0x3c(%rbp)
jne    155f <main+0x32f>
lea    0xbb9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1570 <main+0x340>
mov    -0x38(%rbp),%esi
lea    0xbbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%edi
call   1110 <mpz_clear@plt>
mov    -0x14(%rbp),%edi
call   1110 <mpz_clear@plt>
mov    -0x18(%rbp),%edi
call   1110 <mpz_clear@plt>
mov    -0x1c(%rbp),%edi
call   1110 <mpz_clear@plt>
mov    -0x20(%rbp),%edi
call   1110 <mpz_clear@plt>
mov    -0x8(%rbp),%edi
call   1110 <mpz_clear@plt>
mov    -0xc(%rbp),%edi
call   1110 <mpz_clear@plt>
mov    -0x2c(%rbp),%edi
call   1040 <gmp_randclear@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
call   1090 <mpz_init@plt>
call   1090 <mpz_init@plt>
lea    0xda1(%rip),%rsi
mov    $0xa,%edx
call   10f0 <mpz_set_str@plt>
lea    0xd9b(%rip),%rsi
mov    $0xa,%edx
call   10f0 <mpz_set_str@plt>
call   1090 <mpz_init@plt>
call   1090 <mpz_init@plt>
call   1090 <mpz_init@plt>
call   1090 <mpz_init@plt>
call   1090 <mpz_init@plt>
lea    0x18(%rsp),%rdi
call   10d0 <time@plt>
call   1160 <gmp_randinit_default@plt>
mov    0x18(%rsp),%rsi
call   1140 <gmp_randseed_ui@plt>
nopl   0x0(%rax)
mov    $0x10,%edx
call   10b0 <mpz_urandomb@plt>
mov    $0x10,%edx
call   10b0 <mpz_urandomb@plt>
call   10c0 <mpz_mul@plt>
call   1100 <mpz_cmp@plt>
test   %rax,%rax
jns    12b0 <main+0x70>
call   1030 <mpz_powm@plt>
lea    0xd37(%rip),%rdi
xor    %eax,%eax
call   1150 <gmp_printf@plt>
lea    0xd53(%rip),%rdi
xor    %eax,%eax
call   1150 <gmp_printf@plt>
lea    0xda0(%rip),%rdi
call   1040 <puts@plt>
lea    0xd56(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   10a0 <getchar@plt>
lea    0xdf9(%rip),%rdi
lea    0xd4d(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1471 <main+0x231>
lea    0xdb3(%rip),%rdi
lea    0xd2c(%rip),%rsi
call   1130 <fopen@plt>
test   %rax,%rax
je     147a <main+0x23a>
mov    %rax,%rbx
lea    0x20(%rsp),%rdi
mov    $0x23,%esi
mov    0x8(%rsp),%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     148d <main+0x24d>
mov    $0x1,%r12d
lea    0x20(%rsp),%r14
lea    0x50(%rsp),%rbp
jmp    13d2 <main+0x192>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %r15d,%r15d
mov    %r13d,0x14(%rsp)
imul   $0x26e978d5,%r12d,%eax
ror    $0x2,%eax
cmp    $0x83126e,%eax
jbe    1460 <main+0x220>
add    $0x1,%r12d
mov    %r14,%rdi
mov    $0x23,%esi
mov    0x8(%rsp),%rdx
call   1080 <fgets@plt>
test   %rax,%rax
setne  %al
test   %al,%r15b
je     1490 <main+0x250>
mov    %r14,%rsi
mov    $0xa,%edx
call   10f0 <mpz_set_str@plt>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10e0 <fseek@plt>
mov    %rbp,%rdi
mov    $0x23,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    $0x1,%r15b
test   %rax,%rax
je     1398 <main+0x158>
mov    %r12d,%r13d
nopl   (%rax)
mov    %rbp,%rsi
mov    $0xa,%edx
call   10f0 <mpz_set_str@plt>
call   10c0 <mpz_mul@plt>
call   1110 <mpz_mod@plt>
call   1100 <mpz_cmp@plt>
test   %rax,%rax
je     1390 <main+0x150>
mov    %rbp,%rdi
mov    $0x23,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
add    %r12d,%r13d
test   %rax,%rax
jne    1410 <main+0x1d0>
jmp    1398 <main+0x158>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xc6a(%rip),%rdi
call   1040 <puts@plt>
jmp    13ad <main+0x16d>
lea    0xc89(%rip),%rdi
jmp    1481 <main+0x241>
lea    0xc5b(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    14f1 <main+0x2b1>
mov    $0x1,%r15b
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
test   %r15b,%r15b
je     14b5 <main+0x275>
lea    0xc0c(%rip),%rdi
call   1040 <puts@plt>
jmp    14c7 <main+0x287>
lea    0xbb6(%rip),%rdi
mov    0x14(%rsp),%esi
xor    %eax,%eax
call   1070 <printf@plt>
call   1120 <mpz_clear@plt>
call   1120 <mpz_clear@plt>
call   1120 <mpz_clear@plt>
call   1120 <mpz_clear@plt>
call   1120 <mpz_clear@plt>
call   1120 <mpz_clear@plt>
call   1120 <mpz_clear@plt>
call   1050 <gmp_randclear@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"1040674049\00"
@.str.1 = [11 x i8] c"2081441641\00"
@.str.2 = [42 x i8] c"Now, I have a message, %Zd.\0A%Zd=%Zd*%Zd.\0A\00"
@.str.3 = [29 x i8] c"And the cipher text is %Zd.\0A\00"
@.str.4 = [32 x i8] c"Next, let us begin the attack.\0A\00"
@.str.5 = [19 x i8] c"Enter to start.Go?\00"
@.str.6 = [17 x i8] c"tableCipherText1\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [38 x i8] c"Failed to open file tableCipherText1\0A\00"
@.str.9 = [17 x i8] c"tableCipherText2\00"
@.str.10 = [38 x i8] c"Failed to open file tableCipherText2\0A\00"
@SEEK_SET = global i32 0
@.str.11 = [12 x i8] c"Waiting...\0A\00"
@.str.12 = [24 x i8] c"Failed, I am sorry 0.0\0A\00"
@.str.13 = [41 x i8] c"OK, I have done, the message is %d, ^_^\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [35 x i8]
%16 = alloca [35 x i8]
%17 = alloca i32*
%18 = alloca i32*
store i32 0, i32* %1
%19 = load i32, i32* %2
%20 = call i32 @mpz_init(i32 %19)
%21 = load i32, i32* %3
%22 = call i32 @mpz_init(i32 %21)
%23 = load i32, i32* %2
%24 = call i32 @mpz_set_str(i32 %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%25 = load i32, i32* %3
%26 = call i32 @mpz_set_str(i32 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 10)
%27 = load i32, i32* %4
%28 = call i32 @mpz_init(i32 %27)
%29 = load i32, i32* %5
%30 = call i32 @mpz_init(i32 %29)
%31 = load i32, i32* %6
%32 = call i32 @mpz_init(i32 %31)
%33 = load i32, i32* %7
%34 = call i32 @mpz_init(i32 %33)
%35 = load i32, i32* %8
%36 = call i32 @mpz_init(i32 %35)
%37 = call i32 @time(i64* %9)
%38 = load i32, i32* %10
%39 = call i32 @gmp_randinit_default(i32 %38)
%40 = load i32, i32* %10
%41 = load i64, i64* %9
%42 = call i32 @gmp_randseed_ui(i32 %40, i64 %41)
br label %43
43: ; preds = %54, %0
%44 = load i32, i32* %5
%45 = load i32, i32* %10
%46 = call i32 @mpz_urandomb(i32 %44, i32 %45, i32 16)
%47 = load i32, i32* %6
%48 = load i32, i32* %10
%49 = call i32 @mpz_urandomb(i32 %47, i32 %48, i32 16)
%50 = load i32, i32* %8
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = call i32 @mpz_mul(i32 %50, i32 %51, i32 %52)
br label %54
54: ; preds = %43
%55 = load i32, i32* %8
%56 = load i32, i32* %3
%57 = call i64 @mpz_cmp(i32 %55, i32 %56)
%58 = icmp sge i64 %57, 0
br i1 %58, label %43, label %59
59: ; preds = %54
%60 = load i32, i32* %4
%61 = load i32, i32* %8
%62 = load i32, i32* %2
%63 = load i32, i32* %3
%64 = call i32 @mpz_powm(i32 %60, i32 %61, i32 %62, i32 %63)
%65 = load i32, i32* %8
%66 = load i32, i32* %8
%67 = load i32, i32* %5
%68 = load i32, i32* %6
%69 = call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 %65, i32 %66, i32 %67, i32 %68)
%70 = load i32, i32* %4
%71 = call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %70)
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%74 = call i32 (...) @getchar()
store i32 0, i32* %14
%75 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %75, i32** %17
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %79
77: ; preds = %59
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %1
br label %170
79: ; preds = %59
%80 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %80, i32** %18
%81 = icmp eq i32* %80, null
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
store i32 -1, i32* %1
br label %170
84: ; preds = %79
store i32 1, i32* %11
br label %85
85: ; preds = %138, %84
%86 = getelementptr inbounds [35 x i8], [35 x i8]* %15, i64 0, i64 0
%87 = load i32*, i32** %17
%88 = call i32* @fgets(i8* %86, i32 35, i32* %87)
%89 = icmp ne i32* %88, null
br i1 %89, label %90, label %93
90: ; preds = %85
%91 = load i32, i32* %14
%92 = icmp eq i32 %91, 0
br label %93
93: ; preds = %90, %85
%94 = phi i1 [ false, %85 ], [ %92, %90 ]
br i1 %94, label %95, label %141
95: ; preds = %93
%96 = load i32, i32* %5
%97 = getelementptr inbounds [35 x i8], [35 x i8]* %15, i64 0, i64 0
%98 = call i32 @mpz_set_str(i32 %96, i8* %97, i32 10)
%99 = load i32*, i32** %18
%100 = load i32, i32* @SEEK_SET
%101 = call i32 @fseek(i32* %99, i32 0, i32 %100)
store i32 1, i32* %12
br label %102
102: ; preds = %128, %95
%103 = getelementptr inbounds [35 x i8], [35 x i8]* %16, i64 0, i64 0
%104 = load i32*, i32** %18
%105 = call i32* @fgets(i8* %103, i32 35, i32* %104)
%106 = icmp ne i32* %105, null
br i1 %106, label %107, label %131
107: ; preds = %102
%108 = load i32, i32* %6
%109 = getelementptr inbounds [35 x i8], [35 x i8]* %16, i64 0, i64 0
%110 = call i32 @mpz_set_str(i32 %108, i8* %109, i32 10)
%111 = load i32, i32* %7
%112 = load i32, i32* %5
%113 = load i32, i32* %6
%114 = call i32 @mpz_mul(i32 %111, i32 %112, i32 %113)
%115 = load i32, i32* %7
%116 = load i32, i32* %7
%117 = load i32, i32* %3
%118 = call i32 @mpz_mod(i32 %115, i32 %116, i32 %117)
%119 = load i32, i32* %4
%120 = load i32, i32* %7
%121 = call i64 @mpz_cmp(i32 %119, i32 %120)
%122 = icmp eq i64 %121, 0
br i1 %122, label %123, label %127
123: ; preds = %107
%124 = load i32, i32* %11
%125 = load i32, i32* %12
%126 = mul nsw i32 %124, %125
store i32 %126, i32* %13
store i32 1, i32* %14
br label %131
127: ; preds = %107
br label %128
128: ; preds = %127
%129 = load i32, i32* %12
%130 = add nsw i32 %129, 1
store i32 %130, i32* %12
br label %102
131: ; preds = %123, %102
%132 = load i32, i32* %11
%133 = srem i32 %132, 500
%134 = icmp eq i32 %133, 0
br i1 %134, label %135, label %137
135: ; preds = %131
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
br label %137
137: ; preds = %135, %131
br label %138
138: ; preds = %137
%139 = load i32, i32* %11
%140 = add nsw i32 %139, 1
store i32 %140, i32* %11
br label %85
141: ; preds = %93
%142 = load i32*, i32** %17
%143 = call i32 @fclose(i32* %142)
%144 = load i32*, i32** %18
%145 = call i32 @fclose(i32* %144)
%146 = load i32, i32* %14
%147 = icmp eq i32 %146, 0
br i1 %147, label %148, label %150
148: ; preds = %141
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
br label %153
150: ; preds = %141
%151 = load i32, i32* %13
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.13, i64 0, i64 0), i32 %151)
br label %153
153: ; preds = %150, %148
%154 = load i32, i32* %4
%155 = call i32 @mpz_clear(i32 %154)
%156 = load i32, i32* %5
%157 = call i32 @mpz_clear(i32 %156)
%158 = load i32, i32* %6
%159 = call i32 @mpz_clear(i32 %158)
%160 = load i32, i32* %7
%161 = call i32 @mpz_clear(i32 %160)
%162 = load i32, i32* %8
%163 = call i32 @mpz_clear(i32 %162)
%164 = load i32, i32* %2
%165 = call i32 @mpz_clear(i32 %164)
%166 = load i32, i32* %3
%167 = call i32 @mpz_clear(i32 %166)
%168 = load i32, i32* %10
%169 = call i32 @gmp_randclear(i32 %168)
store i32 0, i32* %1
br label %170
170: ; preds = %153, %82, %77
%171 = load i32, i32* %1
ret i32 %171
}

LLVM IR (-O2):
@.str = [11 x i8] c"1040674049\00"
@.str.1 = [11 x i8] c"2081441641\00"
@.str.2 = [42 x i8] c"Now, I have a message, %Zd.\0A%Zd=%Zd*%Zd.\0A\00"
@.str.3 = [29 x i8] c"And the cipher text is %Zd.\0A\00"
@.str.5 = [19 x i8] c"Enter to start.Go?\00"
@.str.6 = [17 x i8] c"tableCipherText1\00"
@.str.7 = [2 x i8] c"r\00"
@.str.9 = [17 x i8] c"tableCipherText2\00"
@SEEK_SET = global i32 0
@.str.13 = [41 x i8] c"OK, I have done, the message is %d, ^_^\0A\00"
@str = [31 x i8] c"Next, let us begin the attack.\00"
@str.14 = [23 x i8] c"Failed, I am sorry 0.0\00"
@str.15 = [11 x i8] c"Waiting...\00"
@str.16 = [37 x i8] c"Failed to open file tableCipherText2\00"
@str.17 = [37 x i8] c"Failed to open file tableCipherText1\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca [35 x i8]
%3 = alloca [35 x i8]
%4 = tail call i32 @mpz_init(i32 undef)
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_set_str(i32 undef, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%7 = tail call i32 @mpz_set_str(i32 undef, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 10)
%8 = tail call i32 @mpz_init(i32 undef)
%9 = tail call i32 @mpz_init(i32 undef)
%10 = tail call i32 @mpz_init(i32 undef)
%11 = tail call i32 @mpz_init(i32 undef)
%12 = tail call i32 @mpz_init(i32 undef)
%13 = bitcast i64* %1 to i8*
%14 = call i32 @time(i64* %1)
%15 = call i32 @gmp_randinit_default(i32 undef)
%16 = load i64, i64* %1
%17 = call i32 @gmp_randseed_ui(i32 undef, i64 %16)
br label %18
18: ; preds = %18, %0
%19 = call i32 @mpz_urandomb(i32 undef, i32 undef, i32 16)
%20 = call i32 @mpz_urandomb(i32 undef, i32 undef, i32 16)
%21 = call i32 @mpz_mul(i32 undef, i32 undef, i32 undef)
%22 = call i64 @mpz_cmp(i32 undef, i32 undef)
%23 = icmp sgt i64 %22, -1
br i1 %23, label %18, label %24
24: ; preds = %18
%25 = call i32 @mpz_powm(i32 undef, i32 undef, i32 undef, i32 undef)
%26 = call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 undef, i32 undef, i32 undef, i32 undef)
%27 = call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 undef)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 (...) @getchar()
%31 = getelementptr inbounds [35 x i8], [35 x i8]* %2, i64 0, i64 0
%32 = getelementptr inbounds [35 x i8], [35 x i8]* %3, i64 0, i64 0
%33 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %37
35: ; preds = %24
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.17, i64 0, i64 0))
br label %96
37: ; preds = %24
%38 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = call i32* @fgets(i8* %31, i32 35, i32* %33)
%42 = icmp eq i32* %41, null
br i1 %42, label %78, label %45
43: ; preds = %37
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.16, i64 0, i64 0))
br label %96
45: ; preds = %40, %73
%46 = phi i32 [ %67, %73 ], [ undef, %40 ]
%47 = phi i32 [ %74, %73 ], [ 1, %40 ]
%48 = call i32 @mpz_set_str(i32 undef, i8* %31, i32 10)
%49 = load i32, i32* @SEEK_SET
%50 = call i32 @fseek(i32* %38, i32 0, i32 %49)
%51 = call i32* @fgets(i8* %32, i32 35, i32* %38)
%52 = icmp eq i32* %51, null
br i1 %52, label %66, label %53
53: ; preds = %45, %62
%54 = phi i32 [ %63, %62 ], [ 1, %45 ]
%55 = call i32 @mpz_set_str(i32 undef, i8* %32, i32 10)
%56 = call i32 @mpz_mul(i32 undef, i32 undef, i32 undef)
%57 = call i32 @mpz_mod(i32 undef, i32 undef, i32 undef)
%58 = call i64 @mpz_cmp(i32 undef, i32 undef)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %53
%61 = mul nsw i32 %54, %47
br label %66
62: ; preds = %53
%63 = add nuw nsw i32 %54, 1
%64 = call i32* @fgets(i8* %32, i32 35, i32* %38)
%65 = icmp eq i32* %64, null
br i1 %65, label %66, label %53
66: ; preds = %62, %45, %60
%67 = phi i32 [ %61, %60 ], [ %46, %45 ], [ %46, %62 ]
%68 = phi i1 [ false, %60 ], [ true, %45 ], [ true, %62 ]
%69 = urem i32 %47, 500
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.15, i64 0, i64 0))
br label %73
73: ; preds = %66, %71
%74 = add nuw nsw i32 %47, 1
%75 = call i32* @fgets(i8* %31, i32 35, i32* %33)
%76 = icmp ne i32* %75, null
%77 = and i1 %68, %76
br i1 %77, label %45, label %78
78: ; preds = %73, %40
%79 = phi i32 [ undef, %40 ], [ %67, %73 ]
%80 = phi i1 [ true, %40 ], [ %68, %73 ]
%81 = call i32 @fclose(i32* %33)
%82 = call i32 @fclose(i32* %38)
br i1 %80, label %83, label %85
83: ; preds = %78
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.14, i64 0, i64 0))
br label %87
85: ; preds = %78
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.13, i64 0, i64 0), i32 %79)
br label %87
87: ; preds = %85, %83
%88 = call i32 @mpz_clear(i32 undef)
%89 = call i32 @mpz_clear(i32 undef)
%90 = call i32 @mpz_clear(i32 undef)
%91 = call i32 @mpz_clear(i32 undef)
%92 = call i32 @mpz_clear(i32 undef)
%93 = call i32 @mpz_clear(i32 undef)
%94 = call i32 @mpz_clear(i32 undef)
%95 = call i32 @gmp_randclear(i32 undef)
br label %96
96: ; preds = %87, %43, %35
%97 = phi i32 [ -1, %35 ], [ -1, %43 ], [ 0, %87 ]
ret i32 %97
}