#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 *);
int /*<<< orphan*/ caesar1(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  int i = 0;
  char x;
  char trans[1000];
  printf(
      "For encoding write 'c' and for decoding write 'd' and 'q' for exit\n");
  scanf("%c", &x);
  while (x != 'q') {
    if (x == 'c') {
      scanf("%1000s", trans);
      caesar(trans);
    } else if (x == 'd') {
      caesar1(trans);
    }
    scanf("%c", &x);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x9(%rbp),%rsi
call   1060 <scanf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x71,%eax
je     11e6 <main+0xa6>
movsbl -0x9(%rbp),%eax
cmp    $0x63,%eax
jne    11b3 <main+0x73>
lea    -0x400(%rbp),%rsi
lea    0xeaa(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x400(%rbp),%rdi
call   1040 <caesar@plt>
jmp    11d1 <main+0x91>
movsbl -0x9(%rbp),%eax
cmp    $0x64,%eax
jne    11cc <main+0x8c>
lea    -0x400(%rbp),%rdi
call   1050 <caesar1@plt>
jmp    11d1 <main+0x91>
lea    0xe6c(%rip),%rdi
lea    -0x9(%rbp),%rsi
call   1060 <scanf@plt>
jmp    1175 <main+0x35>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f8,%rsp
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%r14
lea    0xf(%rsp),%r12
lea    0xe96(%rip),%r15
lea    0x10(%rsp),%rbx
jmp    1188 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <caesar1@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
movzbl 0xf(%rsp),%eax
cmp    $0x63,%al
je     11b0 <main+0x70>
cmp    $0x64,%al
je     1180 <main+0x40>
cmp    $0x71,%al
jne    1188 <main+0x48>
jmp    11c5 <main+0x85>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <caesar@plt>
jmp    1188 <main+0x48>
xor    %eax,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [68 x i8] c"For encoding write 'c' and for decoding write 'd' and 'q' for exit\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [7 x i8] c"%1000s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %7
7: ; preds = %28, %0
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 113
br i1 %10, label %11, label %30
11: ; preds = %7
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 99
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%17 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%19 = call i32 @caesar(i8* %18)
br label %28
20: ; preds = %11
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 100
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%26 = call i32 @caesar1(i8* %25)
br label %27
27: ; preds = %24, %20
br label %28
28: ; preds = %27, %15
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %7
30: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [7 x i8] c"%1000s\00"
@str = [67 x i8] c"For encoding write 'c' and for decoding write 'd' and 'q' for exit\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %8, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%7 = load i8, i8* %1
switch i8 %7, label %8 [
i8 113, label %14
i8 99, label %9
i8 100, label %12
]
8: ; preds = %5, %12, %9
br label %5
9: ; preds = %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%11 = call i32 @caesar(i8* %3)
br label %8
12: ; preds = %5
%13 = call i32 @caesar1(i8* %3)
br label %8
14: ; preds = %5
ret i32 0
}