#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__ malloc(int);
int strlen(char *);
char *rat(char *message) {
  char *cyphertext = (char *)malloc(sizeof(char) * strlen(message));
  int i;
  for (i = 0; i < strlen(message); i++) {
    cyphertext[i] = (isalpha(message[i]))
                        ? (((message[i] + 13 - 'a') % 26) + 'a')
                        : message[i];
  }
  return cyphertext;
}


x86 assembly (clang, -O0):
<rat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11e8 <rat+0xb8>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     11bb <rat+0x8b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xd,%eax
sub    $0x61,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x61,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ca <rat+0x9a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <rat+0x2d>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rat>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11b3 <rat+0x83>
xor    %ebx,%ebx
jmp    1177 <rat+0x47>
nopw   0x0(%rax,%rax,1)
mov    %cl,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11b3 <rat+0x83>
movsbl (%r15,%rbx,1),%edi
call   1050 <isalpha@plt>
movzbl (%r15,%rbx,1),%ecx
test   %rax,%rax
je     1160 <rat+0x30>
movsbl %cl,%eax
movswl %ax,%ecx
add    $0xffffffac,%ecx
imul   $0x4ec5,%ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
shr    $0x13,%eax
add    %edx,%eax
lea    (%rax,%rax,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %eax,%edx
sub    %edx,%ecx
add    $0x61,%cl
jmp    1160 <rat+0x30>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @rat(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = sext i32 %6 to i64
%8 = mul i64 1, %7
%9 = trunc i64 %8 to i32
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %3
store i32 0, i32* %4
br label %12
12: ; preds = %50, %1
%13 = load i32, i32* %4
%14 = load i8*, i8** %2
%15 = call i32 @strlen(i8* %14)
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %53
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = call i64 @isalpha(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %36
25: ; preds = %17
%26 = load i8*, i8** %2
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = add nsw i32 %31, 13
%33 = sub nsw i32 %32, 97
%34 = srem i32 %33, 26
%35 = add nsw i32 %34, 97
br label %43
36: ; preds = %17
%37 = load i8*, i8** %2
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
br label %43
43: ; preds = %36, %25
%44 = phi i32 [ %35, %25 ], [ %42, %36 ]
%45 = trunc i32 %44 to i8
%46 = load i8*, i8** %3
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8 %45, i8* %49
br label %50
50: ; preds = %43
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %12
53: ; preds = %12
%54 = load i8*, i8** %3
ret i8* %54
}

LLVM IR (-O2):
define i8* @rat(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i64 @malloc(i32 %2)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %27
7: ; preds = %1, %20
%8 = phi i64 [ %23, %20 ], [ 0, %1 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = tail call i64 @isalpha(i8 signext %10)
%12 = icmp eq i64 %11, 0
%13 = load i8, i8* %9
br i1 %12, label %20, label %14
14: ; preds = %7
%15 = sext i8 %13 to i16
%16 = add nsw i16 %15, -84
%17 = srem i16 %16, 26
%18 = trunc i16 %17 to i8
%19 = add nsw i8 %18, 97
br label %20
20: ; preds = %7, %14
%21 = phi i8 [ %19, %14 ], [ %13, %7 ]
%22 = getelementptr inbounds i8, i8* %4, i64 %8
store i8 %21, i8* %22
%23 = add nuw nsw i64 %8, 1
%24 = tail call i32 @strlen(i8* %0)
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %7, label %27
27: ; preds = %20, %1
ret i8* %4
}