#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 /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(unsigned long const);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ t_mixdecrypt(unsigned int, unsigned char *, unsigned char *,
                                unsigned long const, unsigned char const *,
                                unsigned char const *);
void unsliceunmix(unsigned int thr, const unsigned char *fragdata,
                  unsigned char *out, const unsigned long size,
                  const unsigned char *key, const unsigned char *iv) {
  unsigned int fragoffset, readoffset, writeoffset;
  unsigned char *temp = malloc(size);
  readoffset = 0;
  for (fragoffset = 0; fragoffset < (4 * 1024); fragoffset += 4) {
    for (writeoffset = fragoffset; writeoffset < size;
         writeoffset += (4 * 1024)) {
      memcpy(temp + writeoffset, fragdata + readoffset, 4);
      readoffset += 4;
    }
  }
  t_mixdecrypt(thr, temp, out, size, key, iv);
  free(temp);
}


x86 assembly (clang, -O0):
<unsliceunmix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x1000,-0x34(%rbp)
jae    11e4 <unsliceunmix+0xa4>
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x20(%rbp),%rax
jae    11d1 <unsliceunmix+0x91>
mov    -0x48(%rbp),%rdi
mov    -0x3c(%rbp),%eax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x38(%rbp),%eax
add    %rax,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    -0x38(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1000,%eax
mov    %eax,-0x3c(%rbp)
jmp    118d <unsliceunmix+0x4d>
jmp    11d6 <unsliceunmix+0x96>
mov    -0x34(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x34(%rbp)
jmp    117a <unsliceunmix+0x3a>
mov    -0x4(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1040 <t_mixdecrypt@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unsliceunmix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,0x18(%rsp)
mov    %rcx,%rbx
mov    %rdx,0x10(%rsp)
mov    %rsi,%r14
mov    %edi,0xc(%rsp)
mov    %rcx,%rdi
call   1060 <malloc@plt>
mov    %rax,%r13
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    1190 <unsliceunmix+0x50>
nopl   0x0(%rax)
lea    0x4(%rbp),%rax
cmp    $0xffc,%rbp
mov    %rax,%rbp
jae    11c6 <unsliceunmix+0x86>
cmp    %rbx,%rbp
jae    1180 <unsliceunmix+0x40>
mov    %rbp,%r15
nopl   0x0(%rax,%rax,1)
lea    (%r15,%r13,1),%rdi
mov    %r12d,%esi
add    %r14,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
add    $0x4,%r12d
add    $0x1000,%r15d
cmp    %rbx,%r15
jb     11a0 <unsliceunmix+0x60>
jmp    1180 <unsliceunmix+0x40>
mov    0xc(%rsp),%edi
mov    %r13,%rsi
mov    0x10(%rsp),%rdx
mov    %rbx,%rcx
mov    0x18(%rsp),%r8
mov    0x20(%rsp),%r9
call   1040 <t_mixdecrypt@plt>
mov    %r13,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @unsliceunmix(i32 %0, i8* %1, i8* %2, i64 %3, i8* %4, i8* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
store i32 %0, i32* %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%17 = load i64, i64* %10
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %16
store i32 0, i32* %14
store i32 0, i32* %13
br label %19
19: ; preds = %45, %6
%20 = load i32, i32* %13
%21 = icmp ult i32 %20, 4096
br i1 %21, label %22, label %48
22: ; preds = %19
%23 = load i32, i32* %13
store i32 %23, i32* %15
br label %24
24: ; preds = %41, %22
%25 = load i32, i32* %15
%26 = zext i32 %25 to i64
%27 = load i64, i64* %10
%28 = icmp ult i64 %26, %27
br i1 %28, label %29, label %44
29: ; preds = %24
%30 = load i8*, i8** %16
%31 = load i32, i32* %15
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8*, i8** %8
%35 = load i32, i32* %14
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = call i32 @memcpy(i8* %33, i8* %37, i32 4)
%39 = load i32, i32* %14
%40 = add i32 %39, 4
store i32 %40, i32* %14
br label %41
41: ; preds = %29
%42 = load i32, i32* %15
%43 = add i32 %42, 4096
store i32 %43, i32* %15
br label %24
44: ; preds = %24
br label %45
45: ; preds = %44
%46 = load i32, i32* %13
%47 = add i32 %46, 4
store i32 %47, i32* %13
br label %19
48: ; preds = %19
%49 = load i32, i32* %7
%50 = load i8*, i8** %16
%51 = load i8*, i8** %9
%52 = load i64, i64* %10
%53 = load i8*, i8** %11
%54 = load i8*, i8** %12
%55 = call i32 @t_mixdecrypt(i32 %49, i8* %50, i8* %51, i64 %52, i8* %53, i8* %54)
%56 = load i8*, i8** %16
%57 = call i32 @free(i8* %56)
ret void
}

LLVM IR (-O2):
define void @unsliceunmix(i32 %0, i8* %1, i8* %2, i64 %3, i8* %4, i8* %5) {
%7 = tail call i8* @malloc(i64 %3)
br label %8
8: ; preds = %6, %23
%9 = phi i64 [ 0, %6 ], [ %25, %23 ]
%10 = phi i32 [ 0, %6 ], [ %24, %23 ]
%11 = icmp ult i64 %9, %3
br i1 %11, label %12, label %23
12: ; preds = %8, %12
%13 = phi i64 [ %21, %12 ], [ %9, %8 ]
%14 = phi i32 [ %19, %12 ], [ %10, %8 ]
%15 = getelementptr inbounds i8, i8* %7, i64 %13
%16 = zext i32 %14 to i64
%17 = getelementptr inbounds i8, i8* %1, i64 %16
%18 = tail call i32 @memcpy(i8* %15, i8* %17, i32 4)
%19 = add i32 %14, 4
%20 = add nuw i64 %13, 4096
%21 = and i64 %20, 4294967295
%22 = icmp ult i64 %21, %3
br i1 %22, label %12, label %23
23: ; preds = %12, %8
%24 = phi i32 [ %10, %8 ], [ %19, %12 ]
%25 = add nuw nsw i64 %9, 4
%26 = icmp ult i64 %9, 4092
br i1 %26, label %8, label %27
27: ; preds = %23
%28 = tail call i32 @t_mixdecrypt(i32 %0, i8* %7, i8* %2, i64 %3, i8* %4, i8* %5)
%29 = tail call i32 @free(i8* %7)
ret void
}