#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 */
struct baseMatcher {
  int dummy;
};

/* Variables and functions */
char FindTheMatch(unsigned int, struct baseMatcher *);
scalar_t__ calloc(int, int);
char *EncodeStr(char one, char two, char three, struct baseMatcher *matchArr) {
  unsigned int magicInt = 0;
  unsigned int patchInt = 63;
  char *finalArr = (char *)calloc(4, sizeof(char));
  magicInt = magicInt ^ one;
  magicInt = magicInt << 8;
  magicInt = magicInt ^ two;
  magicInt = magicInt << 8;
  magicInt = magicInt ^ three;
  finalArr[0] = FindTheMatch(magicInt & patchInt, matchArr);
  magicInt = magicInt >> 6;
  finalArr[1] = FindTheMatch(magicInt & patchInt, matchArr);
  magicInt = magicInt >> 6;
  finalArr[2] = FindTheMatch(magicInt & patchInt, matchArr);
  magicInt = magicInt >> 6;
  finalArr[3] = FindTheMatch(magicInt & patchInt, matchArr);
  return finalArr;
}


x86 assembly (clang, -O0):
<EncodeStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %rcx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x3f,-0x18(%rbp)
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
movsbl -0x1(%rbp),%ecx
xor    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
movsbl -0x2(%rbp),%ecx
xor    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
movsbl -0x3(%rbp),%ecx
xor    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
and    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <FindTheMatch@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
shr    $0x6,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
and    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <FindTheMatch@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x14(%rbp),%eax
shr    $0x6,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
and    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <FindTheMatch@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x14(%rbp),%eax
shr    $0x6,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
and    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <FindTheMatch@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EncodeStr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%ebx
mov    %esi,%ebp
mov    %edi,%r12d
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%r15
shl    $0x10,%r12d
shl    $0x8,%ebp
xor    %r12d,%ebp
xor    %ebx,%ebp
and    $0x3f,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <FindTheMatch@plt>
mov    %al,(%r15)
mov    %ebp,%edi
shr    $0x6,%edi
and    $0x3f,%edi
mov    %r14,%rsi
call   1030 <FindTheMatch@plt>
mov    %al,0x1(%r15)
mov    %ebp,%edi
shr    $0xc,%edi
and    $0x3f,%edi
mov    %r14,%rsi
call   1030 <FindTheMatch@plt>
mov    %al,0x2(%r15)
shr    $0x12,%ebp
and    $0x3f,%ebp
mov    %ebp,%edi
mov    %r14,%rsi
call   1030 <FindTheMatch@plt>
mov    %al,0x3(%r15)
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.baseMatcher = type { i32 }
define i8* @EncodeStr(i8 signext %0, i8 signext %1, i8 signext %2, %struct.baseMatcher* %3) {
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca %struct.baseMatcher*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8 %0, i8* %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store %struct.baseMatcher* %3, %struct.baseMatcher** %8
store i32 0, i32* %9
store i32 63, i32* %10
%12 = call i64 @calloc(i32 4, i32 1)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %11
%14 = load i32, i32* %9
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
%17 = xor i32 %14, %16
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = shl i32 %18, 8
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
%23 = xor i32 %20, %22
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = shl i32 %24, 8
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = load i8, i8* %7
%28 = sext i8 %27 to i32
%29 = xor i32 %26, %28
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = load i32, i32* %10
%32 = and i32 %30, %31
%33 = load %struct.baseMatcher*, %struct.baseMatcher** %8
%34 = call signext i8 @FindTheMatch(i32 %32, %struct.baseMatcher* %33)
%35 = load i8*, i8** %11
%36 = getelementptr inbounds i8, i8* %35, i64 0
store i8 %34, i8* %36
%37 = load i32, i32* %9
%38 = lshr i32 %37, 6
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = load i32, i32* %10
%41 = and i32 %39, %40
%42 = load %struct.baseMatcher*, %struct.baseMatcher** %8
%43 = call signext i8 @FindTheMatch(i32 %41, %struct.baseMatcher* %42)
%44 = load i8*, i8** %11
%45 = getelementptr inbounds i8, i8* %44, i64 1
store i8 %43, i8* %45
%46 = load i32, i32* %9
%47 = lshr i32 %46, 6
store i32 %47, i32* %9
%48 = load i32, i32* %9
%49 = load i32, i32* %10
%50 = and i32 %48, %49
%51 = load %struct.baseMatcher*, %struct.baseMatcher** %8
%52 = call signext i8 @FindTheMatch(i32 %50, %struct.baseMatcher* %51)
%53 = load i8*, i8** %11
%54 = getelementptr inbounds i8, i8* %53, i64 2
store i8 %52, i8* %54
%55 = load i32, i32* %9
%56 = lshr i32 %55, 6
store i32 %56, i32* %9
%57 = load i32, i32* %9
%58 = load i32, i32* %10
%59 = and i32 %57, %58
%60 = load %struct.baseMatcher*, %struct.baseMatcher** %8
%61 = call signext i8 @FindTheMatch(i32 %59, %struct.baseMatcher* %60)
%62 = load i8*, i8** %11
%63 = getelementptr inbounds i8, i8* %62, i64 3
store i8 %61, i8* %63
%64 = load i8*, i8** %11
ret i8* %64
}

LLVM IR (-O2):
%struct.baseMatcher = type { i32 }
define i8* @EncodeStr(i8 signext %0, i8 signext %1, i8 signext %2, %struct.baseMatcher* %3) {
%5 = tail call i64 @calloc(i32 4, i32 1)
%6 = inttoptr i64 %5 to i8*
%7 = sext i8 %0 to i32
%8 = sext i8 %1 to i32
%9 = shl nsw i32 %7, 16
%10 = shl nsw i32 %8, 8
%11 = xor i32 %10, %9
%12 = sext i8 %2 to i32
%13 = xor i32 %11, %12
%14 = and i32 %12, 63
%15 = tail call signext i8 @FindTheMatch(i32 %14, %struct.baseMatcher* %3)
store i8 %15, i8* %6
%16 = lshr i32 %13, 6
%17 = and i32 %16, 63
%18 = tail call signext i8 @FindTheMatch(i32 %17, %struct.baseMatcher* %3)
%19 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %18, i8* %19
%20 = lshr i32 %13, 12
%21 = and i32 %20, 63
%22 = tail call signext i8 @FindTheMatch(i32 %21, %struct.baseMatcher* %3)
%23 = getelementptr inbounds i8, i8* %6, i64 2
store i8 %22, i8* %23
%24 = lshr i32 %13, 18
%25 = and i32 %24, 63
%26 = tail call signext i8 @FindTheMatch(i32 %25, %struct.baseMatcher* %3)
%27 = getelementptr inbounds i8, i8* %6, i64 3
store i8 %26, i8* %27
ret i8* %6
}