#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 stringLength(char *);
char toupper(char);
void permAlphaChar(char *str, int key) {
  char alphabet[26] = "abcdefghijklmnopqrstuvwxyz";
  int str_length = stringLength(str);
  for (int i = 0; i < str_length; i++) {
    for (int j = 0; j < 26; j++) {
      if (str[i] == alphabet[j]) {
        str[i] = alphabet[(j + key) % 26];
        break;
      } else if (str[i] == toupper(alphabet[j])) {
        str[i] = toupper(alphabet[(j + key) % 26]);
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<permAlphaChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec1(%rip),%ax
mov    %ax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <stringLength@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1252 <permAlphaChar+0x132>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x1a,-0x3c(%rbp)
jge    123f <permAlphaChar+0x11f>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movslq -0x3c(%rbp),%rcx
movsbl -0x30(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11cd <permAlphaChar+0xad>
mov    -0x3c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x30(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    123f <permAlphaChar+0x11f>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x40(%rbp)
movslq -0x3c(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x40(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
jne    1227 <permAlphaChar+0x107>
mov    -0x3c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    123f <permAlphaChar+0x11f>
jmp    122c <permAlphaChar+0x10c>
jmp    1231 <permAlphaChar+0x111>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1181 <permAlphaChar+0x61>
jmp    1244 <permAlphaChar+0x124>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    116e <permAlphaChar+0x4e>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permAlphaChar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r13
call   1040 <stringLength@plt>
test   %eax,%eax
jle    1203 <permAlphaChar+0xe3>
mov    %eax,%r15d
mov    %r14d,%eax
mov    %rax,(%rsp)
xor    %ebp,%ebp
lea    0xeaf(%rip),%r12
jmp    1199 <permAlphaChar+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    (%rsp),%rbx
movslq %ebx,%rax
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
cltq
mov    (%rax,%r12,1),%al
mov    %al,0x0(%r13,%rbp,1)
add    $0x1,%rbp
cmp    %r15,%rbp
je     1203 <permAlphaChar+0xe3>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%r13,%rbp,1),%r14d
movzbl (%rbx,%r12,1),%eax
cmp    %al,%r14b
je     1160 <permAlphaChar+0x40>
movsbl %al,%edi
call   1030 <toupper@plt>
cmp    %al,%r14b
je     11d0 <permAlphaChar+0xb0>
add    $0x1,%rbx
cmp    $0x1a,%rbx
jne    11a0 <permAlphaChar+0x80>
jmp    1190 <permAlphaChar+0x70>
nopl   0x0(%rax)
add    (%rsp),%rbx
movslq %ebx,%rax
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
cltq
movsbl (%rax,%r12,1),%edi
call   1030 <toupper@plt>
jmp    118b <permAlphaChar+0x6b>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.permAlphaChar.alphabet = [26 x i8] c"abcdefghijklmnopqrstuvwxyz"
define void @permAlphaChar(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [26 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = bitcast [26 x i8]* %5 to i8*
%10 = load i8*, i8** %3
%11 = call i32 @stringLength(i8* %10)
store i32 %11, i32* %6
store i32 0, i32* %7
br label %12
12: ; preds = %78, %2
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %81
16: ; preds = %12
store i32 0, i32* %8
br label %17
17: ; preds = %74, %16
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 26
br i1 %19, label %20, label %77
20: ; preds = %17
%21 = load i8*, i8** %3
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %26, %31
br i1 %32, label %33, label %45
33: ; preds = %20
%34 = load i32, i32* %8
%35 = load i32, i32* %4
%36 = add nsw i32 %34, %35
%37 = srem i32 %36, 26
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = load i8*, i8** %3
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 %40, i8* %44
br label %77
45: ; preds = %20
%46 = load i8*, i8** %3
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = call signext i8 @toupper(i8 signext %55)
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %51, %57
br i1 %58, label %59, label %72
59: ; preds = %45
%60 = load i32, i32* %8
%61 = load i32, i32* %4
%62 = add nsw i32 %60, %61
%63 = srem i32 %62, 26
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = call signext i8 @toupper(i8 signext %66)
%68 = load i8*, i8** %3
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
store i8 %67, i8* %71
br label %77
72: ; preds = %45
br label %73
73: ; preds = %72
br label %74
74: ; preds = %73
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
store i32 %76, i32* %8
br label %17
77: ; preds = %59, %33, %17
br label %78
78: ; preds = %77
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
br label %12
81: ; preds = %12
ret void
}

LLVM IR (-O2):
@__const.permAlphaChar.alphabet = [26 x i8] c"abcdefghijklmnopqrstuvwxyz"
define void @permAlphaChar(i8* %0, i32 %1) {
%3 = tail call i32 @stringLength(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = zext i32 %3 to i64
br label %7
7: ; preds = %5, %40
%8 = phi i64 [ 0, %5 ], [ %41, %40 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
br label %11
10: ; preds = %40, %2
ret void
11: ; preds = %7, %35
%12 = phi i64 [ 0, %7 ], [ %36, %35 ]
%13 = load i8, i8* %9
%14 = getelementptr inbounds [26 x i8], [26 x i8]* @__const.permAlphaChar.alphabet, i64 0, i64 %12
%15 = load i8, i8* %14
%16 = icmp eq i8 %13, %15
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = trunc i64 %12 to i32
%19 = add nsw i32 %18, %1
%20 = srem i32 %19, 26
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [26 x i8], [26 x i8]* @__const.permAlphaChar.alphabet, i64 0, i64 %21
%23 = load i8, i8* %22
br label %38
24: ; preds = %11
%25 = tail call signext i8 @toupper(i8 signext %15)
%26 = icmp eq i8 %13, %25
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = trunc i64 %12 to i32
%29 = add nsw i32 %28, %1
%30 = srem i32 %29, 26
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [26 x i8], [26 x i8]* @__const.permAlphaChar.alphabet, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = tail call signext i8 @toupper(i8 signext %33)
br label %38
35: ; preds = %24
%36 = add nuw nsw i64 %12, 1
%37 = icmp eq i64 %36, 26
br i1 %37, label %40, label %11
38: ; preds = %17, %27
%39 = phi i8 [ %34, %27 ], [ %23, %17 ]
store i8 %39, i8* %9
br label %40
40: ; preds = %35, %38
%41 = add nuw nsw i64 %8, 1
%42 = icmp eq i64 %41, %6
br i1 %42, label %10, label %7
}