#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*/ printf(char *, char *);
char rotate_by(char, char);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int sum(char *, size_t);
int main() {
  char buffer[15001];
  scanf("%s", buffer);
  size_t len = strlen(buffer) >> 1;
  int a = sum(buffer, len), b = sum(buffer + len, len);
  for (int i = 0; i < len; i++) {
    buffer[i] = rotate_by(buffer[i], a);
    buffer[i + len] = rotate_by(buffer[i + len], b);
  }
  for (int i = 0; i < len; i++)
    buffer[i] = rotate_by(buffer[i], buffer[i + len] - 'A');
  buffer[len] = '\0';
  printf("%s\n", buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3ac0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3aa0(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x3aa0(%rbp),%rdi
call   1030 <strlen@plt>
sar    $0x1,%eax
cltq
mov    %rax,-0x3aa8(%rbp)
lea    -0x3aa0(%rbp),%rdi
mov    -0x3aa8(%rbp),%rsi
call   1050 <sum@plt>
mov    %eax,-0x3aac(%rbp)
lea    -0x3aa0(%rbp),%rdi
add    -0x3aa8(%rbp),%rdi
mov    -0x3aa8(%rbp),%rsi
call   1050 <sum@plt>
mov    %eax,-0x3ab0(%rbp)
movl   $0x0,-0x3ab4(%rbp)
movslq -0x3ab4(%rbp),%rax
cmp    -0x3aa8(%rbp),%rax
jae    1264 <main+0x114>
movslq -0x3ab4(%rbp),%rax
mov    -0x3aa0(%rbp,%rax,1),%cl
mov    -0x3aac(%rbp),%eax
movsbl %cl,%edi
movsbl %al,%esi
call   1070 <rotate_by@plt>
mov    %al,%cl
movslq -0x3ab4(%rbp),%rax
mov    %cl,-0x3aa0(%rbp,%rax,1)
movslq -0x3ab4(%rbp),%rax
add    -0x3aa8(%rbp),%rax
mov    -0x3aa0(%rbp,%rax,1),%cl
mov    -0x3ab0(%rbp),%eax
movsbl %cl,%edi
movsbl %al,%esi
call   1070 <rotate_by@plt>
mov    %al,%cl
movslq -0x3ab4(%rbp),%rax
add    -0x3aa8(%rbp),%rax
mov    %cl,-0x3aa0(%rbp,%rax,1)
mov    -0x3ab4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3ab4(%rbp)
jmp    11d0 <main+0x80>
movl   $0x0,-0x3ab8(%rbp)
movslq -0x3ab8(%rbp),%rax
cmp    -0x3aa8(%rbp),%rax
jae    12d8 <main+0x188>
movslq -0x3ab8(%rbp),%rax
mov    -0x3aa0(%rbp,%rax,1),%cl
movslq -0x3ab8(%rbp),%rax
add    -0x3aa8(%rbp),%rax
movsbl -0x3aa0(%rbp,%rax,1),%eax
ff
sub    $0x41,%eax
movsbl %cl,%edi
movsbl %al,%esi
call   1070 <rotate_by@plt>
mov    %al,%cl
movslq -0x3ab8(%rbp),%rax
mov    %cl,-0x3aa0(%rbp,%rax,1)
mov    -0x3ab8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3ab8(%rbp)
jmp    126e <main+0x11e>
mov    -0x3aa8(%rbp),%rax
movb   $0x0,-0x3aa0(%rbp,%rax,1)
lea    -0x3aa0(%rbp),%rsi
lea    0xd0e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x3ac0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3ab8,%rsp
lea    0xe98(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
sar    %eax
movslq %eax,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <sum@plt>
mov    %eax,%r12d
lea    (%rsp,%r14,1),%rbx
add    $0x10,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <sum@plt>
cmp    $0x2,%ebp
jb     1240 <main+0xf0>
mov    %ebp,0xc(%rsp)
cmp    $0x2,%r14
mov    $0x1,%r13d
cmovae %r14,%r13
xor    %r15d,%r15d
movsbl %r12b,%r12d
movsbl %al,%ebp
nopw   0x0(%rax,%rax,1)
movsbl 0x10(%rsp,%r15,1),%edi
mov    %r12d,%esi
call   1070 <rotate_by@plt>
mov    %al,0x10(%rsp,%r15,1)
movsbl (%rbx,%r15,1),%edi
mov    %ebp,%esi
call   1070 <rotate_by@plt>
mov    %al,(%rbx,%r15,1)
add    $0x1,%r15
cmp    %r15,%r13
jne    11d0 <main+0x80>
cmpl   $0x2,0xc(%rsp)
jb     1240 <main+0xf0>
cmp    $0x2,%r14
mov    $0x1,%r15d
cmovae %r14,%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0x10(%rsp,%rbp,1),%edi
movzbl (%rbx,%rbp,1),%eax
add    $0xbf,%al
movsbl %al,%esi
call   1070 <rotate_by@plt>
mov    %al,0x10(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1220 <main+0xd0>
movb   $0x0,(%rbx)
lea    0xdb9(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x3ab8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15001 x i8]
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = ashr i32 %11, 1
%13 = sext i32 %12 to i64
store i64 %13, i64* %3
%14 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 0
%15 = load i64, i64* %3
%16 = call i32 @sum(i8* %14, i64 %15)
store i32 %16, i32* %4
%17 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 0
%18 = load i64, i64* %3
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i64, i64* %3
%21 = call i32 @sum(i8* %19, i64 %20)
store i32 %21, i32* %5
store i32 0, i32* %6
br label %22
22: ; preds = %52, %0
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = load i64, i64* %3
%26 = icmp ult i64 %24, %25
br i1 %26, label %27, label %55
27: ; preds = %22
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = load i32, i32* %4
%33 = trunc i32 %32 to i8
%34 = call signext i8 @rotate_by(i8 signext %31, i8 signext %33)
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 %36
store i8 %34, i8* %37
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = load i64, i64* %3
%41 = add i64 %39, %40
%42 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = load i32, i32* %5
%45 = trunc i32 %44 to i8
%46 = call signext i8 @rotate_by(i8 signext %43, i8 signext %45)
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = load i64, i64* %3
%50 = add i64 %48, %49
%51 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 %50
store i8 %46, i8* %51
br label %52
52: ; preds = %27
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %22
55: ; preds = %22
store i32 0, i32* %7
br label %56
56: ; preds = %79, %55
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = load i64, i64* %3
%60 = icmp ult i64 %58, %59
br i1 %60, label %61, label %82
61: ; preds = %56
%62 = load i32, i32* %7
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = load i64, i64* %3
%69 = add i64 %67, %68
%70 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = sub nsw i32 %72, 65
%74 = trunc i32 %73 to i8
%75 = call signext i8 @rotate_by(i8 signext %65, i8 signext %74)
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 %77
store i8 %75, i8* %78
br label %79
79: ; preds = %61
%80 = load i32, i32* %7
%81 = add nsw i32 %80, 1
store i32 %81, i32* %7
br label %56
82: ; preds = %56
%83 = load i64, i64* %3
%84 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 %83
store i8 0, i8* %84
%85 = getelementptr inbounds [15001 x i8], [15001 x i8]* %2, i64 0, i64 0
%86 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %85)
ret i32 0
}

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