#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 gcd(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int AffineGetKey(int *key1, int *key2) {
  int a, b;
  a = b = 0;
  printf("Key 1 > ");
  scanf("%d", &a);
  while (gcd(a, 26) != 1) {
    printf("NOT relatively prime!Try again..\n> ");
    scanf("%d", &a);
  }
  printf("Key 2 > ");
  scanf("%d", &b);
  *key1 = a;
  *key2 = b % 26;
  return 0;
}


x86 assembly (clang, -O0):
<AffineGetKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%edi
mov    $0x1a,%esi
call   1050 <gcd@plt>
cmp    $0x1,%eax
je     11a1 <AffineGetKey+0x71>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
jmp    116a <AffineGetKey+0x3a>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
mov    %edx,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AffineGetKey>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
lea    0xea3(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%edi
mov    $0x1a,%esi
call   1050 <gcd@plt>
cmp    $0x1,%eax
je     11c6 <AffineGetKey+0x96>
lea    0xe82(%rip),%r12
lea    0xe78(%rip),%r13
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%edi
mov    $0x1a,%esi
call   1050 <gcd@plt>
cmp    $0x1,%eax
jne    11a0 <AffineGetKey+0x70>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
lea    0xe30(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
mov    %eax,(%r15)
movslq 0xc(%rsp),%rax
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Key 1 > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"NOT relatively prime!Try again..\0A> \00"
@.str.3 = [9 x i8] c"Key 2 > \00"
define i32 @AffineGetKey(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %6
store i32 0, i32* %5
%7 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
br label %9
9: ; preds = %13, %2
%10 = load i32, i32* %5
%11 = call i32 @gcd(i32 %10, i32 26)
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
br label %9
16: ; preds = %9
%17 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%19 = load i32, i32* %5
%20 = load i32*, i32** %3
store i32 %19, i32* %20
%21 = load i32, i32* %6
%22 = srem i32 %21, 26
%23 = load i32*, i32** %4
store i32 %22, i32* %23
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"Key 1 > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"NOT relatively prime!Try again..\0A> \00"
@.str.3 = [9 x i8] c"Key 2 > \00"
define i32 @AffineGetKey(i32* nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
store i32 0, i32* %3
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = call i32 @gcd(i32 %9, i32 26)
%11 = icmp eq i32 %10, 1
br i1 %11, label %18, label %12
12: ; preds = %2, %12
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = call i32 @gcd(i32 %15, i32 26)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %12
18: ; preds = %12, %2
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%21 = load i32, i32* %3
store i32 %21, i32* %0
%22 = load i32, i32* %4
%23 = srem i32 %22, 26
store i32 %23, i32* %1
ret i32 0
}