#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*/ caesar(char *, char *, int, int);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  do {
    char intext[32], outtext[32] = {'\0'};
    int key;
    char crypt;
    int crypt_mode = 0;
    printf("\nEnter your plaintext/ciphertext: ");
    scanf("%s", intext);
    getchar();
    printf("Encrypt or Decrypt (e/d)? ");
    crypt = getchar();
    if (crypt == 'e') {
      crypt_mode = 1;
    } else {
      crypt_mode = 0;
    }
    printf("Enter a cipher key (0-25): ");
    scanf("%d", &key);
    getchar();
    caesar(intext, outtext, key, crypt_mode);
    printf("The ciphertext is: %s \n", outtext);
    printf("Use again (y/n)? ");
  } while (getchar() != 'n');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
movl   $0x0,-0x5c(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x55(%rbp)
movsbl -0x55(%rbp),%eax
cmp    $0x65,%eax
jne    11ce <main+0x7e>
movl   $0x1,-0x5c(%rbp)
jmp    11d5 <main+0x85>
movl   $0x0,-0x5c(%rbp)
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe73(%rip),%rdi
lea    -0x54(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
mov    -0x5c(%rbp),%ecx
call   1050 <caesar@plt>
lea    -0x50(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
movsbl %al,%eax
cmp    $0x6e,%eax
jne    115f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0x30(%rsp),%rbx
lea    0xc(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xefc(%rip),%r12
lea    0xf0d(%rip),%r13
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe91(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %ebp,%ebp
cmp    $0x65,%al
sete   %bpl
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe88(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%ecx
call   1040 <caesar@plt>
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x6e,%al
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0AEnter your plaintext/ciphertext: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [27 x i8] c"Encrypt or Decrypt (e/d)? \00"
@.str.3 = [28 x i8] c"Enter a cipher key (0-25): \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [24 x i8] c"The ciphertext is: %s \0A\00"
@.str.6 = [18 x i8] c"Use again (y/n)? \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = alloca [32 x i8]
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i32 0, i32* %1
br label %7
7: ; preds = %32, %0
%8 = bitcast [32 x i8]* %3 to i8*
store i32 0, i32* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call signext i8 (...) @getchar()
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%14 = call signext i8 (...) @getchar()
store i8 %14, i8* %5
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 101
br i1 %17, label %18, label %19
18: ; preds = %7
store i32 1, i32* %6
br label %20
19: ; preds = %7
store i32 0, i32* %6
br label %20
20: ; preds = %19, %18
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%23 = call signext i8 (...) @getchar()
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%26 = load i32, i32* %4
%27 = load i32, i32* %6
%28 = call i32 @caesar(i8* %24, i8* %25, i32 %26, i32 %27)
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %20
%33 = call signext i8 (...) @getchar()
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 110
br i1 %35, label %7, label %36
36: ; preds = %32
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [35 x i8] c"\0AEnter your plaintext/ciphertext: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [27 x i8] c"Encrypt or Decrypt (e/d)? \00"
@.str.3 = [28 x i8] c"Enter a cipher key (0-25): \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [24 x i8] c"The ciphertext is: %s \0A\00"
@.str.6 = [18 x i8] c"Use again (y/n)? \00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = alloca [32 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %7, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%10 = call signext i8 (...) @getchar()
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%12 = call signext i8 (...) @getchar()
%13 = icmp eq i8 %12, 101
%14 = zext i1 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%17 = call signext i8 (...) @getchar()
%18 = load i32, i32* %3
%19 = call i32 @caesar(i8* %4, i8* %5, i32 %18, i32 %14)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %5)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%22 = call signext i8 (...) @getchar()
%23 = icmp eq i8 %22, 110
br i1 %23, label %24, label %7
24: ; preds = %7
ret i32 0
}