#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 */
size_t arrlen(char *);
scalar_t__ containsDuplicates(char *, size_t);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  size_t from_len = arrlen(argv[1]);
  if (from_len != arrlen(argv[2]))
    goto ERROR_LEN_EXIT;
  if (containsDuplicates(argv[1], from_len))
    goto ERROR_DUP_EXIT;
  char buffer;
  size_t i;
  while (read(0, &buffer, 1) > 0) {
    for (i = 0; i < from_len; i++)
      if (buffer == argv[1][i])
        buffer = argv[2][i];
    write(1, &buffer, 1);
  }
  exit(0);
ERROR_LEN_EXIT:
  fprintf(stdout, "'from' and 'to' are not the same length\n");
  exit(1);
ERROR_DUP_EXIT:
  fprintf(stdout, "'from' contains duplicates \n");
  exit(1);
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <arrlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <arrlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     11b1 <main+0x51>
jmp    1266 <main+0x106>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <containsDuplicates@plt>
cmp    $0x0,%rax
je     11d1 <main+0x71>
jmp    1285 <main+0x125>
jmp    11d6 <main+0x76>
xor    %edi,%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x0,%rax
jle    125f <main+0xff>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    124a <main+0xea>
movsbl -0x19(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
mov    -0x28(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    1234 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
jmp    1239 <main+0xd9>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11f8 <main+0x98>
mov    $0x1,%edx
lea    -0x19(%rbp),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    11d6 <main+0x76>
xor    %edi,%edi
call   1080 <exit@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xd8a(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    0x8(%rsi),%rdi
call   1050 <arrlen@plt>
mov    %rax,%r14
mov    0x10(%r12),%rdi
call   1050 <arrlen@plt>
cmp    %rax,%r14
jne    1259 <main+0xf9>
mov    0x8(%r12),%rdi
mov    %r14,%rsi
call   1070 <containsDuplicates@plt>
test   %rax,%rax
jne    126b <main+0x10b>
lea    0x7(%rsp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1040 <read@plt>
test   %rax,%rax
jle    128a <main+0x12a>
mov    %r14,%rbx
and    $0xfffffffffffffffe,%rbx
lea    0x7(%rsp),%r15
jmp    11fe <main+0x9e>
nopl   0x0(%rax,%rax,1)
mov    %al,0x7(%rsp)
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %edi,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1040 <read@plt>
test   %rax,%rax
jle    128a <main+0x12a>
mov    0x7(%rsp),%al
test   %r14,%r14
je     11d0 <main+0x70>
mov    0x8(%r12),%rcx
xor    %edx,%edx
cmp    $0x1,%r14
jne    1239 <main+0xd9>
test   $0x1,%r14b
je     11d0 <main+0x70>
cmp    (%rcx,%rdx,1),%al
jne    11d0 <main+0x70>
mov    0x10(%r12),%rax
mov    (%rax,%rdx,1),%al
jmp    11d0 <main+0x70>
nopl   0x0(%rax)
add    $0x2,%rdx
cmp    %rdx,%rbx
je     1214 <main+0xb4>
cmp    (%rcx,%rdx,1),%al
jne    1247 <main+0xe7>
mov    0x10(%r12),%rax
movzbl (%rax,%rdx,1),%eax
cmp    0x1(%rcx,%rdx,1),%al
jne    1230 <main+0xd0>
mov    0x10(%r12),%rax
movzbl 0x1(%rax,%rdx,1),%eax
jmp    1230 <main+0xd0>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%rip),%rsi
jmp    127b <main+0x11b>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xdae(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [41 x i8] c"'from' and 'to' are not the same length\0A\00"
@.str.1 = [29 x i8] c"'from' contains duplicates \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @arrlen(i8* %11)
store i64 %12, i64* %6
%13 = load i64, i64* %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i64 @arrlen(i8* %16)
%18 = icmp ne i64 %13, %17
br i1 %18, label %19, label %20
19: ; preds = %2
br label %63
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i64, i64* %6
%25 = call i64 @containsDuplicates(i8* %23, i64 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %20
br label %67
28: ; preds = %20
br label %29
29: ; preds = %59, %28
%30 = call i64 @read(i32 0, i8* %7, i32 1)
%31 = icmp sgt i64 %30, 0
br i1 %31, label %32, label %61
32: ; preds = %29
store i64 0, i64* %8
br label %33
33: ; preds = %56, %32
%34 = load i64, i64* %8
%35 = load i64, i64* %6
%36 = icmp ult i64 %34, %35
br i1 %36, label %37, label %59
37: ; preds = %33
%38 = load i8, i8* %7
%39 = sext i8 %38 to i32
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = load i64, i64* %8
%44 = getelementptr inbounds i8, i8* %42, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %39, %46
br i1 %47, label %48, label %55
48: ; preds = %37
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = load i64, i64* %8
%53 = getelementptr inbounds i8, i8* %51, i64 %52
%54 = load i8, i8* %53
store i8 %54, i8* %7
br label %55
55: ; preds = %48, %37
br label %56
56: ; preds = %55
%57 = load i64, i64* %8
%58 = add i64 %57, 1
store i64 %58, i64* %8
br label %33
59: ; preds = %33
%60 = call i32 @write(i32 1, i8* %7, i32 1)
br label %29
61: ; preds = %29
%62 = call i32 @exit(i32 0)
unreachable
63: ; preds = %19
%64 = load i32, i32* @stdout
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %27
%68 = load i32, i32* @stdout
%69 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%70 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [41 x i8] c"'from' and 'to' are not the same length\0A\00"
@.str.1 = [29 x i8] c"'from' contains duplicates \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @arrlen(i8* %5)
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i64 @arrlen(i8* %8)
%10 = icmp eq i64 %6, %9
br i1 %10, label %11, label %73
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = tail call i64 @containsDuplicates(i8* %12, i64 %6)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %77
15: ; preds = %11
%16 = call i64 @read(i32 0, i8* %3, i32 1)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %71
18: ; preds = %15
%19 = icmp eq i64 %6, 0
%20 = and i64 %6, 1
%21 = icmp eq i64 %6, 1
%22 = and i64 %6, -2
%23 = icmp eq i64 %20, 0
br label %24
24: ; preds = %18, %66
%25 = load i8, i8* %3
br i1 %19, label %66, label %26
26: ; preds = %24
%27 = load i8*, i8** %4
br i1 %21, label %54, label %28
28: ; preds = %26, %49
%29 = phi i64 [ %51, %49 ], [ 0, %26 ]
%30 = phi i8 [ %50, %49 ], [ %25, %26 ]
%31 = phi i64 [ %52, %49 ], [ 0, %26 ]
%32 = getelementptr inbounds i8, i8* %27, i64 %29
%33 = load i8, i8* %32
%34 = icmp eq i8 %30, %33
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i64 %29
%38 = load i8, i8* %37
br label %39
39: ; preds = %28, %35
%40 = phi i8 [ %30, %28 ], [ %38, %35 ]
%41 = or i64 %29, 1
%42 = getelementptr inbounds i8, i8* %27, i64 %41
%43 = load i8, i8* %42
%44 = icmp eq i8 %40, %43
br i1 %44, label %45, label %49
45: ; preds = %39
%46 = load i8*, i8** %7
%47 = getelementptr inbounds i8, i8* %46, i64 %41
%48 = load i8, i8* %47
br label %49
49: ; preds = %45, %39
%50 = phi i8 [ %40, %39 ], [ %48, %45 ]
%51 = add nuw i64 %29, 2
%52 = add i64 %31, 2
%53 = icmp eq i64 %52, %22
br i1 %53, label %54, label %28
54: ; preds = %49, %26
%55 = phi i8 [ undef, %26 ], [ %50, %49 ]
%56 = phi i64 [ 0, %26 ], [ %51, %49 ]
%57 = phi i8 [ %25, %26 ], [ %50, %49 ]
br i1 %23, label %66, label %58
58: ; preds = %54
%59 = getelementptr inbounds i8, i8* %27, i64 %56
%60 = load i8, i8* %59
%61 = icmp eq i8 %57, %60
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load i8*, i8** %7
%64 = getelementptr inbounds i8, i8* %63, i64 %56
%65 = load i8, i8* %64
br label %66
66: ; preds = %54, %62, %58, %24
%67 = phi i8 [ %25, %24 ], [ %55, %54 ], [ %57, %58 ], [ %65, %62 ]
store i8 %67, i8* %3
%68 = call i32 @write(i32 1, i8* %3, i32 1)
%69 = call i64 @read(i32 0, i8* %3, i32 1)
%70 = icmp sgt i64 %69, 0
br i1 %70, label %24, label %71
71: ; preds = %66, %15
%72 = tail call i32 @exit(i32 0)
unreachable
73: ; preds = %2
%74 = load i32, i32* @stdout
%75 = tail call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%76 = tail call i32 @exit(i32 1)
unreachable
77: ; preds = %11
%78 = load i32, i32* @stdout
%79 = tail call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%80 = tail call i32 @exit(i32 1)
unreachable
}