#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*/ isspace(char);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int toupper(char);
int pencrypt(const char *plain, int alpha, int beta) {
  int length = strlen(plain);
  char cipher[length];
  strncpy(cipher, plain, length + 1);
  int i, j;
  for (i = j = 0; i < length; i++, j++) {
    if (!isspace(cipher[i]))
      cipher[j] = ((toupper(cipher[i]) - 65 + beta) * alpha) % 26 + 65;
    else
      j--;
  }
  cipher[j] = '\0';
  printf("%s\n", cipher);
  return 0;
}


x86 assembly (clang, -O0):
<pencrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1232 <pencrypt+0xe2>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <isspace@plt>
cmp    $0x0,%eax
jne    120d <pencrypt+0xbd>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
sub    $0x41,%eax
add    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    -0x38(%rbp),%rax
add    $0x41,%edx
movslq -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1216 <pencrypt+0xc6>
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    121b <pencrypt+0xcb>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11b1 <pencrypt+0x61>
mov    -0x38(%rbp),%rsi
movslq -0x30(%rbp),%rax
movb   $0x0,(%rsi,%rax,1)
lea    0xdbb(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pencrypt>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,-0x2c(%rbp)
mov    %esi,-0x30(%rbp)
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%r13d
mov    %eax,%r12d
mov    %rsp,%r15
lea    0xf(%r12),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0x1(%r13),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
xor    %r14d,%r14d
test   %r13d,%r13d
jle    120e <pencrypt+0xbe>
mov    -0x2c(%rbp),%r13d
add    $0xffffffbf,%r13d
xor    %ebx,%ebx
jmp    11c1 <pencrypt+0x71>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%r14d
add    $0x1,%rbx
add    $0x1,%r14d
cmp    %rbx,%r12
je     120b <pencrypt+0xbb>
movsbl (%r15,%rbx,1),%edi
call   1070 <isspace@plt>
test   %eax,%eax
jne    11b0 <pencrypt+0x60>
movsbl (%r15,%rbx,1),%edi
call   1040 <toupper@plt>
add    %r13d,%eax
imul   -0x30(%rbp),%eax
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
movslq %r14d,%rcx
mov    %al,(%r15,%rcx,1)
jmp    11b4 <pencrypt+0x64>
movslq %r14d,%r14
movb   $0x0,(%r15,%r14,1)
lea    0xde6(%rip),%rdi
mov    %r15,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @pencrypt(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %8
%17 = alloca i8, i64 %15
store i64 %15, i64* %9
%18 = load i8*, i8** %4
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
%21 = call i32 @strncpy(i8* %17, i8* %18, i32 %20)
store i32 0, i32* %11
store i32 0, i32* %10
br label %22
22: ; preds = %54, %3
%23 = load i32, i32* %10
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %59
26: ; preds = %22
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %17, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @isspace(i8 signext %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %50, label %33
33: ; preds = %26
%34 = load i32, i32* %10
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %17, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @toupper(i8 signext %37)
%39 = sub nsw i32 %38, 65
%40 = load i32, i32* %6
%41 = add nsw i32 %39, %40
%42 = load i32, i32* %5
%43 = mul nsw i32 %41, %42
%44 = srem i32 %43, 26
%45 = add nsw i32 %44, 65
%46 = trunc i32 %45 to i8
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %17, i64 %48
store i8 %46, i8* %49
br label %53
50: ; preds = %26
%51 = load i32, i32* %11
%52 = add nsw i32 %51, -1
store i32 %52, i32* %11
br label %53
53: ; preds = %50, %33
br label %54
54: ; preds = %53
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
%57 = load i32, i32* %11
%58 = add nsw i32 %57, 1
store i32 %58, i32* %11
br label %22
59: ; preds = %22
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %17, i64 %61
store i8 0, i8* %62
%63 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
%64 = load i8*, i8** %8
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @pencrypt(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = add nsw i32 %4, 1
%8 = call i32 @strncpy(i8* %6, i8* %0, i32 %7)
%9 = icmp sgt i32 %4, 0
br i1 %9, label %10, label %38
10: ; preds = %3
%11 = add i32 %2, -65
br label %12
12: ; preds = %10, %31
%13 = phi i64 [ 0, %10 ], [ %33, %31 ]
%14 = phi i32 [ 0, %10 ], [ %34, %31 ]
%15 = getelementptr inbounds i8, i8* %6, i64 %13
%16 = load i8, i8* %15
%17 = call i32 @isspace(i8 signext %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %12
%20 = load i8, i8* %15
%21 = call i32 @toupper(i8 signext %20)
%22 = add i32 %11, %21
%23 = mul nsw i32 %22, %1
%24 = srem i32 %23, 26
%25 = trunc i32 %24 to i8
%26 = add nsw i8 %25, 65
%27 = sext i32 %14 to i64
%28 = getelementptr inbounds i8, i8* %6, i64 %27
store i8 %26, i8* %28
br label %31
29: ; preds = %12
%30 = add nsw i32 %14, -1
br label %31
31: ; preds = %19, %29
%32 = phi i32 [ %30, %29 ], [ %14, %19 ]
%33 = add nuw nsw i64 %13, 1
%34 = add nsw i32 %32, 1
%35 = icmp eq i64 %33, %5
br i1 %35, label %36, label %12
36: ; preds = %31
%37 = sext i32 %34 to i64
br label %38
38: ; preds = %36, %3
%39 = phi i64 [ 0, %3 ], [ %37, %36 ]
%40 = getelementptr inbounds i8, i8* %6, i64 %39
store i8 0, i8* %40
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
ret i32 0
}