#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 */
unsigned int ReverseMatch(char, struct baseMatcher *);
scalar_t__ calloc(int, int);
char *DecodeStr(char one, char two, char three, char four,
                struct baseMatcher *matchArr) {
  unsigned int magicInt = 0;
  unsigned int patchInt = 255;
  char *finalArr = (char *)calloc(3, sizeof(char));
  magicInt = magicInt ^ ReverseMatch(one, matchArr);
  magicInt = magicInt << 6;
  magicInt = magicInt ^ ReverseMatch(two, matchArr);
  magicInt = magicInt << 6;
  magicInt = magicInt ^ ReverseMatch(three, matchArr);
  magicInt = magicInt << 6;
  magicInt = magicInt ^ ReverseMatch(four, matchArr);
  finalArr[0] = magicInt & patchInt;
  magicInt = magicInt >> 8;
  finalArr[1] = magicInt & patchInt;
  magicInt = magicInt >> 8;
  finalArr[2] = magicInt & patchInt;
  magicInt = magicInt >> 8;
  return finalArr;
}


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

x86 assembly (clang, -O2):
<DecodeStr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %ecx,0xc(%rsp)
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%r13d
mov    $0x3,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,0x10(%rsp)
mov    %r13d,%edi
mov    %r14,%rsi
call   1030 <ReverseMatch@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %r14,%rsi
call   1030 <ReverseMatch@plt>
mov    %eax,%ebx
shl    $0xc,%ebp
shl    $0x6,%ebx
xor    %ebp,%ebx
mov    %r15d,%edi
mov    %r14,%rsi
call   1030 <ReverseMatch@plt>
mov    %eax,%ebp
xor    %ebx,%ebp
shl    $0x6,%ebp
mov    0xc(%rsp),%edi
mov    %r14,%rsi
call   1030 <ReverseMatch@plt>
xor    %ebp,%eax
mov    0x10(%rsp),%rcx
mov    %al,(%rcx)
mov    %ah,0x1(%rcx)
shr    $0x10,%eax
mov    %al,0x2(%rcx)
mov    %rcx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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