#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 *, ...);
void shift(const char *p, int i) {
  int ch = *p;
  for (; ch; ch = *++p) {
    if (ch >= 'a' && ch <= 'z')
      ch += 'A' - 'a';
    if (ch >= 'A' && ch <= 'Z')
      printf("%c", 'A' + (ch - 'A' + i) % 26);
    else
      printf("%c", ch);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<shift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11be <shift+0xae>
cmpl   $0x61,-0x10(%rbp)
jl     1150 <shift+0x40>
cmpl   $0x7a,-0x10(%rbp)
jg     1150 <shift+0x40>
mov    -0x10(%rbp),%eax
add    $0xffffffe0,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x41,-0x10(%rbp)
jl     118d <shift+0x7d>
cmpl   $0x5a,-0x10(%rbp)
jg     118d <shift+0x7d>
mov    -0x10(%rbp),%eax
sub    $0x41,%eax
add    -0xc(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x41,%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <shift+0x8e>
mov    -0x10(%rbp),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a3 <shift+0x93>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1129 <shift+0x19>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     117f <shift+0x6f>
mov    %esi,%ebp
mov    %rdi,%rbx
add    $0x1,%rbx
jmp    1140 <shift+0x30>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     117f <shift+0x6f>
movsbl %al,%eax
lea    -0x61(%rax),%ecx
lea    -0x20(%rax),%edi
cmp    $0x1a,%cl
cmovae %eax,%edi
lea    -0x41(%rdi),%eax
cmp    $0x19,%eax
ja     1130 <shift+0x20>
add    %ebp,%eax
movslq %eax,%rdi
imul   $0x4ec4ec4f,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%edi
add    $0x41,%edi
jmp    1130 <shift+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @shift(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
store i32 %8, i32* %5
br label %9
9: ; preds = %39, %2
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %44
12: ; preds = %9
%13 = load i32, i32* %5
%14 = icmp sge i32 %13, 97
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i32, i32* %5
%17 = icmp sle i32 %16, 122
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %5
%20 = add nsw i32 %19, -32
store i32 %20, i32* %5
br label %21
21: ; preds = %18, %15, %12
%22 = load i32, i32* %5
%23 = icmp sge i32 %22, 65
br i1 %23, label %24, label %35
24: ; preds = %21
%25 = load i32, i32* %5
%26 = icmp sle i32 %25, 90
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load i32, i32* %5
%29 = sub nsw i32 %28, 65
%30 = load i32, i32* %4
%31 = add nsw i32 %29, %30
%32 = srem i32 %31, 26
%33 = add nsw i32 65, %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %38
35: ; preds = %24, %21
%36 = load i32, i32* %5
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %27
br label %39
39: ; preds = %38
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %3
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
store i32 %43, i32* %5
br label %9
44: ; preds = %9
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @shift(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %25, label %5
5: ; preds = %2, %19
%6 = phi i8 [ %23, %19 ], [ %3, %2 ]
%7 = phi i8* [ %22, %19 ], [ %0, %2 ]
%8 = sext i8 %6 to i32
%9 = add i8 %6, -97
%10 = icmp ult i8 %9, 26
%11 = add nsw i32 %8, -32
%12 = select i1 %10, i32 %11, i32 %8
%13 = add nsw i32 %12, -65
%14 = icmp ult i32 %13, 26
br i1 %14, label %15, label %19
15: ; preds = %5
%16 = add nsw i32 %13, %1
%17 = srem i32 %16, 26
%18 = add nsw i32 %17, 65
br label %19
19: ; preds = %5, %15
%20 = phi i32 [ %18, %15 ], [ %12, %5 ]
%21 = tail call i32 @putchar(i32 %20)
%22 = getelementptr inbounds i8, i8* %7, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %5
25: ; preds = %19, %2
%26 = tail call i32 @putchar(i32 10)
ret void
}