#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
long parseShiftValue(char const *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ shiftAndPrint(long, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char const *, char *);
void encryptDecrypt(const char *mode, const char *shiftAmt,
                    const char *message) {
  long key = parseShiftValue(shiftAmt);
  if (key > 25 || key < 1) {
    fprintf(stderr, "Error: The shift value should be in the range [1, 25]\n");
    exit(EXIT_FAILURE);
  }
  if (!strcmp(mode, "-d"))
    key -= 2 * key;
  shiftAndPrint(key, message);
  printf("\n");
}


x86 assembly (clang, -O0):
<encryptDecrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <parseShiftValue@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x19,-0x20(%rbp)
jg     1197 <encryptDecrypt+0x37>
cmpq   $0x1,-0x20(%rbp)
jge    11ba <encryptDecrypt+0x5a>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11e6 <encryptDecrypt+0x86>
mov    -0x20(%rbp),%rcx
shl    $0x1,%rcx
mov    -0x20(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <shiftAndPrint@plt>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encryptDecrypt>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <parseShiftValue@plt>
mov    %rax,%rbx
add    $0xffffffffffffffe6,%rax
cmp    $0xffffffffffffffe6,%rax
jbe    11b2 <encryptDecrypt+0x52>
lea    0xeb0(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
mov    %rbx,%rdi
neg    %rdi
test   %eax,%eax
cmovne %rbx,%rdi
mov    %r14,%rsi
call   1070 <shiftAndPrint@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [55 x i8] c"Error: The shift value should be in the range [1, 25]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @encryptDecrypt(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %5
%9 = call i64 @parseShiftValue(i8* %8)
store i64 %9, i64* %7
%10 = load i64, i64* %7
%11 = icmp sgt i64 %10, 25
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i64, i64* %7
%14 = icmp slt i64 %13, 1
br i1 %14, label %15, label %20
15: ; preds = %12, %3
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %12
%21 = load i8*, i8** %4
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %20
%25 = load i64, i64* %7
%26 = mul nsw i64 2, %25
%27 = load i64, i64* %7
%28 = sub nsw i64 %27, %26
store i64 %28, i64* %7
br label %29
29: ; preds = %24, %20
%30 = load i64, i64* %7
%31 = load i8*, i8** %6
%32 = call i32 @shiftAndPrint(i64 %30, i8* %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [55 x i8] c"Error: The shift value should be in the range [1, 25]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"-d\00"
define void @encryptDecrypt(i8* nocapture %0, i8* %1, i8* %2) {
%4 = tail call i64 @parseShiftValue(i8* %1)
%5 = add i64 %4, -26
%6 = icmp ult i64 %5, -25
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %3
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
%15 = sub nsw i64 0, %4
%16 = select i1 %14, i64 %15, i64 %4
%17 = tail call i32 @shiftAndPrint(i64 %16, i8* %2)
%18 = tail call i32 @putchar(i32 10)
ret void
}