#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 */
scalar_t__ islower(char);
scalar_t__ isupper(char);
char rotate(int rot, char c) {
  if (islower(c)) {
    return ('a' + (c - 'a' + rot) % 26);
  } else if (isupper(c)) {
    return ('A' + (c - 'A' + rot) % 26);
  } else {
    return c;
  }
}


x86 assembly (clang, -O0):
<rotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     1163 <rotate+0x43>
movsbl -0x9(%rbp),%eax
sub    $0x61,%eax
add    -0x8(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    %dl,%al
mov    %al,-0x1(%rbp)
jmp    119b <rotate+0x7b>
movsbl -0x9(%rbp),%edi
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     1195 <rotate+0x75>
movsbl -0x9(%rbp),%eax
sub    $0x41,%eax
add    -0x8(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    %dl,%al
mov    %al,-0x1(%rbp)
jmp    119b <rotate+0x7b>
mov    -0x9(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotate>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%r14d
mov    %esi,%edi
call   1030 <islower@plt>
test   %rax,%rax
je     1165 <rotate+0x45>
movsbl %bl,%eax
add    %r14d,%eax
add    $0xffffff9f,%eax
movslq %eax,%rbx
imul   $0x4ec4ec4f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%ebx
add    $0x61,%bl
jmp    11a1 <rotate+0x81>
movsbl %bl,%r15d
mov    %r15d,%edi
call   1040 <isupper@plt>
test   %rax,%rax
je     11a1 <rotate+0x81>
lea    (%r14,%r15,1),%eax
add    $0xffffffbf,%eax
movslq %eax,%rbx
imul   $0x4ec4ec4f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%ebx
add    $0x41,%bl
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define signext i8 @rotate(i32 %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i8
store i32 %0, i32* %4
store i8 %1, i8* %5
%6 = load i8, i8* %5
%7 = call i64 @islower(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i8, i8* %5
%11 = sext i8 %10 to i32
%12 = sub nsw i32 %11, 97
%13 = load i32, i32* %4
%14 = add nsw i32 %12, %13
%15 = srem i32 %14, 26
%16 = add nsw i32 97, %15
%17 = trunc i32 %16 to i8
store i8 %17, i8* %3
br label %33
18: ; preds = %2
%19 = load i8, i8* %5
%20 = call i64 @isupper(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i8, i8* %5
%24 = sext i8 %23 to i32
%25 = sub nsw i32 %24, 65
%26 = load i32, i32* %4
%27 = add nsw i32 %25, %26
%28 = srem i32 %27, 26
%29 = add nsw i32 65, %28
%30 = trunc i32 %29 to i8
store i8 %30, i8* %3
br label %33
31: ; preds = %18
%32 = load i8, i8* %5
store i8 %32, i8* %3
br label %33
33: ; preds = %31, %22, %9
%34 = load i8, i8* %3
ret i8 %34
}

LLVM IR (-O2):
define signext i8 @rotate(i32 %0, i8 signext %1) {
%3 = tail call i64 @islower(i8 signext %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = sext i8 %1 to i32
%7 = add i32 %0, -97
%8 = add i32 %7, %6
%9 = srem i32 %8, 26
%10 = trunc i32 %9 to i8
%11 = add nsw i8 %10, 97
br label %22
12: ; preds = %2
%13 = tail call i64 @isupper(i8 signext %1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %12
%16 = sext i8 %1 to i32
%17 = add i32 %0, -65
%18 = add i32 %17, %16
%19 = srem i32 %18, 26
%20 = trunc i32 %19 to i8
%21 = add nsw i8 %20, 65
br label %22
22: ; preds = %12, %15, %5
%23 = phi i8 [ %11, %5 ], [ %21, %15 ], [ %1, %12 ]
ret i8 %23
}