#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ free(unsigned int *);
unsigned int genrand_int32();
int /*<<< orphan*/ init_by_array(unsigned long *, unsigned int const);
scalar_t__ malloc(unsigned int const);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write_data_as_json_ui32(int /*<<< orphan*/ *, unsigned int *,
                                           unsigned int const);
void generate_ui32_array_seed(unsigned long *seed, const unsigned int nwords,
                              const unsigned int len, const char *name) {
  unsigned int *y;
  unsigned int i;
  FILE *f;
  y = (unsigned int *)malloc(len * sizeof(unsigned int));
  if (y == NULL) {
    printf("Error allocating memory.\n");
    exit(1);
  }
  init_by_array(seed, nwords);
  for (i = 0; i < len; i++) {
    y[i] = genrand_int32();
  }
  f = fopen(name, "w");
  if (f == NULL) {
    printf("Error opening file.\n");
    exit(1);
  }
  write_data_as_json_ui32(f, y, len);
  fclose(f);
  free(y);
}


x86 assembly (clang, -O0):
<generate_ui32_array_seed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d9 <generate_ui32_array_seed+0x49>
lea    0xe36(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1080 <init_by_array@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    1219 <generate_ui32_array_seed+0x89>
mov    $0x0,%al
call   1040 <genrand_int32@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ec <generate_ui32_array_seed+0x5c>
mov    -0x18(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    124e <generate_ui32_array_seed+0xbe>
lea    0xddd(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1070 <write_data_as_json_ui32@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_ui32_array_seed>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %edx,%r14d
mov    %esi,%r12d
mov    %rdi,%rbp
lea    0x0(,%r14,4),%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1238 <generate_ui32_array_seed+0xa8>
mov    %rax,%r13
mov    %rbp,%rdi
mov    %r12d,%esi
call   1080 <init_by_array@plt>
test   %r14d,%r14d
je     11f5 <generate_ui32_array_seed+0x65>
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <genrand_int32@plt>
mov    %eax,0x0(%r13,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11e0 <generate_ui32_array_seed+0x50>
lea    0xe04(%rip),%rsi
mov    %r15,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1241 <generate_ui32_array_seed+0xb1>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
call   1070 <write_data_as_json_ui32@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
lea    0xdd7(%rip),%rdi
jmp    1248 <generate_ui32_array_seed+0xb8>
lea    0xdba(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Error allocating memory.\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [21 x i8] c"Error opening file.\0A\00"
define void @generate_ui32_array_seed(i64* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32*
store i64* %0, i64** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%12 = load i32, i32* %7
%13 = zext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %9
%18 = load i32*, i32** %9
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %4
%21 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %4
%24 = load i64*, i64** %5
%25 = load i32, i32* %6
%26 = call i32 @init_by_array(i64* %24, i32 %25)
store i32 0, i32* %10
br label %27
27: ; preds = %37, %23
%28 = load i32, i32* %10
%29 = load i32, i32* %7
%30 = icmp ult i32 %28, %29
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = call i32 (...) @genrand_int32()
%33 = load i32*, i32** %9
%34 = load i32, i32* %10
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %32, i32* %36
br label %37
37: ; preds = %31
%38 = load i32, i32* %10
%39 = add i32 %38, 1
store i32 %39, i32* %10
br label %27
40: ; preds = %27
%41 = load i8*, i8** %8
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %42, i32** %11
%43 = load i32*, i32** %11
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %40
%49 = load i32*, i32** %11
%50 = load i32*, i32** %9
%51 = load i32, i32* %7
%52 = call i32 @write_data_as_json_ui32(i32* %49, i32* %50, i32 %51)
%53 = load i32*, i32** %11
%54 = call i32 @fclose(i32* %53)
%55 = load i32*, i32** %9
%56 = call i32 @free(i32* %55)
ret void
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"w\00"
@str = [20 x i8] c"Error opening file.\00"
@str.3 = [25 x i8] c"Error allocating memory.\00"
define void @generate_ui32_array_seed(i64* %0, i32 %1, i32 %2, i8* nocapture %3) {
%5 = shl i32 %2, 2
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i32*
%8 = icmp eq i64 %6, 0
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.3, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %4
%13 = tail call i32 @init_by_array(i64* %0, i32 %1)
%14 = icmp eq i32 %2, 0
br i1 %14, label %23, label %15
15: ; preds = %12
%16 = zext i32 %2 to i64
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %21, %17 ]
%19 = tail call i32 (...) @genrand_int32()
%20 = getelementptr inbounds i32, i32* %7, i64 %18
store i32 %19, i32* %20
%21 = add nuw nsw i64 %18, 1
%22 = icmp eq i64 %21, %16
br i1 %22, label %23, label %17
23: ; preds = %17, %12
%24 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %23
%30 = tail call i32 @write_data_as_json_ui32(i32* %24, i32* %7, i32 %2)
%31 = tail call i32 @fclose(i32* %24)
%32 = tail call i32 @free(i32* %7)
ret void
}