#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_genrand(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_integer_seed(const unsigned int seed, 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_genrand(seed);
  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_integer_seed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d5 <generate_ui32_integer_seed+0x45>
lea    0xe3a(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x4(%rbp),%edi
call   10a0 <init_genrand@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1211 <generate_ui32_integer_seed+0x81>
mov    $0x0,%al
call   1040 <genrand_int32@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e4 <generate_ui32_integer_seed+0x54>
mov    -0x10(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1246 <generate_ui32_integer_seed+0xb6>
lea    0xde5(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1070 <write_data_as_json_ui32@plt>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_ui32_integer_seed>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %esi,%r14d
mov    %edi,%ebp
lea    0x0(,%r14,4),%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1221 <generate_ui32_integer_seed+0x91>
mov    %rax,%r12
mov    %ebp,%edi
call   10a0 <init_genrand@plt>
test   %r14d,%r14d
je     11e4 <generate_ui32_integer_seed+0x54>
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <genrand_int32@plt>
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11d0 <generate_ui32_integer_seed+0x40>
lea    0xe15(%rip),%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     122a <generate_ui32_integer_seed+0x9a>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1070 <write_data_as_json_ui32@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
lea    0xdee(%rip),%rdi
jmp    1231 <generate_ui32_integer_seed+0xa1>
lea    0xdd1(%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_integer_seed(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%10 = load i32, i32* %5
%11 = zext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %7
%16 = load i32*, i32** %7
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %3
%22 = load i32, i32* %4
%23 = call i32 @init_genrand(i32 %22)
store i32 0, i32* %8
br label %24
24: ; preds = %34, %21
%25 = load i32, i32* %8
%26 = load i32, i32* %5
%27 = icmp ult i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = call i32 (...) @genrand_int32()
%30 = load i32*, i32** %7
%31 = load i32, i32* %8
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %29, i32* %33
br label %34
34: ; preds = %28
%35 = load i32, i32* %8
%36 = add i32 %35, 1
store i32 %36, i32* %8
br label %24
37: ; preds = %24
%38 = load i8*, i8** %6
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %9
%40 = load i32*, i32** %9
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %37
%46 = load i32*, i32** %9
%47 = load i32*, i32** %7
%48 = load i32, i32* %5
%49 = call i32 @write_data_as_json_ui32(i32* %46, i32* %47, i32 %48)
%50 = load i32*, i32** %9
%51 = call i32 @fclose(i32* %50)
%52 = load i32*, i32** %7
%53 = call i32 @free(i32* %52)
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_integer_seed(i32 %0, i32 %1, i8* nocapture %2) {
%4 = shl i32 %1, 2
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i32*
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.3, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %3
%12 = tail call i32 @init_genrand(i32 %0)
%13 = icmp eq i32 %1, 0
br i1 %13, label %22, label %14
14: ; preds = %11
%15 = zext i32 %1 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %20, %16 ]
%18 = tail call i32 (...) @genrand_int32()
%19 = getelementptr inbounds i32, i32* %6, i64 %17
store i32 %18, i32* %19
%20 = add nuw nsw i64 %17, 1
%21 = icmp eq i64 %20, %15
br i1 %21, label %22, label %16
22: ; preds = %16, %11
%23 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %22
%29 = tail call i32 @write_data_as_json_ui32(i32* %23, i32* %6, i32 %1)
%30 = tail call i32 @fclose(i32* %23)
%31 = tail call i32 @free(i32* %6)
ret void
}