#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 */
char GetWrapAround(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void Cipher(char *input, unsigned offset) {
  printf("Before Cipher: ");
  while (*input != '\0') {
    printf("%c", *input);
    unsigned char nextChar = *input + offset;
    if (nextChar > 'Z' && nextChar < 'a') {
      *input = GetWrapAround(nextChar);
    } else if (nextChar > 'z' || nextChar < 'A') {
      *input = GetWrapAround(nextChar);
    } else {
      *input = nextChar;
    }
    input += 1;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<Cipher>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ee <Cipher+0xce>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    -0xc(%rbp),%eax
mov    %al,-0xd(%rbp)
movzbl -0xd(%rbp),%eax
cmp    $0x5a,%eax
jle    119f <Cipher+0x7f>
movzbl -0xd(%rbp),%eax
cmp    $0x61,%eax
jge    119f <Cipher+0x7f>
movzbl -0xd(%rbp),%edi
call   1040 <GetWrapAround@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    11dd <Cipher+0xbd>
movzbl -0xd(%rbp),%eax
cmp    $0x7a,%eax
jg     11b9 <Cipher+0x99>
movzbl -0xd(%rbp),%eax
cmp    $0x41,%eax
jge    11cf <Cipher+0xaf>
movzbl -0xd(%rbp),%edi
call   1040 <GetWrapAround@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    11d8 <Cipher+0xb8>
mov    -0xd(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    11dd <Cipher+0xbd>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113d <Cipher+0x1d>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cipher>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%al
jmp    1162 <Cipher+0x32>
nopw   0x0(%rax,%rax,1)
movzbl %al,%edi
call   1050 <GetWrapAround@plt>
mov    %al,(%rbx)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1186 <Cipher+0x56>
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    %bpl,%al
lea    -0x5b(%rax),%ecx
cmp    $0x6,%cl
jb     1150 <Cipher+0x20>
lea    -0x7b(%rax),%ecx
cmp    $0xc5,%cl
ja     1158 <Cipher+0x28>
jmp    1150 <Cipher+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [16 x i8] c"Before Cipher: \00"
define void @Cipher(i8* nocapture %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %27, label %6
6: ; preds = %2
%7 = trunc i32 %1 to i8
br label %8
8: ; preds = %6, %22
%9 = phi i8 [ %4, %6 ], [ %25, %22 ]
%10 = phi i8* [ %0, %6 ], [ %24, %22 ]
%11 = sext i8 %9 to i32
%12 = tail call i32 @putchar(i32 %11)
%13 = load i8, i8* %10
%14 = add i8 %13, %7
%15 = add i8 %14, -91
%16 = icmp ult i8 %15, 6
%17 = add i8 %14, -123
%18 = icmp ult i8 %17, -58
%19 = or i1 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %8
%21 = tail call signext i8 @GetWrapAround(i8 zeroext %14)
br label %22
22: ; preds = %8, %20
%23 = phi i8 [ %21, %20 ], [ %14, %8 ]
store i8 %23, i8* %10
%24 = getelementptr inbounds i8, i8* %10, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %8
27: ; preds = %22, %2
%28 = tail call i32 @putchar(i32 10)
ret void
}