#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 /*<<< orphan*/ printf(char *, ...);
int toascii(char);
char tolower(char);
int main() {
  char s[] = "OTWEWNGWCBPQABIZVQAPMLJGZWTTQVOBQUMAPMIDGZCABEQVBMZLZIXMLAXZQVOQV"
             "LMMXAVWEIVLLIZSNZWABJQZLWNLMTQOPBVIUMLGWCBPAEQNBTGTMNBBPMVMABITIA"
             "KWCTLVBBQUMQBEPQTMQBEIAQVUGBZCAB";
  int A[162], i = 0, j;
  printf("tolower:\n");
  for (i = 0; i < 162; i++) {
    s[i] = tolower(s[i]);
    printf("%c", s[i]);
  }
  printf("\ntoascii\n");
  for (j = 1; j < 26; j++) {
    printf("\nkey = %d:\n", j);
    for (i = 0; i < 162; i++) {
      A[i] = toascii(s[i]) - j;
      if (A[i] < 97) {
        A[i] = A[i] + 26;
      }
      printf("%c", A[i]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x350,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xea0(%rip),%rsi
mov    $0xa3,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x344(%rbp)
lea    0xf28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x344(%rbp)
cmpl   $0xa2,-0x344(%rbp)
jge    11f1 <main+0xb1>
movslq -0x344(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%edi
ff
call   1050 <tolower@plt>
mov    %al,%cl
movslq -0x344(%rbp),%rax
mov    %cl,-0xb0(%rbp,%rax,1)
movslq -0x344(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%esi
ff
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x344(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x344(%rbp)
jmp    118c <main+0x4c>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x348(%rbp)
cmpl   $0x1a,-0x348(%rbp)
jge    12f4 <main+0x1b4>
mov    -0x348(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x344(%rbp)
cmpl   $0xa2,-0x344(%rbp)
jge    12d2 <main+0x192>
movslq -0x344(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%edi
ff
call   1060 <toascii@plt>
mov    %eax,%ecx
sub    -0x348(%rbp),%ecx
movslq -0x344(%rbp),%rax
mov    %ecx,-0x340(%rbp,%rax,4)
movslq -0x344(%rbp),%rax
cmpl   $0x61,-0x340(%rbp,%rax,4)
61
jge    12a2 <main+0x162>
movslq -0x344(%rbp),%rax
mov    -0x340(%rbp,%rax,4),%ecx
add    $0x1a,%ecx
movslq -0x344(%rbp),%rax
mov    %ecx,-0x340(%rbp,%rax,4)
movslq -0x344(%rbp),%rax
mov    -0x340(%rbp,%rax,4),%esi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x344(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x344(%rbp)
jmp    1234 <main+0xf4>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x348(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x348(%rbp)
jmp    1209 <main+0xc9>
mov    -0x4(%rbp),%eax
add    $0x350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xb0,%rsp
lea    0xe8e(%rip),%rsi
mov    %rsp,%rdi
mov    $0xa3,%edx
call   1060 <memcpy@plt>
lea    0xf29(%rip),%rdi
call   1040 <puts@plt>
mov    $0x4f,%edi
call   1070 <tolower@plt>
mov    %al,(%rsp)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%rsp,%rbx,1),%edi
call   1070 <tolower@plt>
mov    %al,(%rsp,%rbx,1)
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0xa2,%rbx
jne    11b0 <main+0x50>
lea    0xee0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
lea    0xeba(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %ebx,%ebx
xchg   %ax,%ax
movsbl (%rsp,%rbx,1),%edi
call   1080 <toascii@plt>
sub    %ebp,%eax
lea    0x1a(%rax),%edi
cmp    $0x61,%eax
cmovge %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0xa2,%rbx
jne    1200 <main+0xa0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x1a,%ebp
jne    11f0 <main+0x90>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.main.s = [163 x i8] c"OTWEWNGWCBPQABIZVQAPMLJGZWTTQVOBQUMAPMIDGZCABEQVBMZLZIXMLAXZQVOQVLMMXAVWEIVLLIZSNZWABJQZLWNLMTQOPBVIUMLGWCBPAEQNBTGTMNBBPMVMABITIAKWCTLVBBQUMQBEPQTMQBEIAQVUGBZCAB\00"
@.str.3 = [12 x i8] c"\0Akey = %d:\0A\00"
@str = [9 x i8] c"tolower:\00"
@str.5 = [9 x i8] c"\0Atoascii\00"
define i32 @main() {
%1 = alloca [163 x i8]
%2 = getelementptr inbounds [163 x i8], [163 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [163 x i8], [163 x i8]* %1, i64 0, i64 0
%5 = tail call signext i8 @tolower(i8 signext 79)
store i8 %5, i8* %4
%6 = sext i8 %5 to i32
%7 = tail call i32 @putchar(i32 %6)
br label %8
8: ; preds = %0, %8
%9 = phi i64 [ 1, %0 ], [ %16, %8 ]
%10 = getelementptr inbounds [163 x i8], [163 x i8]* %1, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = getelementptr inbounds [163 x i8], [163 x i8]* %1, i64 0, i64 %9
%13 = tail call signext i8 @tolower(i8 signext %11)
store i8 %13, i8* %12
%14 = sext i8 %13 to i32
%15 = tail call i32 @putchar(i32 %14)
%16 = add nuw nsw i64 %9, 1
%17 = icmp eq i64 %16, 162
br i1 %17, label %18, label %8
18: ; preds = %8
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %35
%21 = phi i32 [ 1, %18 ], [ %37, %35 ]
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %23
%24 = phi i64 [ 0, %20 ], [ %33, %23 ]
%25 = getelementptr inbounds [163 x i8], [163 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = tail call i32 @toascii(i8 signext %26)
%28 = sub nsw i32 %27, %21
%29 = icmp slt i32 %28, 97
%30 = add nsw i32 %28, 26
%31 = select i1 %29, i32 %30, i32 %28
%32 = tail call i32 @putchar(i32 %31)
%33 = add nuw nsw i64 %24, 1
%34 = icmp eq i64 %33, 162
br i1 %34, label %35, label %23
35: ; preds = %23
%36 = tail call i32 @putchar(i32 10)
%37 = add nuw nsw i32 %21, 1
%38 = icmp eq i32 %37, 26
br i1 %38, label %39, label %20
39: ; preds = %35
ret i32 0
}