#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*/ exit(int);
int /*<<< orphan*/ free(unsigned int *);
int /*<<< orphan*/ generate(unsigned int *, unsigned int *, unsigned int,
                            char *);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rand_array_ui32(unsigned int *, unsigned int,
                                   int /*<<< orphan*/, int);
int main(void) {
  unsigned int len;
  unsigned int *a;
  unsigned int *b;
  len = 5000;
  a = (unsigned int *)malloc(len * sizeof(unsigned int));
  if (a == NULL) {
    printf("Error allocating memory.\n");
    exit(1);
  }
  b = (unsigned int *)malloc(len * sizeof(unsigned int));
  if (b == NULL) {
    printf("Error allocating memory.\n");
    exit(1);
  }
  rand_array_ui32(a, len, 0, 4294967295);
  rand_array_ui32(b, len, 0, 4294967295);
  generate(a, b, len, "data.json");
  free(a);
  free(b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1388,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a9 <main+0x49>
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11dc <main+0x7c>
lea    0xe33(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
xor    %edx,%edx
mov    $0xffffffff,%ecx
call   1040 <rand_array_ui32@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
xor    %edx,%edx
mov    $0xffffffff,%ecx
call   1040 <rand_array_ui32@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xe06(%rip),%rcx
call   1080 <generate@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x4e20,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11e1 <main+0x81>
mov    %rax,%r14
mov    $0x4e20,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11e1 <main+0x81>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1388,%esi
xor    %edx,%edx
mov    $0xffffffff,%ecx
call   1050 <rand_array_ui32@plt>
mov    %rbx,%rdi
mov    $0x1388,%esi
xor    %edx,%edx
mov    $0xffffffff,%ecx
call   1050 <rand_array_ui32@plt>
lea    0xe49(%rip),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1388,%edx
call   1080 <generate@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe22(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Error allocating memory.\0A\00"
@.str.1 = [10 x i8] c"data.json\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
store i32 0, i32* %1
store i32 5000, i32* %2
%5 = load i32, i32* %2
%6 = zext i32 %5 to i64
%7 = mul i64 %6, 4
%8 = trunc i64 %7 to i32
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = load i32, i32* %2
%18 = zext i32 %17 to i64
%19 = mul i64 %18, 4
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %4
%23 = load i32*, i32** %4
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %28
25: ; preds = %16
%26 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %16
%29 = load i32*, i32** %3
%30 = load i32, i32* %2
%31 = call i32 @rand_array_ui32(i32* %29, i32 %30, i32 0, i32 -1)
%32 = load i32*, i32** %4
%33 = load i32, i32* %2
%34 = call i32 @rand_array_ui32(i32* %32, i32 %33, i32 0, i32 -1)
%35 = load i32*, i32** %3
%36 = load i32*, i32** %4
%37 = load i32, i32* %2
%38 = call i32 @generate(i32* %35, i32* %36, i32 %37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32*, i32** %3
%40 = call i32 @free(i32* %39)
%41 = load i32*, i32** %4
%42 = call i32 @free(i32* %41)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"data.json\00"
@str.2 = [25 x i8] c"Error allocating memory.\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 20000)
%2 = inttoptr i64 %1 to i32*
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.2, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i64 @malloc(i32 20000)
%9 = inttoptr i64 %8 to i32*
%10 = icmp eq i64 %8, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.2, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7
%15 = tail call i32 @rand_array_ui32(i32* %2, i32 5000, i32 0, i32 -1)
%16 = tail call i32 @rand_array_ui32(i32* %9, i32 5000, i32 0, i32 -1)
%17 = tail call i32 @generate(i32* %2, i32* %9, i32 5000, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @free(i32* %2)
%19 = tail call i32 @free(i32* %9)
ret i32 0
}