#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char const,
                           ...);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
size_t strlen(char const *);
void parse_args(int argc, const char **argv, uint8_t *translate_table) {
  if (argc != 3) {
    fprintf(stderr, "%s: invalid number of operands; expected 2, actual %d\n",
            argv[0], argc - 1);
    exit(1);
  }
  size_t len1 = strlen(argv[1]), len2 = strlen(argv[2]);
  if (len1 != len2) {
    fprintf(stderr,
            "%s: FROM and TO strings must be of the same length; "
            "actual lengths: %zu and %zu\n",
            argv[0], len1, len2);
    exit(1);
  }
  uint8_t dups[256];
  memset(dups, 0, sizeof dups);
  for (int i = 0; i < 256; ++i)
    translate_table[i] = i;
  for (size_t i = 0; i < len1; ++i) {
    if (dups[(uint8_t)argv[1][i]]) {
      fprintf(stderr, "%s: duplicate character %c found in FROM string\n",
              argv[0], argv[1][i]);
      exit(1);
    }
    dups[(uint8_t)argv[1][i]] = 1;
    translate_table[(uint8_t)argv[1][i]] = argv[2][i];
  }
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x3,-0x4(%rbp)
je     1191 <parse_args+0x51>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
lea    0xe83(%rip),%rsi
movsbl %al,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     11f4 <parse_args+0xb4>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%r8
lea    0xe57(%rip),%rsi
movsbl %al,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
movl   $0x0,-0x434(%rbp)
cmpl   $0x100,-0x434(%rbp)
jge    1249 <parse_args+0x109>
mov    -0x434(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x434(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
jmp    1211 <parse_args+0xd1>
movq   $0x0,-0x440(%rbp)
mov    -0x440(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    132a <parse_args+0x1ea>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x440(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cltq
cmpl   $0x0,-0x430(%rbp,%rax,4)
je     12c3 <parse_args+0x183>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x440(%rbp),%rcx
lea    0xdda(%rip),%rsi
movsbl (%rax,%rcx,1),%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x440(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cltq
movl   $0x1,-0x430(%rbp,%rax,4)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x440(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
mov    -0x440(%rbp),%rsi
movsbl (%rcx,%rsi,1),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x440(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x440(%rbp)
jmp    1254 <parse_args+0x114>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    12df <parse_args+0x19f>
mov    %rdx,%r12
mov    0x8(%r14),%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    0x10(%r14),%rdi
call   1030 <strlen@plt>
cmp    %rax,%r15
jne    12fe <parse_args+0x1be>
mov    %rsp,%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
movdqa 0xe6c(%rip),%xmm0
movdqa 0xe73(%rip),%xmm8
movdqa 0xe7a(%rip),%xmm9
movdqa 0xe81(%rip),%xmm10
movdqa 0xe89(%rip),%xmm4
movdqa 0xe91(%rip),%xmm5
movdqa 0xe99(%rip),%xmm6
movdqa 0xea1(%rip),%xmm7
movdqa 0xea9(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqu %xmm0,(%r12,%rbx,4)
movdqu %xmm2,0x10(%r12,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqu %xmm2,0x20(%r12,%rbx,4)
movdqu %xmm3,0x30(%r12,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqu %xmm2,0x40(%r12,%rbx,4)
movdqu %xmm3,0x50(%r12,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqu %xmm2,0x60(%r12,%rbx,4)
movdqu %xmm3,0x70(%r12,%rbx,4)
add    $0x20,%rbx
paddd  %xmm1,%xmm0
cmp    $0x100,%rbx
jne    11e0 <parse_args+0xa0>
test   %r15,%r15
je     12ac <parse_args+0x16c>
mov    0x8(%r14),%rax
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbq (%rax,%rdx,1),%rcx
cmpl   $0x0,(%rsp,%rcx,4)
jne    12bb <parse_args+0x17b>
movl   $0x1,(%rsp,%rcx,4)
mov    0x10(%r14),%rcx
movsbl (%rcx,%rdx,1),%ecx
movsbq (%rax,%rdx,1),%rsi
mov    %ecx,(%r12,%rsi,4)
add    $0x1,%rdx
cmp    %rdx,%r15
jne    1280 <parse_args+0x140>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe4a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%eax
mov    (%r14),%rdx
add    $0xff,%dil
movsbl %dil,%ecx
lea    0xd96(%rip),%rsi
mov    %eax,%edi
jmp    12ce <parse_args+0x18e>
mov    0x2cdb(%rip),%rcx
mov    (%rcx),%edi
mov    (%r14),%rdx
movsbl %r15b,%ecx
lea    0xdb2(%rip),%rsi
mov    %rax,%r8
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [55 x i8] c"%s: invalid number of operands; expected 2, actual %d\0A\00"
@.str.1 = [81 x i8] c"%s: FROM and TO strings must be of the same length; actual lengths: %zu and %zu\0A\00"
@.str.2 = [49 x i8] c"%s: duplicate character %c found in FROM string\0A\00"
define void @parse_args(i32 %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca [256 x i32]
%10 = alloca i32
%11 = alloca i64
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %24
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 1
%21 = trunc i32 %20 to i8
%22 = call i32 (i32, i8*, i8*, i8, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %18, i8 signext %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %3
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @strlen(i8* %27)
store i64 %28, i64* %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i64 @strlen(i8* %31)
store i64 %32, i64* %8
%33 = load i64, i64* %7
%34 = load i64, i64* %8
%35 = icmp ne i64 %33, %34
br i1 %35, label %36, label %46
36: ; preds = %24
%37 = load i32, i32* @stderr
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = load i64, i64* %7
%42 = trunc i64 %41 to i8
%43 = load i64, i64* %8
%44 = call i32 (i32, i8*, i8*, i8, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i8* %40, i8 signext %42, i64 %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %24
%47 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 0
%48 = call i32 @memset(i32* %47, i32 0, i32 1024)
store i32 0, i32* %10
br label %49
49: ; preds = %58, %46
%50 = load i32, i32* %10
%51 = icmp slt i32 %50, 256
br i1 %51, label %52, label %61
52: ; preds = %49
%53 = load i32, i32* %10
%54 = load i32*, i32** %6
%55 = load i32, i32* %10
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
store i32 %53, i32* %57
br label %58
58: ; preds = %52
%59 = load i32, i32* %10
%60 = add nsw i32 %59, 1
store i32 %60, i32* %10
br label %49
61: ; preds = %49
store i64 0, i64* %11
br label %62
62: ; preds = %118, %61
%63 = load i64, i64* %11
%64 = load i64, i64* %7
%65 = icmp ult i64 %63, %64
br i1 %65, label %66, label %121
66: ; preds = %62
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 1
%69 = load i8*, i8** %68
%70 = load i64, i64* %11
%71 = getelementptr inbounds i8, i8* %69, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 %74
%76 = load i32, i32* %75
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %91
78: ; preds = %66
%79 = load i32, i32* @stderr
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 0
%82 = load i8*, i8** %81
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 1
%85 = load i8*, i8** %84
%86 = load i64, i64* %11
%87 = getelementptr inbounds i8, i8* %85, i64 %86
%88 = load i8, i8* %87
%89 = call i32 (i32, i8*, i8*, i8, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %82, i8 signext %88)
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %66
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 1
%94 = load i8*, i8** %93
%95 = load i64, i64* %11
%96 = getelementptr inbounds i8, i8* %94, i64 %95
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [256 x i32], [256 x i32]* %9, i64 0, i64 %99
store i32 1, i32* %100
%101 = load i8**, i8*** %5
%102 = getelementptr inbounds i8*, i8** %101, i64 2
%103 = load i8*, i8** %102
%104 = load i64, i64* %11
%105 = getelementptr inbounds i8, i8* %103, i64 %104
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = load i32*, i32** %6
%109 = load i8**, i8*** %5
%110 = getelementptr inbounds i8*, i8** %109, i64 1
%111 = load i8*, i8** %110
%112 = load i64, i64* %11
%113 = getelementptr inbounds i8, i8* %111, i64 %112
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i32, i32* %108, i64 %116
store i32 %107, i32* %117
br label %118
118: ; preds = %91
%119 = load i64, i64* %11
%120 = add i64 %119, 1
store i64 %120, i64* %11
br label %62
121: ; preds = %62
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [55 x i8] c"%s: invalid number of operands; expected 2, actual %d\0A\00"
@.str.1 = [81 x i8] c"%s: FROM and TO strings must be of the same length; actual lengths: %zu and %zu\0A\00"
@.str.2 = [49 x i8] c"%s: duplicate character %c found in FROM string\0A\00"
define void @parse_args(i32 %0, i8** nocapture %1, i32* nocapture writeonly %2) {
%4 = alloca [256 x i32]
%5 = icmp eq i32 %0, 3
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = trunc i32 %0 to i8
%10 = add i8 %9, -1
%11 = tail call i32 (i32, i8*, i8*, i8, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %8, i8 signext %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %3
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i64 @strlen(i8* dereferenceable(1) %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i64 @strlen(i8* dereferenceable(1) %18)
%20 = icmp eq i64 %16, %19
br i1 %20, label %27, label %21
21: ; preds = %13
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %1
%24 = trunc i64 %16 to i8
%25 = tail call i32 (i32, i8*, i8*, i8, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8 signext %24, i64 %19)
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %13
%28 = bitcast [256 x i32]* %4 to i8*
%29 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%30 = call i32 @memset(i32* %29, i32 0, i32 1024)
br label %31
31: ; preds = %31, %27
%32 = phi i64 [ 0, %27 ], [ %60, %31 ]
%33 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %27 ], [ %61, %31 ]
%34 = add <4 x i32> %33, <i32 4, i32 4, i32 4, i32 4>
%35 = getelementptr inbounds i32, i32* %2, i64 %32
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %33, <4 x i32>* %36
%37 = getelementptr inbounds i32, i32* %35, i64 4
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> %34, <4 x i32>* %38
%39 = or i64 %32, 8
%40 = add <4 x i32> %33, <i32 8, i32 8, i32 8, i32 8>
%41 = add <4 x i32> %33, <i32 12, i32 12, i32 12, i32 12>
%42 = getelementptr inbounds i32, i32* %2, i64 %39
%43 = bitcast i32* %42 to <4 x i32>*
store <4 x i32> %40, <4 x i32>* %43
%44 = getelementptr inbounds i32, i32* %42, i64 4
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> %41, <4 x i32>* %45
%46 = or i64 %32, 16
%47 = add <4 x i32> %33, <i32 16, i32 16, i32 16, i32 16>
%48 = add <4 x i32> %33, <i32 20, i32 20, i32 20, i32 20>
%49 = getelementptr inbounds i32, i32* %2, i64 %46
%50 = bitcast i32* %49 to <4 x i32>*
store <4 x i32> %47, <4 x i32>* %50
%51 = getelementptr inbounds i32, i32* %49, i64 4
%52 = bitcast i32* %51 to <4 x i32>*
store <4 x i32> %48, <4 x i32>* %52
%53 = or i64 %32, 24
%54 = add <4 x i32> %33, <i32 24, i32 24, i32 24, i32 24>
%55 = add <4 x i32> %33, <i32 28, i32 28, i32 28, i32 28>
%56 = getelementptr inbounds i32, i32* %2, i64 %53
%57 = bitcast i32* %56 to <4 x i32>*
store <4 x i32> %54, <4 x i32>* %57
%58 = getelementptr inbounds i32, i32* %56, i64 4
%59 = bitcast i32* %58 to <4 x i32>*
store <4 x i32> %55, <4 x i32>* %59
%60 = add nuw nsw i64 %32, 32
%61 = add <4 x i32> %33, <i32 32, i32 32, i32 32, i32 32>
%62 = icmp eq i64 %60, 256
br i1 %62, label %63, label %31
63: ; preds = %31
%64 = icmp eq i64 %16, 0
br i1 %64, label %67, label %65
65: ; preds = %63
%66 = load i8*, i8** %14
br label %68
67: ; preds = %81, %63
ret void
68: ; preds = %65, %81
%69 = phi i64 [ 0, %65 ], [ %89, %81 ]
%70 = getelementptr inbounds i8, i8* %66, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i64
%73 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = icmp eq i32 %74, 0
br i1 %75, label %81, label %76
76: ; preds = %68
%77 = load i32, i32* @stderr
%78 = load i8*, i8** %1
%79 = call i32 (i32, i8*, i8*, i8, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %78, i8 signext %71)
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %68
store i32 1, i32* %73
%82 = load i8*, i8** %17
%83 = getelementptr inbounds i8, i8* %82, i64 %69
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = load i8, i8* %70
%87 = sext i8 %86 to i64
%88 = getelementptr inbounds i32, i32* %2, i64 %87
store i32 %85, i32* %88
%89 = add nuw i64 %69, 1
%90 = icmp eq i64 %89, %16
br i1 %90, label %67, label %68
}