#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 comp(int, char **);
int dec(int, char **);
int enc(int, char **);
int help();
int /*<<< orphan*/ strchr(char *, int);
int main(int argc, char *argv[]) {
  int mode = 'd';
  if (1 < argc) {
    mode = argv[1][0];
    if (!strchr("cdeh?", mode))
      mode = 'c';
  }
  return (mode == 'c')   ? comp(argc - 1, argv + 1)
         : (mode == 'e') ? enc(argc - 1, argv + 1)
         : (mode == 'd') ? dec(argc - 1, argv + 1)
                         : help();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x64,-0x14(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    11ad <main+0x5d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe6d(%rip),%rdi
call   1060 <strchr@plt>
cmp    $0x0,%eax
jne    11a8 <main+0x58>
movl   $0x63,-0x14(%rbp)
jmp    11ad <main+0x5d>
cmpl   $0x63,-0x14(%rbp)
jne    11d2 <main+0x82>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1040 <comp@plt>
mov    %eax,-0x18(%rbp)
jmp    1232 <main+0xe2>
cmpl   $0x65,-0x14(%rbp)
jne    11f7 <main+0xa7>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1030 <enc@plt>
mov    %eax,-0x1c(%rbp)
jmp    122c <main+0xdc>
cmpl   $0x64,-0x14(%rbp)
jne    121c <main+0xcc>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1050 <dec@plt>
mov    %eax,-0x20(%rbp)
jmp    1226 <main+0xd6>
mov    $0x0,%al
call   1070 <help@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebx
cmp    $0x2,%edi
jl     11a4 <main+0x54>
lea    0x8(%r15),%r14
mov    0x8(%r15),%rax
movsbl (%rax),%ebp
lea    0xe8d(%rip),%rdi
mov    %ebp,%esi
call   1060 <strchr@plt>
test   %eax,%eax
je     118d <main+0x3d>
cmp    $0x65,%ebp
je     11bf <main+0x6f>
cmp    $0x64,%ebp
je     11a4 <main+0x54>
cmp    $0x63,%ebp
jne    11d6 <main+0x86>
add    $0xffffffff,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <comp@plt>
add    $0xffffffff,%ebx
add    $0x8,%r15
mov    %ebx,%edi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <dec@plt>
add    $0xffffffff,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <enc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <help@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"cdeh?\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %6
%7 = load i32, i32* %4
%8 = icmp slt i32 1, %7
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = call i32 @strchr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %9
store i32 99, i32* %6
br label %20
20: ; preds = %19, %9
br label %21
21: ; preds = %20, %2
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 99
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = call i32 @comp(i32 %26, i8** %28)
br label %54
30: ; preds = %21
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 101
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 1
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = call i32 @enc(i32 %35, i8** %37)
br label %52
39: ; preds = %30
%40 = load i32, i32* %6
%41 = icmp eq i32 %40, 100
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i32, i32* %4
%44 = sub nsw i32 %43, 1
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = call i32 @dec(i32 %44, i8** %46)
br label %50
48: ; preds = %39
%49 = call i32 (...) @help()
br label %50
50: ; preds = %48, %42
%51 = phi i32 [ %47, %42 ], [ %49, %48 ]
br label %52
52: ; preds = %50, %33
%53 = phi i32 [ %38, %33 ], [ %51, %50 ]
br label %54
54: ; preds = %52, %24
%55 = phi i32 [ %29, %24 ], [ %53, %52 ]
ret i32 %55
}

LLVM IR (-O2):
@.str = [6 x i8] c"cdeh?\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %18
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = tail call i32 @strchr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %4
switch i32 %8, label %22 [
i32 99, label %12
i32 101, label %15
i32 100, label %18
]
12: ; preds = %4, %11
%13 = add nsw i32 %0, -1
%14 = tail call i32 @comp(i32 %13, i8** %5)
br label %24
15: ; preds = %11
%16 = add nsw i32 %0, -1
%17 = tail call i32 @enc(i32 %16, i8** %5)
br label %24
18: ; preds = %2, %11
%19 = add nsw i32 %0, -1
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = tail call i32 @dec(i32 %19, i8** %20)
br label %24
22: ; preds = %11
%23 = tail call i32 (...) @help()
br label %24
24: ; preds = %15, %22, %18, %12
%25 = phi i32 [ %14, %12 ], [ %17, %15 ], [ %21, %18 ], [ %23, %22 ]
ret i32 %25
}