#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 offset) {
  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 + offset) % 26 + 65;
    else
      j--;
  }
  cipher[j] = '\0';
  printf("%s\n", cipher);
  return 0;
}


x86 assembly (clang, -O0):
<pencrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    122b <pencrypt+0xdb>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <isspace@plt>
cmp    $0x0,%eax
jne    1206 <pencrypt+0xb6>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
sub    $0x41,%eax
add    -0xc(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%rax
add    $0x41,%edx
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    120f <pencrypt+0xbf>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1214 <pencrypt+0xc4>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ae <pencrypt+0x5e>
mov    -0x30(%rbp),%rsi
movslq -0x28(%rbp),%rax
movb   $0x0,(%rsi,%rax,1)
lea    0xdc2(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%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    %esi,-0x2c(%rbp)
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%r12d
mov    %eax,%r13d
mov    %rsp,%r15
lea    0xf(%r13),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0x1(%r12),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
xor    %r14d,%r14d
test   %r12d,%r12d
jle    120a <pencrypt+0xba>
mov    -0x2c(%rbp),%r12d
add    $0xffffffbf,%r12d
xor    %ebx,%ebx
jmp    11c1 <pencrypt+0x71>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%r14d
add    $0x1,%rbx
add    $0x1,%r14d
cmp    %rbx,%r13
je     1207 <pencrypt+0xb7>
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    %r12d,%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    0xdea(%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) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %6
%15 = alloca i8, i64 %13
store i64 %13, i64* %7
%16 = load i8*, i8** %3
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
%19 = call i32 @strncpy(i8* %15, i8* %16, i32 %18)
store i32 0, i32* %9
store i32 0, i32* %8
br label %20
20: ; preds = %50, %2
%21 = load i32, i32* %8
%22 = load i32, i32* %5
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %55
24: ; preds = %20
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %15, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @isspace(i8 signext %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %46, label %31
31: ; preds = %24
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %15, i64 %33
%35 = load i8, i8* %34
%36 = call i32 @toupper(i8 signext %35)
%37 = sub nsw i32 %36, 65
%38 = load i32, i32* %4
%39 = add nsw i32 %37, %38
%40 = srem i32 %39, 26
%41 = add nsw i32 %40, 65
%42 = trunc i32 %41 to i8
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %15, i64 %44
store i8 %42, i8* %45
br label %49
46: ; preds = %24
%47 = load i32, i32* %9
%48 = add nsw i32 %47, -1
store i32 %48, i32* %9
br label %49
49: ; preds = %46, %31
br label %50
50: ; preds = %49
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %20
55: ; preds = %20
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %15, i64 %57
store i8 0, i8* %58
%59 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
%60 = load i8*, i8** %6
ret i32 0
}

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