#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*/ eea(int, int, int *, int *, int *);
char decrypt(char ciphertext, int a, int b) {
  int gcd, x, y;
  char plaintext = 0;
  int aInv = 0;
  int offset = 97;
  if (ciphertext < 97)
    offset = 65;
  eea(26, a, &gcd, &x, &y);
  if (gcd == 1)
    aInv = (y + 26) % 26;
  plaintext = ((aInv * (ciphertext - offset - b + 26)) % 26) + offset;
  return plaintext;
}


x86 assembly (clang, -O0):
<decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movb   $0x0,-0x19(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x61,-0x24(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x61,%eax
jge    114a <decrypt+0x3a>
movl   $0x41,-0x24(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x1a,%edi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1030 <eea@plt>
cmpl   $0x1,-0x10(%rbp)
jne    117e <decrypt+0x6e>
mov    -0x18(%rbp),%eax
add    $0x1a,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x20(%rbp),%eax
movsbl -0x1(%rbp),%ecx
sub    -0x24(%rbp),%ecx
sub    -0xc(%rbp),%ecx
add    $0x1a,%ecx
imul   %ecx,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    -0x24(%rbp),%edx
mov    %dl,%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %edi,%ebp
lea    0x10(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    $0x1a,%edi
call   1030 <eea@plt>
xor    %eax,%eax
cmpl   $0x1,0x10(%rsp)
jne    1163 <decrypt+0x53>
mov    0xc(%rsp),%eax
add    $0x1a,%eax
cltq
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
xor    %edx,%edx
xor    %ecx,%ecx
cmp    $0x61,%bpl
setl   %dl
setge  %cl
shl    $0x5,%ecx
shl    $0x5,%edx
movsbl %bpl,%esi
sub    %ebx,%esi
add    %esi,%edx
add    $0xffffffb9,%edx
imul   %eax,%edx
movslq %edx,%rax
imul   $0x4ec4ec4f,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x23,%rdx
add    %esi,%edx
lea    (%rdx,%rdx,4),%esi
lea    (%rsi,%rsi,4),%esi
add    %edx,%esi
sub    %esi,%eax
add    %ecx,%eax
add    $0x41,%al
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @decrypt(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i32
%12 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8 0, i8* %10
store i32 0, i32* %11
store i32 97, i32* %12
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp slt i32 %14, 97
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 65, i32* %12
br label %17
17: ; preds = %16, %3
%18 = load i32, i32* %5
%19 = call i32 @eea(i32 26, i32 %18, i32* %7, i32* %8, i32* %9)
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i32, i32* %9
%24 = add nsw i32 %23, 26
%25 = srem i32 %24, 26
store i32 %25, i32* %11
br label %26
26: ; preds = %22, %17
%27 = load i32, i32* %11
%28 = load i8, i8* %4
%29 = sext i8 %28 to i32
%30 = load i32, i32* %12
%31 = sub nsw i32 %29, %30
%32 = load i32, i32* %6
%33 = sub nsw i32 %31, %32
%34 = add nsw i32 %33, 26
%35 = mul nsw i32 %27, %34
%36 = srem i32 %35, 26
%37 = load i32, i32* %12
%38 = add nsw i32 %36, %37
%39 = trunc i32 %38 to i8
store i8 %39, i8* %10
%40 = load i8, i8* %10
ret i8 %40
}

LLVM IR (-O2):
define signext i8 @decrypt(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = icmp slt i8 %0, 97
%11 = call i32 @eea(i32 26, i32 %1, i32* %4, i32* %5, i32* %6)
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 26
%17 = srem i32 %16, 26
br label %18
18: ; preds = %14, %3
%19 = phi i32 [ %17, %14 ], [ 0, %3 ]
%20 = select i1 %10, i32 65, i32 97
%21 = select i1 %10, i32 -65, i32 -97
%22 = sext i8 %0 to i32
%23 = add nsw i32 %22, 26
%24 = sub i32 %23, %2
%25 = add i32 %24, %21
%26 = mul nsw i32 %19, %25
%27 = srem i32 %26, 26
%28 = add nsw i32 %27, %20
%29 = trunc i32 %28 to i8
ret i8 %29
}