#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*/ cod();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char k;
  printf("press c and enter to encode\n");
  printf("press d and enter to decode\n");
  printf("press q and enter to exit from program\n");
  printf("\n");
  while (k != 'q') {
    scanf("%c", &k);
    if (k == 'c' || k == 'd')
      cod();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x71,%eax
je     11b2 <main+0x82>
lea    0xedf(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x63,%eax
je     11a6 <main+0x76>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    11ad <main+0x7d>
mov    $0x0,%al
call   1030 <cod@plt>
jmp    116f <main+0x3f>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe87(%rip),%r14
lea    0x7(%rsp),%rbx
jmp    1184 <main+0x44>
cmp    $0x71,%al
je     11aa <main+0x6a>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movzbl 0x7(%rsp),%eax
lea    -0x63(%rax),%ecx
cmp    $0x1,%cl
ja     1180 <main+0x40>
xor    %eax,%eax
call   1050 <cod@plt>
movzbl 0x7(%rsp),%eax
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"press c and enter to encode\0A\00"
@.str.1 = [29 x i8] c"press d and enter to decode\0A\00"
@.str.2 = [40 x i8] c"press q and enter to exit from program\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %22, %0
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 113
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 99
br i1 %15, label %20, label %16
16: ; preds = %11
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 100
br i1 %19, label %20, label %22
20: ; preds = %16, %11
%21 = call i32 (...) @cod()
br label %22
22: ; preds = %20, %16
br label %7
23: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str.4 = [3 x i8] c"%c\00"
@str = [28 x i8] c"press c and enter to encode\00"
@str.5 = [28 x i8] c"press d and enter to decode\00"
@str.6 = [39 x i8] c"press q and enter to exit from program\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.6, i64 0, i64 0))
%5 = tail call i32 @putchar(i32 10)
br label %6
6: ; preds = %0, %14
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%8 = load i8, i8* %1
%9 = add i8 %8, -99
%10 = icmp ult i8 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = call i32 (...) @cod()
%13 = load i8, i8* %1
br label %14
14: ; preds = %6, %11
%15 = phi i8 [ %8, %6 ], [ %13, %11 ]
%16 = icmp eq i8 %15, 113
br i1 %16, label %17, label %6
17: ; preds = %14
ret i32 0
}