#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ gmp_randinit_default(int /*<<< orphan*/);
int /*<<< orphan*/ gmp_randseed_ui(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmpabs_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_gcd(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init2(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_invert(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_out_str(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_sub_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_urandomb(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ primeKeyGeneration(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int keyGeneration() {
  printf("--------------------------------------\n");
  printf("        Generation of Key\n");
  printf("--------------------------------------\n");
  gmp_randstate_t state;
  gmp_randinit_default(state);
  gmp_randseed_ui(state, time(NULL));
  mpz_t p;
  mpz_t q;
  mpz_t n;
  mpz_t pMinusOne;
  mpz_t qMinusOne;
  mpz_t phi;
  mpz_t e;
  mpz_t pgcdEPhi;
  mpz_t d;
  mpz_init2(p, 2048);
  mpz_init2(q, 2048);
  mpz_init2(n, 2048);
  mpz_init2(pMinusOne, 2048);
  mpz_init2(qMinusOne, 2048);
  mpz_init2(phi, 2048);
  mpz_init2(e, 2048);
  mpz_init2(pgcdEPhi, 2048);
  mpz_init2(d, 2048);
  FILE *privateFile = fopen("out/prive.rsa", "w+");
  FILE *publicFile = fopen("out/public.rsa", "w+");
  if (privateFile == NULL || publicFile == NULL) {
    printf("Error in opening private or public file ! \n");
    return -1;
  }
  primeKeyGeneration(p);
  gmp_printf("p = %Zd\n\n", p);
  sleep(1);
  primeKeyGeneration(q);
  gmp_printf("q = %Zd\n\n", q);
  mpz_mul(n, p, q);
  mpz_sub_ui(pMinusOne, p, 1);
  mpz_sub_ui(qMinusOne, q, 1);
  mpz_mul(phi, pMinusOne, qMinusOne);
  mpz_urandomb(e, state, 2048);
  mpz_gcd(pgcdEPhi, e, phi);
  while (mpz_cmpabs_ui(pgcdEPhi, 1) != 0) {
    mpz_urandomb(e, state, 2048);
    mpz_gcd(pgcdEPhi, e, phi);
  }
  mpz_invert(d, e, phi);
  mpz_out_str(privateFile, 16, p);
  fputs("\n", privateFile);
  mpz_out_str(privateFile, 16, q);
  fputs("\n", privateFile);
  mpz_out_str(privateFile, 16, d);
  printf("-> (p,q,d) generated in prive.rsa\n");
  mpz_out_str(publicFile, 16, n);
  fputs("\n", publicFile);
  mpz_out_str(publicFile, 16, e);
  printf("-> (n,e) generated in public.rsa\n");
  printf("--------------------------------------\n");
  mpz_clear(p);
  mpz_clear(q);
  mpz_clear(n);
  mpz_clear(pMinusOne);
  mpz_clear(qMinusOne);
  mpz_clear(phi);
  mpz_clear(e);
  mpz_clear(pgcdEPhi);
  mpz_clear(d);
  fclose(privateFile);
  fclose(publicFile);
  return 0;
}


x86 assembly (clang, -O0):
<keyGeneration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xdc1(%rip),%rdi
call   1040 <printf@plt>
lea    0xddd(%rip),%rdi
call   1040 <printf@plt>
lea    0xda9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1140 <gmp_randinit_default@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x44(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    -0x44(%rbp),%edi
mov    %eax,%esi
call   1100 <gmp_randseed_ui@plt>
mov    -0xc(%rbp),%edi
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    -0x10(%rbp),%edi
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    -0x14(%rbp),%edi
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    -0x18(%rbp),%edi
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    -0x1c(%rbp),%edi
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    -0x20(%rbp),%edi
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    -0x24(%rbp),%edi
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    -0x28(%rbp),%edi
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    -0x2c(%rbp),%edi
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
lea    0xd4a(%rip),%rdi
lea    0xd51(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x38(%rbp)
lea    0xd44(%rip),%rdi
lea    0xd3a(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1336 <keyGeneration+0x106>
cmpq   $0x0,-0x40(%rbp)
jne    134e <keyGeneration+0x11e>
lea    0xd26(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1532 <keyGeneration+0x302>
mov    -0xc(%rbp),%edi
call   10d0 <primeKeyGeneration@plt>
mov    -0xc(%rbp),%esi
lea    0xd2f(%rip),%rdi
call   1130 <gmp_printf@plt>
mov    $0x1,%edi
call   1150 <sleep@plt>
mov    -0x10(%rbp),%edi
call   10d0 <primeKeyGeneration@plt>
mov    -0x10(%rbp),%esi
lea    0xd18(%rip),%rdi
call   1130 <gmp_printf@plt>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1080 <mpz_mul@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
call   10b0 <mpz_sub_ui@plt>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x1,%edx
call   10b0 <mpz_sub_ui@plt>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1080 <mpz_mul@plt>
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x800,%edx
call   1070 <mpz_urandomb@plt>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1120 <mpz_gcd@plt>
mov    -0x28(%rbp),%edi
mov    $0x1,%esi
call   10c0 <mpz_cmpabs_ui@plt>
cmp    $0x0,%rax
je     141a <keyGeneration+0x1ea>
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x800,%edx
call   1070 <mpz_urandomb@plt>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1120 <mpz_gcd@plt>
jmp    13e0 <keyGeneration+0x1b0>
mov    -0x2c(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1060 <mpz_invert@plt>
mov    -0x38(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
mov    -0x38(%rbp),%rsi
lea    0xc53(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
mov    -0x38(%rbp),%rsi
lea    0xc32(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
lea    0xc21(%rip),%rdi
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
mov    -0x40(%rbp),%rsi
lea    0xbf4(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x40(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
lea    0xc06(%rip),%rdi
call   1040 <printf@plt>
lea    0xb34(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   10e0 <mpz_clear@plt>
mov    -0x10(%rbp),%edi
call   10e0 <mpz_clear@plt>
mov    -0x14(%rbp),%edi
call   10e0 <mpz_clear@plt>
mov    -0x18(%rbp),%edi
call   10e0 <mpz_clear@plt>
mov    -0x1c(%rbp),%edi
call   10e0 <mpz_clear@plt>
mov    -0x20(%rbp),%edi
call   10e0 <mpz_clear@plt>
mov    -0x24(%rbp),%edi
call   10e0 <mpz_clear@plt>
mov    -0x28(%rbp),%edi
call   10e0 <mpz_clear@plt>
mov    -0x2c(%rbp),%edi
call   10e0 <mpz_clear@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keyGeneration>:
push   %r15
push   %r14
push   %rbx
lea    0xe55(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xde9(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
call   1140 <gmp_randinit_default@plt>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%esi
call   1100 <gmp_randseed_ui@plt>
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
mov    $0x800,%esi
call   1110 <mpz_init2@plt>
lea    0xd34(%rip),%rdi
lea    0xd3b(%rip),%rbx
mov    %rbx,%rsi
call   10f0 <fopen@plt>
mov    %rax,%r15
lea    0xd2c(%rip),%rdi
mov    %rbx,%rsi
call   10f0 <fopen@plt>
test   %r15,%r15
je     1440 <keyGeneration+0x210>
mov    %rax,%r14
test   %rax,%rax
je     1440 <keyGeneration+0x210>
call   10d0 <primeKeyGeneration@plt>
lea    0xd12(%rip),%rdi
call   1130 <gmp_printf@plt>
mov    $0x1,%edi
call   1150 <sleep@plt>
call   10d0 <primeKeyGeneration@plt>
lea    0xd01(%rip),%rdi
call   1130 <gmp_printf@plt>
call   1080 <mpz_mul@plt>
mov    $0x1,%edx
call   10b0 <mpz_sub_ui@plt>
mov    $0x1,%edx
call   10b0 <mpz_sub_ui@plt>
call   1080 <mpz_mul@plt>
nopl   0x0(%rax)
mov    $0x800,%edx
call   1070 <mpz_urandomb@plt>
call   1120 <mpz_gcd@plt>
mov    $0x1,%esi
call   10c0 <mpz_cmpabs_ui@plt>
test   %rax,%rax
jne    1350 <keyGeneration+0x120>
call   1060 <mpz_invert@plt>
mov    %r15,%rdi
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
mov    $0xa,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    %r15,%rdi
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
mov    $0xa,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
mov    %r15,%rdi
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
lea    0xc93(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    %r14,%rdi
mov    $0x10,%esi
call   10a0 <mpz_out_str@plt>
lea    0xc82(%rip),%rdi
call   1030 <puts@plt>
lea    0xc97(%rip),%rdi
call   1030 <puts@plt>
call   10e0 <mpz_clear@plt>
call   10e0 <mpz_clear@plt>
call   10e0 <mpz_clear@plt>
call   10e0 <mpz_clear@plt>
call   10e0 <mpz_clear@plt>
call   10e0 <mpz_clear@plt>
call   10e0 <mpz_clear@plt>
call   10e0 <mpz_clear@plt>
call   10e0 <mpz_clear@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1451 <keyGeneration+0x221>
lea    0xc71(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [40 x i8] c"--------------------------------------\0A\00"
@.str.1 = [27 x i8] c" Generation of Key\0A\00"
@.str.2 = [14 x i8] c"out/prive.rsa\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [15 x i8] c"out/public.rsa\00"
@.str.5 = [44 x i8] c"Error in opening private or public file ! \0A\00"
@.str.6 = [10 x i8] c"p = %Zd\0A\0A\00"
@.str.7 = [10 x i8] c"q = %Zd\0A\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [35 x i8] c"-> (p,q,d) generated in prive.rsa\0A\00"
@.str.10 = [34 x i8] c"-> (n,e) generated in public.rsa\0A\00"
define i32 @keyGeneration() {
%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 i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %2
%18 = call i32 @gmp_randinit_default(i32 %17)
%19 = load i32, i32* %2
%20 = call i32 @time(i32* null)
%21 = call i32 @gmp_randseed_ui(i32 %19, i32 %20)
%22 = load i32, i32* %3
%23 = call i32 @mpz_init2(i32 %22, i32 2048)
%24 = load i32, i32* %4
%25 = call i32 @mpz_init2(i32 %24, i32 2048)
%26 = load i32, i32* %5
%27 = call i32 @mpz_init2(i32 %26, i32 2048)
%28 = load i32, i32* %6
%29 = call i32 @mpz_init2(i32 %28, i32 2048)
%30 = load i32, i32* %7
%31 = call i32 @mpz_init2(i32 %30, i32 2048)
%32 = load i32, i32* %8
%33 = call i32 @mpz_init2(i32 %32, i32 2048)
%34 = load i32, i32* %9
%35 = call i32 @mpz_init2(i32 %34, i32 2048)
%36 = load i32, i32* %10
%37 = call i32 @mpz_init2(i32 %36, i32 2048)
%38 = load i32, i32* %11
%39 = call i32 @mpz_init2(i32 %38, i32 2048)
%40 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %40, i32** %12
%41 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %41, i32** %13
%42 = load i32*, i32** %12
%43 = icmp eq i32* %42, null
br i1 %43, label %47, label %44
44: ; preds = %0
%45 = load i32*, i32** %13
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %49
47: ; preds = %44, %0
%48 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %143
49: ; preds = %44
%50 = load i32, i32* %3
%51 = call i32 @primeKeyGeneration(i32 %50)
%52 = load i32, i32* %3
%53 = call i32 @gmp_printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %52)
%54 = call i32 @sleep(i32 1)
%55 = load i32, i32* %4
%56 = call i32 @primeKeyGeneration(i32 %55)
%57 = load i32, i32* %4
%58 = call i32 @gmp_printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %5
%60 = load i32, i32* %3
%61 = load i32, i32* %4
%62 = call i32 @mpz_mul(i32 %59, i32 %60, i32 %61)
%63 = load i32, i32* %6
%64 = load i32, i32* %3
%65 = call i32 @mpz_sub_ui(i32 %63, i32 %64, i32 1)
%66 = load i32, i32* %7
%67 = load i32, i32* %4
%68 = call i32 @mpz_sub_ui(i32 %66, i32 %67, i32 1)
%69 = load i32, i32* %8
%70 = load i32, i32* %6
%71 = load i32, i32* %7
%72 = call i32 @mpz_mul(i32 %69, i32 %70, i32 %71)
%73 = load i32, i32* %9
%74 = load i32, i32* %2
%75 = call i32 @mpz_urandomb(i32 %73, i32 %74, i32 2048)
%76 = load i32, i32* %10
%77 = load i32, i32* %9
%78 = load i32, i32* %8
%79 = call i32 @mpz_gcd(i32 %76, i32 %77, i32 %78)
br label %80
80: ; preds = %84, %49
%81 = load i32, i32* %10
%82 = call i64 @mpz_cmpabs_ui(i32 %81, i32 1)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %92
84: ; preds = %80
%85 = load i32, i32* %9
%86 = load i32, i32* %2
%87 = call i32 @mpz_urandomb(i32 %85, i32 %86, i32 2048)
%88 = load i32, i32* %10
%89 = load i32, i32* %9
%90 = load i32, i32* %8
%91 = call i32 @mpz_gcd(i32 %88, i32 %89, i32 %90)
br label %80
92: ; preds = %80
%93 = load i32, i32* %11
%94 = load i32, i32* %9
%95 = load i32, i32* %8
%96 = call i32 @mpz_invert(i32 %93, i32 %94, i32 %95)
%97 = load i32*, i32** %12
%98 = load i32, i32* %3
%99 = call i32 @mpz_out_str(i32* %97, i32 16, i32 %98)
%100 = load i32*, i32** %12
%101 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %100)
%102 = load i32*, i32** %12
%103 = load i32, i32* %4
%104 = call i32 @mpz_out_str(i32* %102, i32 16, i32 %103)
%105 = load i32*, i32** %12
%106 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %105)
%107 = load i32*, i32** %12
%108 = load i32, i32* %11
%109 = call i32 @mpz_out_str(i32* %107, i32 16, i32 %108)
%110 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%111 = load i32*, i32** %13
%112 = load i32, i32* %5
%113 = call i32 @mpz_out_str(i32* %111, i32 16, i32 %112)
%114 = load i32*, i32** %13
%115 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %114)
%116 = load i32*, i32** %13
%117 = load i32, i32* %9
%118 = call i32 @mpz_out_str(i32* %116, i32 16, i32 %117)
%119 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
%120 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%121 = load i32, i32* %3
%122 = call i32 @mpz_clear(i32 %121)
%123 = load i32, i32* %4
%124 = call i32 @mpz_clear(i32 %123)
%125 = load i32, i32* %5
%126 = call i32 @mpz_clear(i32 %125)
%127 = load i32, i32* %6
%128 = call i32 @mpz_clear(i32 %127)
%129 = load i32, i32* %7
%130 = call i32 @mpz_clear(i32 %129)
%131 = load i32, i32* %8
%132 = call i32 @mpz_clear(i32 %131)
%133 = load i32, i32* %9
%134 = call i32 @mpz_clear(i32 %133)
%135 = load i32, i32* %10
%136 = call i32 @mpz_clear(i32 %135)
%137 = load i32, i32* %11
%138 = call i32 @mpz_clear(i32 %137)
%139 = load i32*, i32** %12
%140 = call i32 @fclose(i32* %139)
%141 = load i32*, i32** %13
%142 = call i32 @fclose(i32* %141)
store i32 0, i32* %1
br label %143
143: ; preds = %92, %47
%144 = load i32, i32* %1
ret i32 %144
}

LLVM IR (-O2):
@.str.2 = [14 x i8] c"out/prive.rsa\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [15 x i8] c"out/public.rsa\00"
@.str.6 = [10 x i8] c"p = %Zd\0A\0A\00"
@.str.7 = [10 x i8] c"q = %Zd\0A\0A\00"
@str.11 = [26 x i8] c" Generation of Key\00"
@str.13 = [34 x i8] c"-> (p,q,d) generated in prive.rsa\00"
@str.14 = [33 x i8] c"-> (n,e) generated in public.rsa\00"
@str.15 = [39 x i8] c"--------------------------------------\00"
@str.16 = [43 x i8] c"Error in opening private or public file ! \00"
define i32 @keyGeneration() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.15, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.15, i64 0, i64 0))
%4 = tail call i32 @gmp_randinit_default(i32 undef)
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @gmp_randseed_ui(i32 undef, i32 %5)
%7 = tail call i32 @mpz_init2(i32 undef, i32 2048)
%8 = tail call i32 @mpz_init2(i32 undef, i32 2048)
%9 = tail call i32 @mpz_init2(i32 undef, i32 2048)
%10 = tail call i32 @mpz_init2(i32 undef, i32 2048)
%11 = tail call i32 @mpz_init2(i32 undef, i32 2048)
%12 = tail call i32 @mpz_init2(i32 undef, i32 2048)
%13 = tail call i32 @mpz_init2(i32 undef, i32 2048)
%14 = tail call i32 @mpz_init2(i32 undef, i32 2048)
%15 = tail call i32 @mpz_init2(i32 undef, i32 2048)
%16 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32* %16, null
%19 = icmp eq i32* %17, null
%20 = or i1 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.16, i64 0, i64 0))
br label %66
23: ; preds = %0
%24 = tail call i32 @primeKeyGeneration(i32 undef)
%25 = tail call i32 @gmp_printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 undef)
%26 = tail call i32 @sleep(i32 1)
%27 = tail call i32 @primeKeyGeneration(i32 undef)
%28 = tail call i32 @gmp_printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 undef)
%29 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 undef)
%30 = tail call i32 @mpz_sub_ui(i32 undef, i32 undef, i32 1)
%31 = tail call i32 @mpz_sub_ui(i32 undef, i32 undef, i32 1)
%32 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 undef)
%33 = tail call i32 @mpz_urandomb(i32 undef, i32 undef, i32 2048)
%34 = tail call i32 @mpz_gcd(i32 undef, i32 undef, i32 undef)
%35 = tail call i64 @mpz_cmpabs_ui(i32 undef, i32 1)
%36 = icmp eq i64 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %23, %37
%38 = tail call i32 @mpz_urandomb(i32 undef, i32 undef, i32 2048)
%39 = tail call i32 @mpz_gcd(i32 undef, i32 undef, i32 undef)
%40 = tail call i64 @mpz_cmpabs_ui(i32 undef, i32 1)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %37
42: ; preds = %37, %23
%43 = tail call i32 @mpz_invert(i32 undef, i32 undef, i32 undef)
%44 = tail call i32 @mpz_out_str(i32* %16, i32 16, i32 undef)
%45 = tail call i32 @fputc(i32 10, i32* %16)
%46 = tail call i32 @mpz_out_str(i32* %16, i32 16, i32 undef)
%47 = tail call i32 @fputc(i32 10, i32* %16)
%48 = tail call i32 @mpz_out_str(i32* %16, i32 16, i32 undef)
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.13, i64 0, i64 0))
%50 = tail call i32 @mpz_out_str(i32* %17, i32 16, i32 undef)
%51 = tail call i32 @fputc(i32 10, i32* %17)
%52 = tail call i32 @mpz_out_str(i32* %17, i32 16, i32 undef)
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.14, i64 0, i64 0))
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.15, i64 0, i64 0))
%55 = tail call i32 @mpz_clear(i32 undef)
%56 = tail call i32 @mpz_clear(i32 undef)
%57 = tail call i32 @mpz_clear(i32 undef)
%58 = tail call i32 @mpz_clear(i32 undef)
%59 = tail call i32 @mpz_clear(i32 undef)
%60 = tail call i32 @mpz_clear(i32 undef)
%61 = tail call i32 @mpz_clear(i32 undef)
%62 = tail call i32 @mpz_clear(i32 undef)
%63 = tail call i32 @mpz_clear(i32 undef)
%64 = tail call i32 @fclose(i32* %16)
%65 = tail call i32 @fclose(i32* %17)
br label %66
66: ; preds = %42, %21
%67 = phi i32 [ -1, %21 ], [ 0, %42 ]
ret i32 %67
}