#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 /*<<< orphan*/ printf(char *);
int gen_privatekey(int totient, int publickey) {
  unsigned int i = totient + 1;
  unsigned int num;
  do {
    num = (publickey * i) - 1;
    if (!(num % totient))
      return i;
    i++;
  } while (i > totient);
  printf("\nDecryption failed..\n");
}


x86 assembly (clang, -O0):
<gen_privatekey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
xor    %edx,%edx
divl   -0x8(%rbp)
cmp    $0x0,%edx
jne    1150 <gen_privatekey+0x40>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1171 <gen_privatekey+0x61>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
ja     1127 <gen_privatekey+0x17>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_privatekey>:
push   %rbx
lea    0x1(%rdi),%eax
mov    %esi,%ecx
imul   %eax,%ecx
add    $0xffffffff,%ecx
nopl   0x0(%rax)
mov    %eax,%ebx
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
test   %edx,%edx
je     1141 <gen_privatekey+0x31>
lea    0x1(%rbx),%eax
add    %esi,%ecx
cmp    %edi,%eax
ja     1120 <gen_privatekey+0x10>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\0ADecryption failed..\0A\00"
define i32 @gen_privatekey(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %4
%9 = add nsw i32 %8, 1
store i32 %9, i32* %6
br label %10
10: ; preds = %24, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = mul i32 %11, %12
%14 = sub i32 %13, 1
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = urem i32 %15, %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %10
%20 = load i32, i32* %6
store i32 %20, i32* %3
br label %30
21: ; preds = %10
%22 = load i32, i32* %6
%23 = add i32 %22, 1
store i32 %23, i32* %6
br label %24
24: ; preds = %21
%25 = load i32, i32* %6
%26 = load i32, i32* %4
%27 = icmp ugt i32 %25, %26
br i1 %27, label %10, label %28
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %19
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@str = [21 x i8] c"\0ADecryption failed..\00"
define i32 @gen_privatekey(i32 %0, i32 %1) {
%3 = add nsw i32 %0, 1
br label %4
4: ; preds = %10, %2
%5 = phi i32 [ %3, %2 ], [ %11, %10 ]
%6 = mul i32 %5, %1
%7 = add i32 %6, -1
%8 = urem i32 %7, %0
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = add i32 %5, 1
%12 = icmp ugt i32 %11, %0
br i1 %12, label %4, label %13
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %4, %13
ret i32 %5
}