#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_cipher_decode(char *, char *);
int /*<<< orphan*/ caesar_cipher_encode(char *, char *);
int getopt(int, char **, char *);
scalar_t__ malloc(scalar_t__);
int optind;
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int flg_encode = 0;
  int flg_decode = 0;
  char *res;
  int c;
  while ((c = getopt(argc, argv, "ed")) != -1)
    switch (c) {
    case 'e':
      flg_encode = 1;
      break;
    case 'd':
      flg_decode = 1;
      break;
    case '?':
      usage(argv[0]);
      return 1;
      break;
    }
  if ((flg_decode ^ flg_encode) == 0 || argc - optind != 1) {
    usage(argv[0]);
    return 2;
  }
  res = (char *)malloc(strlen(argv[optind]) + 1);
  if (flg_encode) {
    caesar_cipher_encode(argv[optind], res);
    printf("Encoded string: %s\n", res);
  } else {
    caesar_cipher_decode(argv[optind], res);
    printf("Decoded string: %s\n", res);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe5e(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     121e <main+0xae>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x3f,%eax
je     1201 <main+0x91>
jmp    11c7 <main+0x57>
mov    -0x28(%rbp),%eax
sub    $0x64,%eax
je     11f5 <main+0x85>
jmp    11d8 <main+0x68>
mov    -0x28(%rbp),%eax
sub    $0x65,%eax
jne    1219 <main+0xa9>
jmp    11e9 <main+0x79>
movl   $0x1,-0x14(%rbp)
jmp    1219 <main+0xa9>
movl   $0x1,-0x18(%rbp)
jmp    1219 <main+0xa9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ed <main+0x17d>
jmp    1194 <main+0x24>
mov    -0x18(%rbp),%eax
xor    -0x14(%rbp),%eax
cmp    $0x0,%eax
je     1242 <main+0xd2>
mov    -0x8(%rbp),%eax
mov    0x2db1(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x1,%eax
je     125a <main+0xea>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
movl   $0x2,-0x4(%rbp)
jmp    12ed <main+0x17d>
mov    -0x10(%rbp),%rax
mov    0x2d83(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12bb <main+0x14b>
mov    -0x10(%rbp),%rax
mov    0x2d52(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <caesar_cipher_encode@plt>
mov    -0x20(%rbp),%rsi
lea    0xd52(%rip),%rdi
call   1040 <printf@plt>
jmp    12e6 <main+0x176>
mov    -0x10(%rbp),%rax
mov    0x2d22(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <caesar_cipher_decode@plt>
mov    -0x20(%rbp),%rsi
lea    0xd36(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r12d,%r12d
lea    0xe79(%rip),%r14
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    $0x63,%eax
jg     11b0 <main+0x40>
cmp    $0xffffffff,%eax
je     11ca <main+0x5a>
cmp    $0x3f,%eax
jne    1190 <main+0x20>
jmp    1212 <main+0xa2>
xchg   %ax,%ax
cmp    $0x64,%eax
je     11c2 <main+0x52>
cmp    $0x65,%eax
jne    1190 <main+0x20>
mov    $0x1,%r15d
jmp    1190 <main+0x20>
mov    $0x1,%r12d
jmp    1190 <main+0x20>
cmp    %r15d,%r12d
je     1221 <main+0xb1>
mov    0x2e12(%rip),%r14
movslq (%r14),%rax
sub    %eax,%ebp
cmp    $0x1,%ebp
jne    1221 <main+0xb1>
mov    (%rbx,%rax,8),%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbp
movslq (%r14),%rax
mov    (%rbx,%rax,8),%rdi
mov    %rbp,%rsi
test   %r15d,%r15d
je     1230 <main+0xc0>
call   1060 <caesar_cipher_encode@plt>
lea    0xdf3(%rip),%rdi
jmp    123c <main+0xcc>
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    $0x1,%eax
jmp    1246 <main+0xd6>
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    $0x2,%eax
jmp    1246 <main+0xd6>
call   1090 <caesar_cipher_decode@plt>
lea    0xddb(%rip),%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ed\00"
@optind = global i32 0
@.str.1 = [20 x i8] c"Encoded string: %s\0A\00"
@.str.2 = [20 x i8] c"Decoded string: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %24, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %9
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %25
15: ; preds = %10
%16 = load i32, i32* %9
switch i32 %16, label %24 [
i32 101, label %17
i32 100, label %18
i32 63, label %19
]
17: ; preds = %15
store i32 1, i32* %6
br label %24
18: ; preds = %15
store i32 1, i32* %7
br label %24
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @usage(i8* %22)
store i32 1, i32* %3
br label %73
24: ; preds = %15, %18, %17
br label %10
25: ; preds = %10
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = xor i32 %26, %27
%29 = icmp eq i32 %28, 0
br i1 %29, label %35, label %30
30: ; preds = %25
%31 = load i32, i32* %4
%32 = load i32, i32* @optind
%33 = sub nsw i32 %31, %32
%34 = icmp ne i32 %33, 1
br i1 %34, label %35, label %40
35: ; preds = %30, %25
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 @usage(i8* %38)
store i32 2, i32* %3
br label %73
40: ; preds = %30
%41 = load i8**, i8*** %5
%42 = load i32, i32* @optind
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i64 @strlen(i8* %45)
%47 = add nsw i64 %46, 1
%48 = call i64 @malloc(i64 %47)
%49 = inttoptr i64 %48 to i8*
store i8* %49, i8** %8
%50 = load i32, i32* %6
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %62
52: ; preds = %40
%53 = load i8**, i8*** %5
%54 = load i32, i32* @optind
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = load i8*, i8** %8
%59 = call i32 @caesar_cipher_encode(i8* %57, i8* %58)
%60 = load i8*, i8** %8
%61 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %60)
br label %72
62: ; preds = %40
%63 = load i8**, i8*** %5
%64 = load i32, i32* @optind
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = load i8*, i8** %8
%69 = call i32 @caesar_cipher_decode(i8* %67, i8* %68)
%70 = load i8*, i8** %8
%71 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %62, %52
store i32 0, i32* %3
br label %73
73: ; preds = %72, %35, %19
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@.str = [3 x i8] c"ed\00"
@optind = global i32 0
@.str.1 = [20 x i8] c"Encoded string: %s\0A\00"
@.str.2 = [20 x i8] c"Decoded string: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %8, %2
%4 = phi i32 [ 0, %2 ], [ 1, %8 ]
%5 = phi i32 [ 0, %2 ], [ %7, %8 ]
br label %6
6: ; preds = %8, %3
%7 = phi i32 [ %5, %3 ], [ 1, %8 ]
br label %8
8: ; preds = %6, %8
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %8 [
i32 -1, label %13
i32 101, label %6
i32 100, label %3
i32 63, label %10
]
10: ; preds = %8
%11 = load i8*, i8** %1
%12 = tail call i32 @usage(i8* %11)
br label %41
13: ; preds = %8
%14 = icmp eq i32 %4, %7
br i1 %14, label %19, label %15
15: ; preds = %13
%16 = load i32, i32* @optind
%17 = sub nsw i32 %0, %16
%18 = icmp eq i32 %17, 1
br i1 %18, label %22, label %19
19: ; preds = %15, %13
%20 = load i8*, i8** %1
%21 = tail call i32 @usage(i8* %20)
br label %41
22: ; preds = %15
%23 = sext i32 %16 to i64
%24 = getelementptr inbounds i8*, i8** %1, i64 %23
%25 = load i8*, i8** %24
%26 = tail call i64 @strlen(i8* dereferenceable(1) %25)
%27 = add nsw i64 %26, 1
%28 = tail call i64 @malloc(i64 %27)
%29 = inttoptr i64 %28 to i8*
%30 = icmp eq i32 %7, 0
%31 = load i32, i32* @optind
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %1, i64 %32
%34 = load i8*, i8** %33
br i1 %30, label %38, label %35
35: ; preds = %22
%36 = tail call i32 @caesar_cipher_encode(i8* %34, i8* %29)
%37 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %41
38: ; preds = %22
%39 = tail call i32 @caesar_cipher_decode(i8* %34, i8* %29)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %41
41: ; preds = %35, %38, %19, %10
%42 = phi i32 [ 1, %10 ], [ 2, %19 ], [ 0, %38 ], [ 0, %35 ]
ret i32 %42
}