#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*/ AF_merge(char *, char *, int, int);
int /*<<< orphan*/ AF_split(char *, char *, int, int);
scalar_t__ malloc(int);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int random();
int main(int argc, char **argv) {
  char data[10000];
  char recover[10000];
  char *buf;
  int i;
  buf = (char *)malloc(10000 * 3000);
  for (i = 0; i < 10000; i++)
    data[i] = (unsigned char)(random() % 256);
  AF_split(data, buf, 10000, 3000);
  AF_merge(buf, recover, 10000, 3000);
  printf("Data %sequal, should be equal\n",
         (memcmp(data, recover, 10000) ? "not " : ""));
  AF_split(data, buf, 10000, 3000);
  buf[random() % (10000 * 3000)] ^= 1 << (random() % 8);
  AF_merge(buf, recover, 10000, 3000);
  printf("Data %sequal, should be not equal\n",
         (memcmp(data, recover, 10000) ? "not " : ""));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1c9c380,%edi
call   1070 <malloc@plt>
mov    %rax,-0x4e38(%rbp)
movl   $0x0,-0x4e3c(%rbp)
cmpl   $0x2710,-0x4e3c(%rbp)
jge    11d7 <main+0x77>
mov    $0x0,%al
call   1060 <random@plt>
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
movslq -0x4e3c(%rbp),%rax
mov    %cl,-0x2720(%rbp,%rax,1)
mov    -0x4e3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e3c(%rbp)
jmp    1194 <main+0x34>
lea    -0x2720(%rbp),%rdi
mov    -0x4e38(%rbp),%rsi
mov    $0x2710,%edx
mov    $0xbb8,%ecx
call   1030 <AF_split@plt>
mov    -0x4e38(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
mov    $0x2710,%edx
mov    $0xbb8,%ecx
call   1080 <AF_merge@plt>
lea    -0x2720(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
mov    $0x2710,%edx
call   1050 <memcmp@plt>
mov    %rax,%rcx
lea    0xdeb(%rip),%rsi
lea    0xde5(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xdb7(%rip),%rdi
call   1040 <printf@plt>
lea    -0x2720(%rbp),%rdi
mov    -0x4e38(%rbp),%rsi
mov    $0x2710,%edx
mov    $0xbb8,%ecx
call   1030 <AF_split@plt>
mov    $0x0,%al
call   1060 <random@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x4e4c(%rbp)
mov    -0x4e38(%rbp),%rax
mov    %rax,-0x4e48(%rbp)
mov    $0x0,%al
call   1060 <random@plt>
mov    -0x4e4c(%rbp),%esi
mov    $0x1c9c380,%ecx
cltd
idiv   %ecx
mov    -0x4e48(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edx
xor    %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x4e38(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
mov    $0x2710,%edx
mov    $0xbb8,%ecx
call   1080 <AF_merge@plt>
lea    -0x2720(%rbp),%rdi
lea    -0x4e30(%rbp),%rsi
mov    $0x2710,%edx
call   1050 <memcmp@plt>
mov    %rax,%rcx
lea    0xd20(%rip),%rsi
lea    0xd1a(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xd10(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x4e50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4e28,%rsp
mov    $0x1c9c380,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <random@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x2710,%rbx
jne    1180 <main+0x20>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x2710,%edx
mov    $0xbb8,%ecx
call   1030 <AF_split@plt>
lea    0x2710(%rsp),%r15
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x2710,%edx
mov    $0xbb8,%ecx
call   1080 <AF_merge@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2710,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
lea    0xe38(%rip),%r13
lea    0xe32(%rip),%rbx
mov    %rbx,%rsi
cmove  %r13,%rsi
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x2710,%edx
mov    $0xbb8,%ecx
call   1030 <AF_split@plt>
xor    %eax,%eax
call   1060 <random@plt>
and    $0x7,%al
mov    $0x1,%ebp
mov    %eax,%ecx
shl    %cl,%ebp
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x4795319d,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x37,%rcx
add    %edx,%ecx
imul   $0x1c9c380,%ecx,%ecx
sub    %ecx,%eax
cltq
xor    %bpl,(%r12,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x2710,%edx
mov    $0xbb8,%ecx
call   1080 <AF_merge@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2710,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
cmove  %r13,%rbx
lea    0xd9f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x4e28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Data %sequal, should be equal\0A\00"
@.str.1 = [5 x i8] c"not \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [35 x i8] c"Data %sequal, should be not equal\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10000 x i8]
%7 = alloca [10000 x i8]
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i64 @malloc(i32 30000000)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %8
store i32 0, i32* %9
br label %12
12: ; preds = %22, %2
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 10000
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = call i32 (...) @random()
%17 = srem i32 %16, 256
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %15
%23 = load i32, i32* %9
%24 = add nsw i32 %23, 1
store i32 %24, i32* %9
br label %12
25: ; preds = %12
%26 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%27 = load i8*, i8** %8
%28 = call i32 @AF_split(i8* %26, i8* %27, i32 10000, i32 3000)
%29 = load i8*, i8** %8
%30 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%31 = call i32 @AF_merge(i8* %29, i8* %30, i32 10000, i32 3000)
%32 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%33 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%34 = call i64 @memcmp(i8* %32, i8* %33, i32 10000)
%35 = icmp ne i64 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%38 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%40 = load i8*, i8** %8
%41 = call i32 @AF_split(i8* %39, i8* %40, i32 10000, i32 3000)
%42 = call i32 (...) @random()
%43 = srem i32 %42, 8
%44 = shl i32 1, %43
%45 = load i8*, i8** %8
%46 = call i32 (...) @random()
%47 = srem i32 %46, 30000000
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = xor i32 %51, %44
%53 = trunc i32 %52 to i8
store i8 %53, i8* %49
%54 = load i8*, i8** %8
%55 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%56 = call i32 @AF_merge(i8* %54, i8* %55, i32 10000, i32 3000)
%57 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%58 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%59 = call i64 @memcmp(i8* %57, i8* %58, i32 10000)
%60 = icmp ne i64 %59, 0
%61 = zext i1 %60 to i64
%62 = select i1 %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%63 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Data %sequal, should be equal\0A\00"
@.str.1 = [5 x i8] c"not \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [35 x i8] c"Data %sequal, should be not equal\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10000 x i8]
%4 = alloca [10000 x i8]
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%7 = tail call i64 @malloc(i32 30000000)
br label %8
8: ; preds = %2, %8
%9 = phi i64 [ 0, %2 ], [ %13, %8 ]
%10 = tail call i32 (...) @random()
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 %9
store i8 %11, i8* %12
%13 = add nuw nsw i64 %9, 1
%14 = icmp eq i64 %13, 10000
br i1 %14, label %15, label %8
15: ; preds = %8
%16 = inttoptr i64 %7 to i8*
%17 = call i32 @AF_split(i8* %5, i8* %16, i32 10000, i32 3000)
%18 = call i32 @AF_merge(i8* %16, i8* %6, i32 10000, i32 3000)
%19 = call i64 @memcmp(i8* %5, i8* %6, i32 10000)
%20 = icmp eq i64 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @AF_split(i8* %5, i8* %16, i32 10000, i32 3000)
%24 = call i32 (...) @random()
%25 = and i32 %24, 7
%26 = shl nuw nsw i32 1, %25
%27 = call i32 (...) @random()
%28 = srem i32 %27, 30000000
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %16, i64 %29
%31 = load i8, i8* %30
%32 = trunc i32 %26 to i8
%33 = xor i8 %31, %32
store i8 %33, i8* %30
%34 = call i32 @AF_merge(i8* %16, i8* %6, i32 10000, i32 3000)
%35 = call i64 @memcmp(i8* %5, i8* %6, i32 10000)
%36 = icmp eq i64 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%38 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %37)
ret i32 0
}