#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  char Str[30], encStr[30], decStr[30];
  int i, iKey, iChoice;
  while (1) {
    printf("\nMENU\n=====\n1.Input\n2.Encode\n3.Decode\n4.Exit");
    printf("\nEnter your choice\n");
    scanf("%d", &iChoice);
    getchar();
    switch (iChoice) {
    case 1:
      printf("\nEnter a str\n");
      gets(Str);
      break;
    case 2:
      printf("\nEnter a key\n");
      scanf("%d", &iKey);
      for (i = 0; Str[i] != '\0'; i++) {
        encStr[i] = Str[i] + iKey;
      }
      printf("\nEncoded String :\n");
      puts(encStr);
      break;
    case 3:
      for (i = 0; Str[i] != '\0'; i++) {
        decStr[i] = encStr[i] - iKey;
      }
      decStr[i] = '\0';
      printf("\nDecoded String :\n");
      puts(decStr);
      break;
    default:
      exit(0);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x7c(%rbp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x80(%rbp)
sub    $0x1,%eax
je     11d7 <main+0x77>
jmp    11b5 <main+0x55>
mov    -0x80(%rbp),%eax
sub    $0x2,%eax
je     11f1 <main+0x91>
jmp    11c6 <main+0x66>
mov    -0x80(%rbp),%eax
sub    $0x3,%eax
je     1264 <main+0x104>
jmp    12c4 <main+0x164>
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1060 <gets@plt>
jmp    12cb <main+0x16b>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe3d(%rip),%rdi
lea    -0x78(%rbp),%rsi
call   1070 <scanf@plt>
movl   $0x0,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     124a <main+0xea>
movslq -0x74(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
add    -0x78(%rbp),%eax
mov    %al,%cl
movslq -0x74(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1214 <main+0xb4>
lea    0xe0f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1030 <puts@plt>
jmp    12cb <main+0x16b>
movl   $0x0,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     12a1 <main+0x141>
movslq -0x74(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
sub    -0x78(%rbp),%eax
mov    %al,%cl
movslq -0x74(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    126b <main+0x10b>
movslq -0x74(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    0xdc2(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <puts@plt>
jmp    12cb <main+0x16b>
xor    %edi,%edi
call   1080 <exit@plt>
jmp    1172 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe8b(%rip),%r14
lea    0xeb4(%rip),%r15
lea    0xeaa(%rip),%rbx
lea    0xc(%rsp),%r12
lea    0xeb4(%rip),%r13
lea    0x30(%rsp),%rbp
jmp    11b6 <main+0x56>
cs nopw 0x0(%rax,%rax,1)
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0x50(%rsp),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
je     1220 <main+0xc0>
cmp    $0x2,%eax
je     1240 <main+0xe0>
cmp    $0x3,%eax
jne    12a6 <main+0x146>
cmpb   $0x0,0x10(%rsp)
je     1288 <main+0x128>
mov    0x8(%rsp),%al
xor    %ecx,%ecx
movzbl 0x50(%rsp,%rcx,1),%edx
sub    %al,%dl
mov    %dl,0x30(%rsp,%rcx,1)
lea    0x1(%rcx),%rdx
cmpb   $0x0,0x11(%rsp,%rcx,1)
mov    %rdx,%rcx
jne    1200 <main+0xa0>
jmp    128a <main+0x12a>
nopl   0x0(%rax,%rax,1)
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdi
call   1060 <gets@plt>
jmp    11b6 <main+0x56>
nopl   0x0(%rax,%rax,1)
lea    0xe0e(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x10(%rsp),%al
test   %al,%al
je     11a0 <main+0x40>
mov    0x8(%rsp),%cl
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
add    %cl,%al
mov    %al,0x50(%rsp,%rdx,1)
movzbl 0x11(%rsp,%rdx,1),%eax
add    $0x1,%rdx
test   %al,%al
jne    1270 <main+0x110>
jmp    11a0 <main+0x40>
xor    %edx,%edx
mov    %edx,%eax
movb   $0x0,0x30(%rsp,%rax,1)
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
jmp    11b6 <main+0x56>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"\0AMENU\0A=====\0A1.Input\0A2.Encode\0A3.Decode\0A4.Exit\00"
@.str.1 = [20 x i8] c"\0AEnter your choice\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"\0AEnter a str\0A\00"
@.str.4 = [14 x i8] c"\0AEnter a key\0A\00"
@.str.5 = [19 x i8] c"\0AEncoded String :\0A\00"
@.str.6 = [19 x i8] c"\0ADecoded String :\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca [30 x i8]
%4 = alloca [30 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
br label %8
8: ; preds = %0, %79
%9 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%12 = call i32 (...) @getchar()
%13 = load i32, i32* %7
switch i32 %13, label %77 [
i32 1, label %14
i32 2, label %18
i32 3, label %47
]
14: ; preds = %8
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%16 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%17 = call i32 @gets(i8* %16)
br label %79
18: ; preds = %8
%19 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
store i32 0, i32* %5
br label %21
21: ; preds = %40, %18
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %43
28: ; preds = %21
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = load i32, i32* %6
%35 = add nsw i32 %33, %34
%36 = trunc i32 %35 to i8
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %38
store i8 %36, i8* %39
br label %40
40: ; preds = %28
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %21
43: ; preds = %21
%44 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%45 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%46 = call i32 @puts(i8* %45)
br label %79
47: ; preds = %8
store i32 0, i32* %5
br label %48
48: ; preds = %67, %47
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %70
55: ; preds = %48
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = load i32, i32* %6
%62 = sub nsw i32 %60, %61
%63 = trunc i32 %62 to i8
%64 = load i32, i32* %5
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %65
store i8 %63, i8* %66
br label %67
67: ; preds = %55
%68 = load i32, i32* %5
%69 = add nsw i32 %68, 1
store i32 %69, i32* %5
br label %48
70: ; preds = %48
%71 = load i32, i32* %5
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %72
store i8 0, i8* %73
%74 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%75 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%76 = call i32 @puts(i8* %75)
br label %79
77: ; preds = %8
%78 = call i32 @exit(i32 0)
unreachable
79: ; preds = %70, %43, %14
br label %8
}

LLVM IR (-O2):
@.str = [45 x i8] c"\0AMENU\0A=====\0A1.Input\0A2.Encode\0A3.Decode\0A4.Exit\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [19 x i8] c"\0AEnter your choice\00"
@str.7 = [18 x i8] c"\0ADecoded String :\00"
@str.8 = [13 x i8] c"\0AEnter a key\00"
@str.9 = [18 x i8] c"\0AEncoded String :\00"
@str.10 = [13 x i8] c"\0AEnter a str\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [30 x i8]
%3 = alloca [30 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
br label %11
11: ; preds = %62, %0
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%15 = call i32 (...) @getchar()
%16 = load i32, i32* %5
switch i32 %16, label %63 [
i32 1, label %23
i32 2, label %26
i32 3, label %17
]
17: ; preds = %11
%18 = load i8, i8* %6
%19 = icmp eq i8 %18, 0
br i1 %19, label %56, label %20
20: ; preds = %17
%21 = load i32, i32* %4
%22 = trunc i32 %21 to i8
br label %46
23: ; preds = %11
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0))
%25 = call i32 @gets(i8* %6)
br label %62
26: ; preds = %11
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.8, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%29 = load i8, i8* %6
%30 = icmp eq i8 %29, 0
br i1 %30, label %43, label %31
31: ; preds = %26
%32 = load i32, i32* %4
%33 = trunc i32 %32 to i8
br label %34
34: ; preds = %31, %34
%35 = phi i64 [ 0, %31 ], [ %39, %34 ]
%36 = phi i8 [ %29, %31 ], [ %41, %34 ]
%37 = add i8 %36, %33
%38 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %35
store i8 %37, i8* %38
%39 = add nuw nsw i64 %35, 1
%40 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 0
br i1 %42, label %43, label %34
43: ; preds = %34, %26
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.9, i64 0, i64 0))
%45 = call i32 @puts(i8* %7)
br label %62
46: ; preds = %20, %46
%47 = phi i64 [ 0, %20 ], [ %52, %46 ]
%48 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sub i8 %49, %22
%51 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %47
store i8 %50, i8* %51
%52 = add nuw nsw i64 %47, 1
%53 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = icmp eq i8 %54, 0
br i1 %55, label %56, label %46
56: ; preds = %46, %17
%57 = phi i64 [ 0, %17 ], [ %52, %46 ]
%58 = and i64 %57, 4294967295
%59 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %58
store i8 0, i8* %59
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
%61 = call i32 @puts(i8* %8)
br label %62
62: ; preds = %56, %43, %23
br label %11
63: ; preds = %11
%64 = call i32 @exit(i32 0)
unreachable
}