#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;

/* Variables and functions */
int /*<<< orphan*/ findED(int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int /*<<< orphan*/ getRandomKey(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int);
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, unsigned long *);
int main(int argc, char **argv) {
  unsigned long int n;
  mpz_t key, p, q, e, d;
  mpz_init(key);
  mpz_init(p);
  mpz_init(q);
  mpz_init(e);
  mpz_init(d);
  printf("Key lengths:\n");
  printf(
      "[1]\tLength: 1024 bit\n[2]\tLength: 2048 bit\n[3]\tLength: 4096 bit\n");
  printf("Choose your length: ");
  scanf("%ld", &n);
  switch (n) {
  case 1:
    getRandomKey(key, p, q, 1024);
    break;
  case 2:
    getRandomKey(key, p, q, 2048);
    break;
  case 3:
    getRandomKey(key, p, q, 4096);
    break;
  default:
    printf("Forbidden value... defalut key length 2048!\n");
    getRandomKey(key, p, q, 2048);
    break;
  }
  gmp_printf("Your 'Key': %Zd\n\nYour 'p': %Zd\n\nYour 'q': %Zd\n\n", key, p,
             q);
  findED(key, p, q, e, d);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x20(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x24(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x28(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x2c(%rbp),%edi
call   1050 <mpz_init@plt>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
sub    $0x1,%rax
je     120f <main+0xaf>
jmp    11e9 <main+0x89>
mov    -0x38(%rbp),%rax
sub    $0x2,%rax
je     1227 <main+0xc7>
jmp    11fc <main+0x9c>
mov    -0x38(%rbp),%rax
sub    $0x3,%rax
je     123f <main+0xdf>
jmp    1257 <main+0xf7>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x400,%ecx
call   1060 <getRandomKey@plt>
jmp    1276 <main+0x116>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x800,%ecx
call   1060 <getRandomKey@plt>
jmp    1276 <main+0x116>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x1000,%ecx
call   1060 <getRandomKey@plt>
jmp    1276 <main+0x116>
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x800,%ecx
call   1060 <getRandomKey@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe0e(%rip),%rdi
call   1080 <gmp_printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1030 <findED@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1060 <mpz_init@plt>
call   1060 <mpz_init@plt>
call   1060 <mpz_init@plt>
call   1060 <mpz_init@plt>
call   1060 <mpz_init@plt>
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
lea    0xe60(%rip),%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%rax
lea    -0x1(%rax),%rcx
cmp    $0x3,%rcx
jae    11d8 <main+0x68>
lea    0xef2(%rip),%rcx
mov    -0x4(%rcx,%rax,4),%ecx
jmp    11e9 <main+0x79>
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x800,%ecx
call   1070 <getRandomKey@plt>
lea    0xe24(%rip),%rdi
call   1090 <gmp_printf@plt>
call   1030 <findED@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Key lengths:\0A\00"
@.str.1 = [64 x i8] c"[1]\09Length: 1024 bit\0A[2]\09Length: 2048 bit\0A[3]\09Length: 4096 bit\0A\00"
@.str.2 = [21 x i8] c"Choose your length: \00"
@.str.3 = [4 x i8] c"%ld\00"
@.str.4 = [45 x i8] c"Forbidden value... defalut key length 2048!\0A\00"
@.str.5 = [48 x i8] c"Your 'Key': %Zd\0A\0AYour 'p': %Zd\0A\0AYour 'q': %Zd\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %7
%13 = call i32 @mpz_init(i32 %12)
%14 = load i32, i32* %8
%15 = call i32 @mpz_init(i32 %14)
%16 = load i32, i32* %9
%17 = call i32 @mpz_init(i32 %16)
%18 = load i32, i32* %10
%19 = call i32 @mpz_init(i32 %18)
%20 = load i32, i32* %11
%21 = call i32 @mpz_init(i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %6)
%26 = load i64, i64* %6
switch i64 %26, label %42 [
i64 1, label %27
i64 2, label %32
i64 3, label %37
]
27: ; preds = %2
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = call i32 @getRandomKey(i32 %28, i32 %29, i32 %30, i32 1024)
br label %48
32: ; preds = %2
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = call i32 @getRandomKey(i32 %33, i32 %34, i32 %35, i32 2048)
br label %48
37: ; preds = %2
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = call i32 @getRandomKey(i32 %38, i32 %39, i32 %40, i32 4096)
br label %48
42: ; preds = %2
%43 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%44 = load i32, i32* %7
%45 = load i32, i32* %8
%46 = load i32, i32* %9
%47 = call i32 @getRandomKey(i32 %44, i32 %45, i32 %46, i32 2048)
br label %48
48: ; preds = %42, %37, %32, %27
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = load i32, i32* %9
%52 = call i32 @gmp_printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %49, i32 %50, i32 %51)
%53 = load i32, i32* %7
%54 = load i32, i32* %8
%55 = load i32, i32* %9
%56 = load i32, i32* %10
%57 = load i32, i32* %11
%58 = call i32 @findED(i32 %53, i32 %54, i32 %55, i32 %56, i32 %57)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"Choose your length: \00"
@.str.3 = [4 x i8] c"%ld\00"
@.str.5 = [48 x i8] c"Your 'Key': %Zd\0A\0AYour 'p': %Zd\0A\0AYour 'q': %Zd\0A\0A\00"
@str = [13 x i8] c"Key lengths:\00"
@str.6 = [63 x i8] c"[1]\09Length: 1024 bit\0A[2]\09Length: 2048 bit\0A[3]\09Length: 4096 bit\00"
@str.7 = [44 x i8] c"Forbidden value... defalut key length 2048!\00"
@switch.table.main = [3 x i32] [i32 1024, i32 2048, i32 4096]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_init(i32 undef)
%7 = tail call i32 @mpz_init(i32 undef)
%8 = tail call i32 @mpz_init(i32 undef)
%9 = tail call i32 @mpz_init(i32 undef)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.6, i64 0, i64 0))
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %3)
%14 = load i64, i64* %3
%15 = add i64 %14, -1
%16 = icmp ult i64 %15, 3
br i1 %16, label %19, label %17
17: ; preds = %2
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.7, i64 0, i64 0))
br label %22
19: ; preds = %2
%20 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.main, i64 0, i64 %15
%21 = load i32, i32* %20
br label %22
22: ; preds = %19, %17
%23 = phi i32 [ 2048, %17 ], [ %21, %19 ]
%24 = call i32 @getRandomKey(i32 undef, i32 undef, i32 undef, i32 %23)
%25 = call i32 @gmp_printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 undef, i32 undef, i32 undef)
%26 = call i32 @findED(i32 undef, i32 undef, i32 undef, i32 undef, i32 undef)
ret i32 0
}