#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*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int strlen(char *);
int main(int argc, char **argv) {
  int i, len = strlen(argv[2]);
  if (argc > 2) {
    if (argv[1][0] == 'd')
      for (i = 0; i < len; i++)
        switch (i % 12) {
        case 0:
        case 1:
        case 2:
        case 4:
        case 5:
        case 6:
        case 8:
        case 9:
          putchar(argv[2][i]);
          break;
        default:
          break;
        }
    else
      for (i = 0; i < len; i++)
        switch (i % 8) {
        case 0:
        case 1:
        case 3:
        case 4:
        case 6:
          putchar(argv[2][i]);
          break;
        case 2:
        case 5:
          putchar(argv[2][i]);
          if (argv[2][i] == '0')
            putchar('1');
          else
            putchar('0');
          break;
        case 7:
          putchar(argv[2][i]);
          if (i < len - 1)
            printf("01");
        }
  } else
    printf("Usage: %s <d/e> <bit sequence>\n\td - decode\n\te - encode\n\tbit "
           "sequence as string of 0 and 1.\n",
           argv[0]);
  return 0;
}


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)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1367 <main+0x237>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x64,%eax
jne    121b <main+0xeb>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1216 <main+0xe6>
movslq -0x14(%rbp),%rcx
mov    %ecx,%eax
imul   $0x2aaaaaab,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x21,%rdx
add    %ecx,%edx
shl    $0x2,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
sub    $0x3,%eax
jb     11e4 <main+0xb4>
jmp    11bc <main+0x8c>
mov    -0x1c(%rbp),%eax
add    $0xfffffffc,%eax
sub    $0x3,%eax
jb     11e4 <main+0xb4>
jmp    11d0 <main+0xa0>
mov    -0x1c(%rbp),%eax
add    $0xfffffff8,%eax
sub    $0x1,%eax
ja     11fe <main+0xce>
jmp    11e4 <main+0xb4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    1203 <main+0xd3>
jmp    1203 <main+0xd3>
jmp    1208 <main+0xd8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117b <main+0x4b>
jmp    1362 <main+0x232>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    135d <main+0x22d>
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x7,%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffff8,%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
sub    $0x2,%eax
jb     12ab <main+0x17b>
jmp    1253 <main+0x123>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     12c5 <main+0x195>
jmp    1264 <main+0x134>
mov    -0x20(%rbp),%eax
add    $0xfffffffd,%eax
sub    $0x2,%eax
jb     12ab <main+0x17b>
jmp    1278 <main+0x148>
mov    -0x20(%rbp),%eax
sub    $0x5,%eax
je     12c5 <main+0x195>
jmp    1289 <main+0x159>
mov    -0x20(%rbp),%eax
sub    $0x6,%eax
je     12ab <main+0x17b>
jmp    129a <main+0x16a>
mov    -0x20(%rbp),%eax
sub    $0x7,%eax
je     1311 <main+0x1e1>
jmp    134a <main+0x21a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    134a <main+0x21a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jne    1302 <main+0x1d2>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    130c <main+0x1dc>
mov    $0x30,%edi
call   1030 <putchar@plt>
jmp    134a <main+0x21a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1345 <main+0x215>
lea    0xcc2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    134a <main+0x21a>
jmp    134f <main+0x21f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1222 <main+0xf2>
jmp    1362 <main+0x232>
jmp    137c <main+0x24c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xc8e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x10(%rsi),%rdi
call   1040 <strlen@plt>
cmp    $0x3,%ebp
jl     11a7 <main+0x77>
mov    0x8(%rbx),%rcx
cmpb   $0x64,(%rcx)
jne    11c9 <main+0x99>
test   %eax,%eax
jle    11b8 <main+0x88>
mov    %eax,%r14d
xor    %ebp,%ebp
mov    $0xaaaaaaab,%r15d
mov    $0x377,%r12d
jmp    1179 <main+0x49>
xchg   %ax,%ax
add    $0x1,%rbp
cmp    %rbp,%r14
je     11b8 <main+0x88>
mov    %ebp,%eax
imul   %r15,%rax
shr    $0x23,%rax
shl    $0x2,%eax
lea    (%rax,%rax,2),%ecx
mov    %ebp,%eax
sub    %ecx,%eax
cmp    $0x9,%eax
ja     1170 <main+0x40>
bt     %eax,%r12d
jae    1170 <main+0x40>
mov    0x10(%rbx),%rax
movsbl (%rax,%rbp,1),%edi
call   1030 <putchar@plt>
jmp    1170 <main+0x40>
mov    (%rbx),%rsi
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %eax,%eax
jle    11b8 <main+0x88>
lea    -0x1(%rax),%r15d
mov    %eax,%ebp
mov    $0x5b,%r12d
mov    $0x24,%r13d
xor    %r14d,%r14d
jmp    1207 <main+0xd7>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rbx),%rax
movsbl (%rax,%r14,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    %r14,%rbp
je     11b8 <main+0x88>
mov    %r14d,%eax
and    $0x7,%eax
bt     %eax,%r12d
jb     11f0 <main+0xc0>
bt     %eax,%r13d
jae    1239 <main+0x109>
mov    0x10(%rbx),%rax
movsbl (%rax,%r14,1),%edi
call   1030 <putchar@plt>
mov    0x10(%rbx),%rax
cmpb   $0x30,(%rax,%r14,1)
jne    125c <main+0x12c>
mov    $0x31,%edi
jmp    11f9 <main+0xc9>
mov    0x10(%rbx),%rax
movsbl (%rax,%r14,1),%edi
call   1030 <putchar@plt>
cmp    %r15,%r14
jae    11fe <main+0xce>
lea    0xdad(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11fe <main+0xce>
mov    $0x30,%edi
jmp    11f9 <main+0xc9>

LLVM IR (-O0):
@.str = [3 x i8] c"01\00"
@.str.1 = [92 x i8] c"Usage: %s <d/e> <bit sequence>\0A\09d - decode\0A\09e - encode\0A\09bit sequence as string of 0 and 1.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 2
%10 = load i8*, i8** %9
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 2
br i1 %13, label %14, label %107
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 100
br i1 %21, label %22, label %45
22: ; preds = %14
store i32 0, i32* %6
br label %23
23: ; preds = %41, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %44
27: ; preds = %23
%28 = load i32, i32* %6
%29 = srem i32 %28, 12
switch i32 %29, label %39 [
i32 0, label %30
i32 1, label %30
i32 2, label %30
i32 4, label %30
i32 5, label %30
i32 6, label %30
i32 8, label %30
i32 9, label %30
]
30: ; preds = %27, %27, %27, %27, %27, %27, %27, %27
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @putchar(i8 signext %37)
br label %40
39: ; preds = %27
br label %40
40: ; preds = %39, %30
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %23
44: ; preds = %23
br label %106
45: ; preds = %14
store i32 0, i32* %6
br label %46
46: ; preds = %102, %45
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %105
50: ; preds = %46
%51 = load i32, i32* %6
%52 = srem i32 %51, 8
switch i32 %52, label %101 [
i32 0, label %53
i32 1, label %53
i32 3, label %53
i32 4, label %53
i32 6, label %53
i32 2, label %62
i32 5, label %62
i32 7, label %85
]
53: ; preds = %50, %50, %50, %50, %50
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = call i32 @putchar(i8 signext %60)
br label %101
62: ; preds = %50, %50
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = load i32, i32* %6
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = load i8, i8* %68
%70 = call i32 @putchar(i8 signext %69)
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 2
%73 = load i8*, i8** %72
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 48
br i1 %79, label %80, label %82
80: ; preds = %62
%81 = call i32 @putchar(i8 signext 49)
br label %84
82: ; preds = %62
%83 = call i32 @putchar(i8 signext 48)
br label %84
84: ; preds = %82, %80
br label %101
85: ; preds = %50
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 2
%88 = load i8*, i8** %87
%89 = load i32, i32* %6
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
%92 = load i8, i8* %91
%93 = call i32 @putchar(i8 signext %92)
%94 = load i32, i32* %6
%95 = load i32, i32* %7
%96 = sub nsw i32 %95, 1
%97 = icmp slt i32 %94, %96
br i1 %97, label %98, label %100
98: ; preds = %85
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %100
100: ; preds = %98, %85
br label %101
101: ; preds = %100, %50, %84, %53
br label %102
102: ; preds = %101
%103 = load i32, i32* %6
%104 = add nsw i32 %103, 1
store i32 %104, i32* %6
br label %46
105: ; preds = %46
br label %106
106: ; preds = %105, %44
br label %112
107: ; preds = %2
%108 = load i8**, i8*** %5
%109 = getelementptr inbounds i8*, i8** %108, i64 0
%110 = load i8*, i8** %109
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.1, i64 0, i64 0), i8* %110)
br label %112
112: ; preds = %107, %106
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"01\00"
@.str.1 = [92 x i8] c"Usage: %s <d/e> <bit sequence>\0A\09d - decode\0A\09e - encode\0A\09bit sequence as string of 0 and 1.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 2
%4 = load i8*, i8** %3
%5 = tail call i32 @strlen(i8* %4)
%6 = icmp sgt i32 %0, 2
br i1 %6, label %7, label %67
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 100
%12 = icmp sgt i32 %5, 0
br i1 %11, label %18, label %13
13: ; preds = %7
br i1 %12, label %14, label %70
14: ; preds = %13
%15 = add nsw i32 %5, -1
%16 = zext i32 %15 to i64
%17 = zext i32 %5 to i64
br label %33
18: ; preds = %7
br i1 %12, label %19, label %70
19: ; preds = %18
%20 = zext i32 %5 to i64
br label %21
21: ; preds = %19, %30
%22 = phi i64 [ 0, %19 ], [ %31, %30 ]
%23 = trunc i64 %22 to i32
%24 = urem i32 %23, 12
switch i32 %24, label %30 [
i32 0, label %25
i32 1, label %25
i32 2, label %25
i32 4, label %25
i32 5, label %25
i32 6, label %25
i32 8, label %25
i32 9, label %25
]
25: ; preds = %21, %21, %21, %21, %21, %21, %21, %21
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 %22
%28 = load i8, i8* %27
%29 = tail call i32 @putchar(i8 signext %28)
br label %30
30: ; preds = %25, %21
%31 = add nuw nsw i64 %22, 1
%32 = icmp eq i64 %31, %20
br i1 %32, label %70, label %21
33: ; preds = %14, %64
%34 = phi i64 [ 0, %14 ], [ %65, %64 ]
%35 = trunc i64 %34 to i32
%36 = and i32 %35, 7
switch i32 %36, label %63 [
i32 0, label %37
i32 1, label %37
i32 3, label %37
i32 4, label %37
i32 6, label %37
i32 2, label %42
i32 5, label %42
i32 7, label %55
]
37: ; preds = %33, %33, %33, %33, %33
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 %34
%40 = load i8, i8* %39
%41 = tail call i32 @putchar(i8 signext %40)
br label %64
42: ; preds = %33, %33
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i64 %34
%45 = load i8, i8* %44
%46 = tail call i32 @putchar(i8 signext %45)
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i64 %34
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 48
br i1 %50, label %51, label %53
51: ; preds = %42
%52 = tail call i32 @putchar(i8 signext 49)
br label %64
53: ; preds = %42
%54 = tail call i32 @putchar(i8 signext 48)
br label %64
55: ; preds = %33
%56 = load i8*, i8** %3
%57 = getelementptr inbounds i8, i8* %56, i64 %34
%58 = load i8, i8* %57
%59 = tail call i32 @putchar(i8 signext %58)
%60 = icmp ult i64 %34, %16
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %64
63: ; preds = %33
unreachable
64: ; preds = %37, %53, %51, %61, %55
%65 = add nuw nsw i64 %34, 1
%66 = icmp eq i64 %65, %17
br i1 %66, label %70, label %33
67: ; preds = %2
%68 = load i8*, i8** %1
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([92 x i8], [92 x i8]* @.str.1, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %64, %30, %13, %18, %67
ret i32 0
}