#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double fmod(double, double);
int gcd(double, double);
double pow(double, double);
int /*<<< orphan*/ printf(char *, double);
int main() {
  double p = 3;
  double q = 7;
  double n = p * q;
  double e = 2;
  double phi = (p - 1) * (q - 1);
  while (e < phi) {
    if (gcd(e, phi) == 1)
      break;
    else
      e++;
  }
  int k = 2;
  double d = (1 + (k * phi)) / e;
  double msg = 12;
  printf("Message data = %lf", msg);
  double c = pow(msg, e);
  c = fmod(c, n);
  printf("\nEncrypted data = %lf", c);
  double m = pow(c, d);
  m = fmod(m, n);
  printf("\nOriginal Message Sent = %lf", m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeac(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe88(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe6e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe5d(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f8 <main+0xb8>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1060 <gcd@plt>
cmp    $0x1,%eax
jne    11e1 <main+0xa1>
jmp    11f8 <main+0xb8>
movsd  0xe17(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11b0 <main+0x70>
movl   $0x2,-0x34(%rbp)
cvtsi2sdl -0x34(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdeb(%rip),%xmm1
addsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdf5(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x48(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <fmod@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
lea    0xdc6(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <fmod@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
lea    0xda3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movsd  0xeb4(%rip),%xmm0
movsd  0xeb4(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xea0(%rip),%xmm0
movsd  0xe90(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xe84(%rip),%xmm0
movsd  0xe6c(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xe68(%rip),%xmm0
movsd  0xe48(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xe4c(%rip),%xmm0
movsd  0xe24(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xe30(%rip),%xmm0
movsd  0xe00(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xe14(%rip),%xmm0
movsd  0xddc(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xdfc(%rip),%xmm0
movsd  0xdbc(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xde4(%rip),%xmm0
movsd  0xd9c(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xdcc(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xd76(%rip),%xmm1
call   1060 <gcd@plt>
cmp    $0x1,%eax
je     12aa <main+0x16a>
movsd  0xd64(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xda6(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xda3(%rip),%rdi
movsd  0xd3b(%rip),%xmm0
call   1030 <printf@plt>
movsd  0xd2e(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
call   1050 <pow@plt>
movsd  0xd73(%rip),%xmm1
call   1040 <fmod@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xd7c(%rip),%rdi
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1050 <pow@plt>
movsd  0xd43(%rip),%xmm1
call   1040 <fmod@plt>
lea    0xd68(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Message data = %lf\00"
@.str.1 = [22 x i8] c"\0AEncrypted data = %lf\00"
@.str.2 = [29 x i8] c"\0AOriginal Message Sent = %lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 0, i32* %1
store double 3.000000e+00, double* %2
store double 7.000000e+00, double* %3
%12 = load double, double* %2
%13 = load double, double* %3
%14 = fmul double %12, %13
store double %14, double* %4
store double 2.000000e+00, double* %5
%15 = load double, double* %2
%16 = fsub double %15, 1.000000e+00
%17 = load double, double* %3
%18 = fsub double %17, 1.000000e+00
%19 = fmul double %16, %18
store double %19, double* %6
br label %20
20: ; preds = %33, %0
%21 = load double, double* %5
%22 = load double, double* %6
%23 = fcmp olt double %21, %22
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load double, double* %5
%26 = load double, double* %6
%27 = call i32 @gcd(double %25, double %26)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %24
br label %34
30: ; preds = %24
%31 = load double, double* %5
%32 = fadd double %31, 1.000000e+00
store double %32, double* %5
br label %33
33: ; preds = %30
br label %20
34: ; preds = %29, %20
store i32 2, i32* %7
%35 = load i32, i32* %7
%36 = sitofp i32 %35 to double
%37 = load double, double* %6
%38 = call double @llvm.fmuladd.f64(double %36, double %37, double 1.000000e+00)
%39 = load double, double* %5
%40 = fdiv double %38, %39
store double %40, double* %8
store double 1.200000e+01, double* %9
%41 = load double, double* %9
%42 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %41)
%43 = load double, double* %9
%44 = load double, double* %5
%45 = call double @pow(double %43, double %44)
store double %45, double* %10
%46 = load double, double* %10
%47 = load double, double* %4
%48 = call double @fmod(double %46, double %47)
store double %48, double* %10
%49 = load double, double* %10
%50 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %49)
%51 = load double, double* %10
%52 = load double, double* %8
%53 = call double @pow(double %51, double %52)
store double %53, double* %11
%54 = load double, double* %11
%55 = load double, double* %4
%56 = call double @fmod(double %54, double %55)
store double %56, double* %11
%57 = load double, double* %11
%58 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double %57)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Message data = %lf\00"
@.str.1 = [22 x i8] c"\0AEncrypted data = %lf\00"
@.str.2 = [29 x i8] c"\0AOriginal Message Sent = %lf\00"
define i32 @main() {
%1 = tail call i32 @gcd(double 2.000000e+00, double 1.200000e+01)
%2 = icmp eq i32 %1, 1
br i1 %2, label %31, label %3
3: ; preds = %0
%4 = tail call i32 @gcd(double 3.000000e+00, double 1.200000e+01)
%5 = icmp eq i32 %4, 1
br i1 %5, label %31, label %6
6: ; preds = %3
%7 = tail call i32 @gcd(double 4.000000e+00, double 1.200000e+01)
%8 = icmp eq i32 %7, 1
br i1 %8, label %31, label %9
9: ; preds = %6
%10 = tail call i32 @gcd(double 5.000000e+00, double 1.200000e+01)
%11 = icmp eq i32 %10, 1
br i1 %11, label %31, label %12
12: ; preds = %9
%13 = tail call i32 @gcd(double 6.000000e+00, double 1.200000e+01)
%14 = icmp eq i32 %13, 1
br i1 %14, label %31, label %15
15: ; preds = %12
%16 = tail call i32 @gcd(double 7.000000e+00, double 1.200000e+01)
%17 = icmp eq i32 %16, 1
br i1 %17, label %31, label %18
18: ; preds = %15
%19 = tail call i32 @gcd(double 8.000000e+00, double 1.200000e+01)
%20 = icmp eq i32 %19, 1
br i1 %20, label %31, label %21
21: ; preds = %18
%22 = tail call i32 @gcd(double 9.000000e+00, double 1.200000e+01)
%23 = icmp eq i32 %22, 1
br i1 %23, label %31, label %24
24: ; preds = %21
%25 = tail call i32 @gcd(double 1.000000e+01, double 1.200000e+01)
%26 = icmp eq i32 %25, 1
br i1 %26, label %31, label %27
27: ; preds = %24
%28 = tail call i32 @gcd(double 1.100000e+01, double 1.200000e+01)
%29 = icmp eq i32 %28, 1
%30 = select i1 %29, double 1.100000e+01, double 1.200000e+01
br label %31
31: ; preds = %27, %24, %21, %18, %15, %12, %9, %6, %3, %0
%32 = phi double [ 2.000000e+00, %0 ], [ 3.000000e+00, %3 ], [ 4.000000e+00, %6 ], [ 5.000000e+00, %9 ], [ 6.000000e+00, %12 ], [ 7.000000e+00, %15 ], [ 8.000000e+00, %18 ], [ 9.000000e+00, %21 ], [ 1.000000e+01, %24 ], [ %30, %27 ]
%33 = fdiv double 2.500000e+01, %32
%34 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double 1.200000e+01)
%35 = tail call double @pow(double 1.200000e+01, double %32)
%36 = tail call double @fmod(double %35, double 2.100000e+01)
%37 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %36)
%38 = tail call double @pow(double %36, double %33)
%39 = tail call double @fmod(double %38, double 2.100000e+01)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double %39)
ret i32 0
}