#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  char sentence[80], key2[5], output1[80], output2[80];
  int key1, j, k;
  printf("This will encrypt your sentence using two methods.\n");
  printf("Please enter your sentence (up to 79 characters): ");
  scanf("%s", sentence);
  printf("A Caesar cipher uses an integer number to scramble letters.\n");
  printf("Please enter an integer number to scrmble the letters with: ");
  scanf("%d", &key1);
  printf("A modified Caesar cipher uses a word to scramble the letters.\n");
  printf("Please input a 4-character word with which the above sentence will "
         "be scrambled: ");
  scanf("%s", key2);
  for (j = 0, k = 0; j < 80 && sentence[j] != '\0'; j++, k = ((k + 1) % 4)) {
    output1[j] = (sentence[j] + key1) % 256;
    output2[j] = (sentence[j] + key2[k]) % 256;
  }
  printf("Your input sentence is %s", sentence);
  printf(" and key1 is %d while key2 is %s.\n", key1, key2);
  printf("The cipher with key1 is %s ", output1);
  printf(" and with key2 is %s.\n", output2);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0x1033(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf5e(%rip),%rdi
lea    -0x114(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x65(%rbp),%rsi
lea    0xfd4(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x118(%rbp)
movl   $0x0,-0x11c(%rbp)
xor    %eax,%eax
cmpl   $0x50,-0x118(%rbp)
mov    %al,-0x11d(%rbp)
jge    1200 <main+0xe0>
movslq -0x118(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11d(%rbp)
mov    -0x11d(%rbp),%al
test   $0x1,%al
jne    1213 <main+0xf3>
jmp    129a <main+0x17a>
movslq -0x118(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
add    -0x114(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
movslq -0x118(%rbp),%rax
mov    %cl,-0xc0(%rbp,%rax,1)
movslq -0x118(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
movslq -0x11c(%rbp),%rcx
movsbl -0x65(%rbp,%rcx,1),%ecx
add    %ecx,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
movslq -0x118(%rbp),%rax
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x11c(%rbp)
jmp    11d3 <main+0xb3>
lea    -0x60(%rbp),%rsi
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x114(%rbp),%esi
lea    -0x65(%rbp),%rdx
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc0(%rbp),%rsi
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ceb(%rip),%rax
mov    (%rax),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0xff4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf7f(%rip),%r14
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xff5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee3(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0x1004(%rip),%rdi
call   1030 <puts@plt>
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xb(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%al
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movzbl 0x10(%rsp,%rbx,1),%edx
test   %dl,%dl
je     120e <main+0xde>
lea    (%rdx,%rax,1),%esi
movslq %ecx,%rcx
add    0xb(%rsp,%rcx,1),%dl
mov    %sil,0xb0(%rsp,%rbx,1)
mov    %dl,0x60(%rsp,%rbx,1)
add    $0x1,%rbx
lea    0x1(%rcx),%edx
lea    0x4(%rcx),%esi
test   %edx,%edx
cmovns %edx,%esi
and    $0xfffffffc,%esi
neg    %esi
add    %esi,%ecx
add    $0x1,%ecx
cmp    $0x50,%rbx
jne    11d0 <main+0xa0>
lea    0xeb0(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xeb3(%rip),%rdi
lea    0xb(%rsp),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0xb0(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
lea    0x60(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [52 x i8] c"This will encrypt your sentence using two methods.\0A\00"
@.str.1 = [51 x i8] c"Please enter your sentence (up to 79 characters): \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [61 x i8] c"A Caesar cipher uses an integer number to scramble letters.\0A\00"
@.str.4 = [61 x i8] c"Please enter an integer number to scrmble the letters with: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [63 x i8] c"A modified Caesar cipher uses a word to scramble the letters.\0A\00"
@.str.7 = [82 x i8] c"Please input a 4-character word with which the above sentence will be scrambled: \00"
@.str.8 = [26 x i8] c"Your input sentence is %s\00"
@.str.9 = [35 x i8] c" and key1 is %d while key2 is %s.\0A\00"
@.str.10 = [28 x i8] c"The cipher with key1 is %s \00"
@.str.11 = [23 x i8] c" and with key2 is %s.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [5 x i8]
%4 = alloca [80 x i8]
%5 = alloca [80 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %6)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.7, i64 0, i64 0))
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %18)
store i32 0, i32* %7
store i32 0, i32* %8
br label %20
20: ; preds = %61, %0
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 80
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br label %30
30: ; preds = %23, %20
%31 = phi i1 [ false, %20 ], [ %29, %23 ]
br i1 %31, label %32, label %67
32: ; preds = %30
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = load i32, i32* %6
%39 = add nsw i32 %37, %38
%40 = srem i32 %39, 256
%41 = trunc i32 %40 to i8
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %43
store i8 %41, i8* %44
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = add nsw i32 %49, %54
%56 = srem i32 %55, 256
%57 = trunc i32 %56 to i8
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %59
store i8 %57, i8* %60
br label %61
61: ; preds = %32
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
%66 = srem i32 %65, 4
store i32 %66, i32* %8
br label %20
67: ; preds = %30
%68 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %68)
%70 = load i32, i32* %6
%71 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %70, i8* %71)
%73 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i8* %73)
%75 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %75)
%77 = load i32, i32* @EXIT_SUCCESS
ret i32 %77
}

LLVM IR (-O2):
@.str.1 = [51 x i8] c"Please enter your sentence (up to 79 characters): \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.4 = [61 x i8] c"Please enter an integer number to scrmble the letters with: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.7 = [82 x i8] c"Please input a 4-character word with which the above sentence will be scrambled: \00"
@.str.8 = [26 x i8] c"Your input sentence is %s\00"
@.str.9 = [35 x i8] c" and key1 is %d while key2 is %s.\0A\00"
@.str.10 = [28 x i8] c"The cipher with key1 is %s \00"
@.str.11 = [23 x i8] c" and with key2 is %s.\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [51 x i8] c"This will encrypt your sentence using two methods.\00"
@str.12 = [60 x i8] c"A Caesar cipher uses an integer number to scramble letters.\00"
@str.13 = [62 x i8] c"A modified Caesar cipher uses a word to scramble the letters.\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [5 x i8]
%3 = alloca [80 x i8]
%4 = alloca [80 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.12, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.13, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%20 = load i32, i32* %5
%21 = trunc i32 %20 to i8
br label %22
22: ; preds = %0, %28
%23 = phi i64 [ 0, %0 ], [ %36, %28 ]
%24 = phi i32 [ 0, %0 ], [ %38, %28 ]
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %23
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %40, label %28
28: ; preds = %22
%29 = add i8 %26, %21
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %23
store i8 %29, i8* %30
%31 = sext i32 %24 to i64
%32 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = add i8 %33, %26
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %23
store i8 %34, i8* %35
%36 = add nuw nsw i64 %23, 1
%37 = add nsw i32 %24, 1
%38 = srem i32 %37, 4
%39 = icmp eq i64 %36, 80
br i1 %39, label %40, label %22
40: ; preds = %28, %22
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %6)
%42 = load i32, i32* %5
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %42, i8* %7)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i8* %8)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %9)
%46 = load i32, i32* @EXIT_SUCCESS
ret i32 %46
}