#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 */
char decrypt_binaire(int *);
void *malloc(int);
char *decrypt(int *tableau) {
  int *binaire1 = malloc(5 * sizeof(int));
  int *binaire2 = malloc(5 * sizeof(int));
  int i;
  int j = 0;
  for (i = 0; i < 10; ++i) {
    if (i <= 4) {
      binaire1[i] = tableau[i];
    } else if (i > 4) {
      binaire2[j] = tableau[i];
      j++;
    }
  }
  char *msg = malloc(2 * sizeof(char));
  msg[0] = decrypt_binaire(binaire1);
  msg[1] = decrypt_binaire(binaire2);
  return msg;
}


x86 assembly (clang, -O0):
<decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    11c6 <decrypt+0xa6>
cmpl   $0x4,-0x1c(%rbp)
jg     1185 <decrypt+0x65>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11b3 <decrypt+0x93>
cmpl   $0x4,-0x1c(%rbp)
jle    11ae <decrypt+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b3 <decrypt+0x93>
jmp    11b8 <decrypt+0x98>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1156 <decrypt+0x36>
mov    $0x2,%edi
call   1030 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <decrypt_binaire@plt>
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rdi
call   1040 <decrypt_binaire@plt>
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    %rax,%r15
movups (%rbx),%xmm0
movups %xmm0,(%r14)
mov    0x10(%rbx),%eax
mov    %eax,0x10(%r14)
movups 0x14(%rbx),%xmm0
movups %xmm0,(%r15)
mov    0x24(%rbx),%eax
mov    %eax,0x10(%r15)
mov    $0x2,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <decrypt_binaire@plt>
mov    %al,(%rbx)
mov    %r15,%rdi
call   1040 <decrypt_binaire@plt>
mov    %al,0x1(%rbx)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define noalias i8* @decrypt(i32* nocapture %0) {
%2 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%3 = bitcast i8* %2 to i32*
%4 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%5 = bitcast i8* %4 to i32*
%6 = bitcast i32* %0 to <4 x i32>*
%7 = load <4 x i32>, <4 x i32>* %6
%8 = bitcast i8* %2 to <4 x i32>*
store <4 x i32> %7, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %0, i64 4
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %3, i64 4
store i32 %10, i32* %11
%12 = getelementptr inbounds i32, i32* %0, i64 5
%13 = bitcast i32* %12 to <4 x i32>*
%14 = load <4 x i32>, <4 x i32>* %13
%15 = bitcast i8* %4 to <4 x i32>*
store <4 x i32> %14, <4 x i32>* %15
%16 = getelementptr inbounds i32, i32* %0, i64 9
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %5, i64 4
store i32 %17, i32* %18
%19 = tail call dereferenceable_or_null(2) i8* @malloc(i32 2)
%20 = tail call signext i8 @decrypt_binaire(i32* %3)
store i8 %20, i8* %19
%21 = tail call signext i8 @decrypt_binaire(i32* %5)
%22 = getelementptr inbounds i8, i8* %19, i64 1
store i8 %21, i8* %22
ret i8* %19
}