#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*/ escape(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ unescape(char *, char *);
int main(int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "usage: %s <escape|unescape> <string>\n", argv[0]);
    exit(1);
  }
  char buf[0x10000];
  if (strcmp(argv[1], "escape") == 0)
    escape(buf, argv[2]);
  else
    unescape(buf, argv[2]);
  printf("%s\n", buf);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10010,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a9 <main+0x49>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe66(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11e0 <main+0x80>
lea    -0x10010(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1080 <escape@plt>
jmp    11f4 <main+0x94>
lea    -0x10010(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1060 <unescape@plt>
lea    -0x10010(%rbp),%rsi
lea    0xe2b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10000,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11b2 <main+0x52>
mov    0x8(%rbx),%rdi
lea    0xeab(%rip),%rsi
call   1040 <strcmp@plt>
mov    0x10(%rbx),%rsi
mov    %rsp,%rdi
test   %rax,%rax
je     1193 <main+0x33>
call   1060 <unescape@plt>
jmp    1198 <main+0x38>
call   1080 <escape@plt>
lea    0xe8e(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10000,%rsp
pop    %rbx
ret
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe3b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s <escape|unescape> <string>\0A\00"
@.str.1 = [7 x i8] c"escape\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [65536 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @escape(i8* %23, i8* %26)
br label %34
28: ; preds = %16
%29 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @unescape(i8* %29, i8* %32)
br label %34
34: ; preds = %28, %22
%35 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s <escape|unescape> <string>\0A\00"
@.str.1 = [7 x i8] c"escape\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65536 x i8]
%4 = icmp eq i32 %0, 3
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
br i1 %15, label %18, label %20
18: ; preds = %10
%19 = call i32 @escape(i8* %11, i8* %17)
br label %22
20: ; preds = %10
%21 = call i32 @unescape(i8* %11, i8* %17)
br label %22
22: ; preds = %20, %18
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
ret i32 0
}