#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__ isalpha(char);
scalar_t__ islower(char);
char rot13_char(char c) {
  if (isalpha(c)) {
    char alpha = islower(c) ? 'a' : 'A';
    return (c - alpha + 13) % 26 + alpha;
  }
  return c;
}


x86 assembly (clang, -O0):
<rot13_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     1186 <rot13_char+0x66>
movsbl -0x2(%rbp),%edi
call   1030 <islower@plt>
mov    %rax,%rdx
mov    $0x41,%eax
mov    $0x61,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %al,-0x3(%rbp)
movsbl -0x2(%rbp),%eax
movsbl -0x3(%rbp),%ecx
sub    %ecx,%eax
add    $0xd,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
movsbl -0x3(%rbp),%eax
add    %eax,%edx
mov    %dl,%al
mov    %al,-0x1(%rbp)
jmp    118c <rot13_char+0x6c>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rot13_char>:
push   %rbx
mov    %edi,%ebx
call   1040 <isalpha@plt>
test   %rax,%rax
je     116c <rot13_char+0x4c>
movsbl %bl,%ebx
mov    %ebx,%edi
call   1030 <islower@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
shl    $0x5,%ecx
lea    0x41(%rcx),%eax
neg    %eax
add    %ebx,%eax
add    $0xd,%eax
imul   $0x4ec5,%eax,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x13,%edx
add    %esi,%edx
lea    (%rdx,%rdx,4),%esi
lea    (%rsi,%rsi,4),%esi
add    %edx,%esi
sub    %esi,%eax
lea    (%rcx,%rax,1),%ebx
add    $0x41,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define signext i8 @rot13_char(i8 signext %0) {
%2 = tail call i64 @isalpha(i8 signext %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = tail call i64 @islower(i8 signext %0)
%6 = icmp eq i64 %5, 0
%7 = sext i8 %0 to i32
%8 = select i1 %6, i32 65, i32 97
%9 = sub nsw i32 %7, %8
%10 = trunc i32 %9 to i16
%11 = add i16 %10, 13
%12 = srem i16 %11, 26
%13 = zext i16 %12 to i32
%14 = add nuw nsw i32 %8, %13
%15 = trunc i32 %14 to i8
br label %16
16: ; preds = %1, %4
%17 = phi i8 [ %15, %4 ], [ %0, %1 ]
ret i8 %17
}