#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*/ momrand_genrand_int32();
double momrand_genrand_real2();
int /*<<< orphan*/ momrand_init_by_array(unsigned long *, unsigned long);
int /*<<< orphan*/ printf(char *, ...);
int momrand_main_mt19937ar(void) {
  int i;
  unsigned long init[4] = {0x123, 0x234, 0x345, 0x456}, length = 4;
  momrand_init_by_array(init, length);
  printf("1000 outputs of genrand_int32()\n");
  for (i = 0; i < 1000; i++) {
    printf("%10lu ", momrand_genrand_int32());
    if (i % 5 == 4)
      printf("\n");
  }
  printf("\n1000 outputs of genrand_real2()\n");
  for (i = 0; i < 1000; i++) {
    printf("%10.8f ", momrand_genrand_real2());
    if (i % 5 == 4)
      printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<momrand_main_mt19937ar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea8(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x4,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <momrand_init_by_array@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    11f7 <momrand_main_mt19937ar+0xb7>
mov    $0x0,%al
call   1040 <momrand_genrand_int32@plt>
mov    %eax,%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x4,%edx
jne    11e4 <momrand_main_mt19937ar+0xa4>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e9 <momrand_main_mt19937ar+0xa9>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    119e <momrand_main_mt19937ar+0x5e>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    1263 <momrand_main_mt19937ar+0x123>
mov    $0x0,%al
call   1060 <momrand_genrand_real2@plt>
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x4,%edx
jne    1250 <momrand_main_mt19937ar+0x110>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1255 <momrand_main_mt19937ar+0x115>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    120c <momrand_main_mt19937ar+0xcc>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<momrand_main_mt19937ar>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe83(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x4,%esi
call   1070 <momrand_init_by_array@plt>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7f(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11be <momrand_main_mt19937ar+0x5e>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
add    $0x1,%ebp
cmp    $0xfffffc18,%ebx
je     11fb <momrand_main_mt19937ar+0x9b>
movzwl %bp,%eax
imul   $0xcccd,%eax,%eax
shr    $0x12,%eax
lea    (%rax,%rax,4),%eax
mov    $0xfffffffc,%r15d
sub    %eax,%r15d
xor    %eax,%eax
call   1060 <momrand_genrand_int32@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %bx,%r15w
jne    11b0 <momrand_main_mt19937ar+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11b0 <momrand_main_mt19937ar+0x50>
lea    0xe4d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe19(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    122e <momrand_main_mt19937ar+0xce>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0xffffffff,%ebx
add    $0x1,%ebp
cmp    $0xfffffc18,%ebx
je     1269 <momrand_main_mt19937ar+0x109>
movzwl %bp,%eax
imul   $0xcccd,%eax,%eax
shr    $0x12,%eax
lea    (%rax,%rax,4),%eax
mov    $0xfffffffc,%r15d
sub    %eax,%r15d
xor    %eax,%eax
call   1080 <momrand_genrand_real2@plt>
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
cmp    %bx,%r15w
jne    1220 <momrand_main_mt19937ar+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1220 <momrand_main_mt19937ar+0xc0>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.momrand_main_mt19937ar.init = [4 x i64] [i64 291, i64 564, i64 837, i64 1110]
@.str = [33 x i8] c"1000 outputs of genrand_int32()\0A\00"
@.str.1 = [7 x i8] c"%10lu \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [34 x i8] c"\0A1000 outputs of genrand_real2()\0A\00"
@.str.4 = [8 x i8] c"%10.8f \00"
define i32 @momrand_main_mt19937ar() {
%1 = alloca i32
%2 = alloca [4 x i64]
%3 = alloca i64
%4 = bitcast [4 x i64]* %2 to i8*
store i64 4, i64* %3
%5 = getelementptr inbounds [4 x i64], [4 x i64]* %2, i64 0, i64 0
%6 = load i64, i64* %3
%7 = call i32 @momrand_init_by_array(i64* %5, i64 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %9
9: ; preds = %21, %0
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1000
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = call i32 (...) @momrand_genrand_int32()
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = srem i32 %15, 5
%17 = icmp eq i32 %16, 4
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %12
br label %21
21: ; preds = %20
%22 = load i32, i32* %1
%23 = add nsw i32 %22, 1
store i32 %23, i32* %1
br label %9
24: ; preds = %9
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %26
26: ; preds = %38, %24
%27 = load i32, i32* %1
%28 = icmp slt i32 %27, 1000
br i1 %28, label %29, label %41
29: ; preds = %26
%30 = call double (...) @momrand_genrand_real2()
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %30)
%32 = load i32, i32* %1
%33 = srem i32 %32, 5
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %29
br label %38
38: ; preds = %37
%39 = load i32, i32* %1
%40 = add nsw i32 %39, 1
store i32 %40, i32* %1
br label %26
41: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@__const.momrand_main_mt19937ar.init = [4 x i64] [i64 291, i64 564, i64 837, i64 1110]
@.str.1 = [7 x i8] c"%10lu \00"
@.str.4 = [8 x i8] c"%10.8f \00"
@str = [32 x i8] c"1000 outputs of genrand_int32()\00"
@str.5 = [33 x i8] c"\0A1000 outputs of genrand_real2()\00"
define i32 @momrand_main_mt19937ar() {
%1 = alloca [4 x i64]
%2 = bitcast [4 x i64]* %1 to i8*
%3 = getelementptr inbounds [4 x i64], [4 x i64]* %1, i64 0, i64 0
%4 = call i32 @momrand_init_by_array(i64* %3, i64 4)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %6
6: ; preds = %0, %15
%7 = phi i32 [ 0, %0 ], [ %16, %15 ]
%8 = call i32 (...) @momrand_genrand_int32()
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = trunc i32 %7 to i16
%11 = urem i16 %10, 5
%12 = icmp eq i16 %11, 4
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = call i32 @putchar(i32 10)
br label %15
15: ; preds = %6, %13
%16 = add nuw nsw i32 %7, 1
%17 = icmp eq i32 %16, 1000
br i1 %17, label %18, label %6
18: ; preds = %15
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %29
%21 = phi i32 [ 0, %18 ], [ %30, %29 ]
%22 = call double (...) @momrand_genrand_real2()
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %22)
%24 = trunc i32 %21 to i16
%25 = urem i16 %24, 5
%26 = icmp eq i16 %25, 4
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = call i32 @putchar(i32 10)
br label %29
29: ; preds = %20, %27
%30 = add nuw nsw i32 %21, 1
%31 = icmp eq i32 %30, 1000
br i1 %31, label %32, label %20
32: ; preds = %29
ret i32 0
}