#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 */
int pgcd(long, long);
long phi_n(long, long);
long random_numberC(long);
long calcul_e(long p, long q) {
  long phi = phi_n(p, q);
  long e = random_numberC(phi);
  int boolean = 1;
  while (boolean) {
    if ((e > 0) && (e < phi) && (pgcd(e, phi) == 1)) {
      boolean = 0;
    } else {
      e = random_numberC(phi);
    }
  }
  return e;
}


x86 assembly (clang, -O0):
<calcul_e>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <phi_n@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <random_numberC@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11bc <calcul_e+0x8c>
cmpq   $0x0,-0x20(%rbp)
jle    11aa <calcul_e+0x7a>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11aa <calcul_e+0x7a>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <pgcd@plt>
cmp    $0x1,%eax
jne    11aa <calcul_e+0x7a>
movl   $0x0,-0x24(%rbp)
jmp    11b7 <calcul_e+0x87>
mov    -0x18(%rbp),%rdi
call   1030 <random_numberC@plt>
mov    %rax,-0x20(%rbp)
jmp    1165 <calcul_e+0x35>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcul_e>:
push   %r14
push   %rbx
push   %rax
call   1040 <phi_n@plt>
mov    %rax,%r14
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <random_numberC@plt>
test   %rax,%rax
jle    1140 <calcul_e+0x10>
mov    %rax,%rbx
cmp    %r14,%rax
jge    1140 <calcul_e+0x10>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <pgcd@plt>
cmp    $0x1,%eax
jne    1140 <calcul_e+0x10>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @calcul_e(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
store i64 %0, i64* %3
store i64 %1, i64* %4
%8 = load i64, i64* %3
%9 = load i64, i64* %4
%10 = call i64 @phi_n(i64 %8, i64 %9)
store i64 %10, i64* %5
%11 = load i64, i64* %5
%12 = call i64 @random_numberC(i64 %11)
store i64 %12, i64* %6
store i32 1, i32* %7
br label %13
13: ; preds = %32, %2
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %33
16: ; preds = %13
%17 = load i64, i64* %6
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load i64, i64* %6
%21 = load i64, i64* %5
%22 = icmp slt i64 %20, %21
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i64, i64* %6
%25 = load i64, i64* %5
%26 = call i32 @pgcd(i64 %24, i64 %25)
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 0, i32* %7
br label %32
29: ; preds = %23, %19, %16
%30 = load i64, i64* %5
%31 = call i64 @random_numberC(i64 %30)
store i64 %31, i64* %6
br label %32
32: ; preds = %29, %28
br label %13
33: ; preds = %13
%34 = load i64, i64* %6
ret i64 %34
}

LLVM IR (-O2):
define i64 @calcul_e(i64 %0, i64 %1) {
%3 = tail call i64 @phi_n(i64 %0, i64 %1)
br label %4
4: ; preds = %9, %2
%5 = tail call i64 @random_numberC(i64 %3)
%6 = icmp sgt i64 %5, 0
%7 = icmp slt i64 %5, %3
%8 = and i1 %6, %7
br i1 %8, label %10, label %9
9: ; preds = %4, %10
br label %4
10: ; preds = %4
%11 = tail call i32 @pgcd(i64 %5, i64 %3)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %9
13: ; preds = %10
ret i64 %5
}