#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 from_hex(char);
int strlen(char *);
void decrypt(void *input, void *output) {
  char key[] = "EDUARDO";
  char *pinput = (char *)input;
  char *poutput = (char *)output;
  int sinput = strlen(pinput);
  int skey = strlen(key);
  int idx;
  for (idx = 0; idx < sinput / 2; idx++) {
    int pos = idx % skey;
    poutput[idx] =
        ((from_hex(pinput[idx * 2]) << 4) | from_hex(pinput[idx * 2 + 1])) ^
        key[pos];
  }
}


x86 assembly (clang, -O0):
<decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    11f4 <decrypt+0xd4>
mov    -0x34(%rbp),%eax
cltd
idivl  -0x30(%rbp)
mov    %edx,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <from_hex@plt>
shl    $0x4,%eax
mov    %eax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <from_hex@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
or     %ecx,%eax
movslq -0x38(%rbp),%rcx
movsbl -0x18(%rbp,%rcx,1),%ecx
xor    %ecx,%eax
mov    %al,%dl
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116a <decrypt+0x4a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r12
mov    %rdi,%r13
movabs $0x4f445241554445,%rax
mov    %rax,0x10(%rsp)
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rdi
call   1030 <strlen@plt>
mov    %rbp,0x8(%rsp)
cmp    $0x2,%ebp
jl     11ab <decrypt+0x8b>
mov    %eax,%r15d
mov    0x8(%rsp),%rax
shr    %eax
mov    %rax,0x8(%rsp)
xor    %ebp,%ebp
nop
mov    %ebp,%eax
cltd
idiv   %r15d
mov    %edx,%ebx
movsbl 0x0(%r13,%rbp,2),%edi
call   1040 <from_hex@plt>
mov    %eax,%r14d
shl    $0x4,%r14d
movsbl 0x1(%r13,%rbp,2),%edi
call   1040 <from_hex@plt>
or     %r14d,%eax
xor    0x10(%rsp,%rbx,1),%al
mov    %al,(%r12,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,0x8(%rsp)
jne    1170 <decrypt+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.decrypt.key = [8 x i8] c"EDUARDO\00"
define void @decrypt(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [8 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%12 = bitcast [8 x i8]* %5 to i8*
%13 = load i8*, i8** %3
store i8* %13, i8** %6
%14 = load i8*, i8** %4
store i8* %14, i8** %7
%15 = load i8*, i8** %6
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %8
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %9
store i32 0, i32* %10
br label %19
19: ; preds = %56, %2
%20 = load i32, i32* %10
%21 = load i32, i32* %8
%22 = sdiv i32 %21, 2
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %59
24: ; preds = %19
%25 = load i32, i32* %10
%26 = load i32, i32* %9
%27 = srem i32 %25, %26
store i32 %27, i32* %11
%28 = load i8*, i8** %6
%29 = load i32, i32* %10
%30 = mul nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @from_hex(i8 signext %33)
%35 = shl i32 %34, 4
%36 = load i8*, i8** %6
%37 = load i32, i32* %10
%38 = mul nsw i32 %37, 2
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %36, i64 %40
%42 = load i8, i8* %41
%43 = call i32 @from_hex(i8 signext %42)
%44 = or i32 %35, %43
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = xor i32 %44, %49
%51 = trunc i32 %50 to i8
%52 = load i8*, i8** %7
%53 = load i32, i32* %10
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 %51, i8* %55
br label %56
56: ; preds = %24
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
br label %19
59: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @decrypt(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to [8 x i8]*
%5 = bitcast i64* %3 to i8*
store i64 22311643234255941, i64* %3
%6 = tail call i32 @strlen(i8* %0)
%7 = call i32 @strlen(i8* %5)
%8 = icmp sgt i32 %6, 1
br i1 %8, label %9, label %34
9: ; preds = %2
%10 = lshr i32 %6, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %9, %12
%13 = phi i64 [ 0, %9 ], [ %32, %12 ]
%14 = trunc i64 %13 to i32
%15 = srem i32 %14, %7
%16 = shl nuw nsw i64 %13, 1
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @from_hex(i8 signext %18)
%20 = shl i32 %19, 4
%21 = or i64 %16, 1
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @from_hex(i8 signext %23)
%25 = or i32 %24, %20
%26 = zext i32 %15 to i64
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = trunc i32 %25 to i8
%30 = xor i8 %28, %29
%31 = getelementptr inbounds i8, i8* %1, i64 %13
store i8 %30, i8* %31
%32 = add nuw nsw i64 %13, 1
%33 = icmp eq i64 %32, %11
br i1 %33, label %34, label %12
34: ; preds = %12, %2
ret void
}