#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*/ code(char *);
int /*<<< orphan*/ decode(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char w, mas[1000];
  printf(
      "Type c for code and d for decode press enter and then add the text\n");
  scanf("%c", &w);
  while (w == 'c') {
    code(mas);
  }
  while (w == 'd') {
    decode(mas);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x63,%eax
jne    118c <main+0x4c>
lea    -0x3f0(%rbp),%rdi
call   1060 <code@plt>
jmp    116e <main+0x2e>
jmp    1191 <main+0x51>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
jne    11af <main+0x6f>
lea    -0x3f0(%rbp),%rdi
call   1040 <decode@plt>
jmp    1191 <main+0x51>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x400,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xf(%rsp),%al
cmp    $0x63,%al
jne    1191 <main+0x51>
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <code@plt>
movzbl 0xf(%rsp),%eax
cmp    $0x63,%al
je     1180 <main+0x40>
cmp    $0x64,%al
jne    11af <main+0x6f>
lea    0x10(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <decode@plt>
cmpb   $0x64,0xf(%rsp)
je     11a0 <main+0x60>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [68 x i8] c"Type c for code and d for decode press enter and then add the text\0A\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [1000 x i8]
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %6
6: ; preds = %10, %0
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 99
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%12 = call i32 @code(i8* %11)
br label %6
13: ; preds = %6
br label %14
14: ; preds = %18, %13
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 100
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%20 = call i32 @decode(i8* %19)
br label %14
21: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@str = [67 x i8] c"Type c for code and d for decode press enter and then add the text\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))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 99
br i1 %7, label %11, label %8
8: ; preds = %11, %0
%9 = phi i8 [ %6, %0 ], [ %13, %11 ]
%10 = icmp eq i8 %9, 100
br i1 %10, label %15, label %19
11: ; preds = %0, %11
%12 = call i32 @code(i8* %3)
%13 = load i8, i8* %1
%14 = icmp eq i8 %13, 99
br i1 %14, label %11, label %8
15: ; preds = %8, %15
%16 = call i32 @decode(i8* %3)
%17 = load i8, i8* %1
%18 = icmp eq i8 %17, 100
br i1 %18, label %15, label %19
19: ; preds = %15, %8
ret i32 0
}