// File: /workspace/github_c_makefile_star2_O0/MersenneTwister-Lab[P]MTGP/mtgp32-ref.c
// Function: mtgp32_init_by_array
int mtgp32_init_by_array(mtgp32_ref_t *mtgp32,
			 const mtgp32_params_ref_t *para,
			 const uint32_t *array, int length) {
    int i, j, count;
    uint32_t r;
    int lag;
    int mid;
    int size = para->mexp / 32 + 1;
    uint32_t hidden_seed;
    uint32_t tmp;
    mtgp32_status_ref_t *st;

    st = (mtgp32_status_ref_t *)malloc(sizeof(mtgp32_status_ref_t)
				     + sizeof(uint32_t) * size);
    if (st == NULL) {
	return -1;
    }
    if (size >= 623) {
	lag = 11;
    } else if (size >= 68) {
	lag = 7;
    } else if (size >= 39) {
	lag = 5;
    } else {
	lag = 3;
    }
    mid = (size - lag) / 2;

    hidden_seed = para->tbl[2] ^ (para->tbl[3] << 16);
    tmp = hidden_seed;
    tmp += tmp >> 16;
    tmp += tmp >> 8;
    memset(st->array, tmp & 0xff, sizeof(uint32_t) * size);
    mtgp32->params = *para;
    mtgp32->status = st;
    st->size = size;
    st->idx = size - 1;
    st->array[0] = hidden_seed;

    if (length + 1 > size) {
	count = length + 1;
    } else {
	count = size;
    }
    r = ini_func1(st->array[0] ^ st->array[mid] ^ st->array[size - 1]);
    st->array[mid] += r;
    r += length;
    st->array[(mid + lag) % size] += r;
    st->array[0] = r;
    i = 1;
    count--;
    for (i = 1, j = 0; (j < count) && (j < length); j++) {
	r = ini_func1(st->array[i] ^ st->array[(i + mid) % size]
		      ^ st->array[(i + size - 1) % size]);
	st->array[(i + mid) % size] += r;
	r += array[j] + i;
	st->array[(i + mid + lag) % size] += r;
	st->array[i] = r;
	i = (i + 1) % size;
    }
    for (; j < count; j++) {
	r = ini_func1(st->array[i] ^ st->array[(i + mid) % size]
		      ^ st->array[(i + size - 1) % size]);
	st->array[(i + mid) % size] += r;
	r += i;
	st->array[(i + mid + lag) % size] += r;
	st->array[i] = r;
	i = (i + 1) % size;
    }
    for (j = 0; j < size; j++) {
	r = ini_func2(st->array[i] + st->array[(i + mid) % size]
		      + st->array[(i + size - 1) % size]);
	st->array[(i + mid) % size] ^= r;
	r -= i;
	st->array[(i + mid + lag) % size] ^= r;
	st->array[i] = r;
	i = (i + 1) % size;
    }
    if (st->array[size - 1] == 0) {
	st->array[size - 1] = non_zero;
    }
    return 0;
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xe8(%rsp)
movq %rsi, 0xe0(%rsp)
movq %rdx, 0xd8(%rsp)
movl %ecx, 0xd4(%rsp)
movq 0xe0(%rsp), %rax
movl (%rax), %eax
movl $0x20, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, 0xb8(%rsp)
movslq 0xb8(%rsp), %rdi
shlq $0x2, %rdi
addq $0x8, %rdi
callq 0x10b0
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0xa8(%rsp)
jne 0x13ba
movl $0xffffffff, 0xf4(%rsp) # imm = 0xFFFFFFFF
jmp 0x1b8e
cmpl $0x26f, 0xb8(%rsp) # imm = 0x26F
jl 0x13d4
movl $0xb, 0xc0(%rsp)
jmp 0x1411
cmpl $0x44, 0xb8(%rsp)
jl 0x13eb
movl $0x7, 0xc0(%rsp)
jmp 0x140f
cmpl $0x27, 0xb8(%rsp)
jl 0x1402
movl $0x5, 0xc0(%rsp)
jmp 0x140d
movl $0x3, 0xc0(%rsp)
jmp 0x140f
jmp 0x1411
movl 0xb8(%rsp), %eax
subl 0xc0(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, 0xbc(%rsp)
movq 0xe0(%rsp), %rax
movl 0x18(%rax), %eax
movq 0xe0(%rsp), %rcx
movl 0x1c(%rcx), %ecx
shll $0x10, %ecx
xorl %ecx, %eax
movl %eax, 0xb4(%rsp)
movl 0xb4(%rsp), %eax
movl %eax, 0xb0(%rsp)
movl 0xb0(%rsp), %eax
shrl $0x10, %eax
addl 0xb0(%rsp), %eax
movl %eax, 0xb0(%rsp)
movl 0xb0(%rsp), %eax
shrl $0x8, %eax
addl 0xb0(%rsp), %eax
movl %eax, 0xb0(%rsp)
movq 0xa8(%rsp), %rdi
addq $0x8, %rdi
movl 0xb0(%rsp), %eax
andl $0xff, %eax
movslq 0xb8(%rsp), %rdx
shlq $0x2, %rdx
movzbl %al, %esi
callq 0x1070
movq 0xe8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
movl $0x4c, %edx
callq 0x10a0
movq 0xa8(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq %rcx, 0x50(%rax)
movl 0xb8(%rsp), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, (%rax)
movl 0xb8(%rsp), %ecx
subl $0x1, %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x4(%rax)
movl 0xb4(%rsp), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x8(%rax)
movl 0xd4(%rsp), %eax
addl $0x1, %eax
cmpl 0xb8(%rsp), %eax
jle 0x1546
movl 0xd4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc8(%rsp)
jmp 0x1554
movl 0xb8(%rsp), %eax
movl %eax, 0xc8(%rsp)
movq 0xa8(%rsp), %rax
movl 0x8(%rax), %edi
movq 0xa8(%rsp), %rax
movslq 0xbc(%rsp), %rcx
xorl 0x8(%rax,%rcx,4), %edi
movq 0xa8(%rsp), %rax
movl 0xb8(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
xorl 0x8(%rax,%rcx,4), %edi
callq 0x1ba0
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %edx
movq 0xa8(%rsp), %rax
movslq 0xbc(%rsp), %rcx
addl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xd4(%rsp), %eax
addl 0xc4(%rsp), %eax
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0xa4(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movl 0xbc(%rsp), %eax
addl 0xc0(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x98(%rsp), %rax
movl %edx, %ecx
movl 0xa4(%rsp), %edx
movslq %ecx, %rcx
addl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xc4(%rsp), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x8(%rax)
movl $0x1, 0xd0(%rsp)
movl 0xc8(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xc8(%rsp)
movl $0x1, 0xd0(%rsp)
movl $0x0, 0xcc(%rsp)
movl 0xcc(%rsp), %ecx
xorl %eax, %eax
cmpl 0xc8(%rsp), %ecx
movb %al, 0x97(%rsp)
jge 0x1691
movl 0xcc(%rsp), %eax
cmpl 0xd4(%rsp), %eax
setl %al
movb %al, 0x97(%rsp)
movb 0x97(%rsp), %al
testb $0x1, %al
jne 0x16a1
jmp 0x1835
movq 0xa8(%rsp), %rax
movslq 0xd0(%rsp), %rcx
movl 0x8(%rax,%rcx,4), %edi
movq 0xa8(%rsp), %rax
movq %rax, 0x68(%rsp)
movl 0xd0(%rsp), %eax
addl 0xbc(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x68(%rsp), %rax
movslq %edx, %rcx
xorl 0x8(%rax,%rcx,4), %edi
movq 0xa8(%rsp), %rax
movq %rax, 0x70(%rsp)
movl 0xd0(%rsp), %eax
addl 0xb8(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0xb8(%rsp)
movq 0x70(%rsp), %rax
movslq %edx, %rcx
xorl 0x8(%rax,%rcx,4), %edi
callq 0x1ba0
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x84(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x78(%rsp)
movl 0xd0(%rsp), %eax
addl 0xbc(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x78(%rsp), %rax
movl %edx, %ecx
movl 0x84(%rsp), %edx
movslq %ecx, %rcx
addl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x8(%rax,%rcx,4)
movq 0xd8(%rsp), %rax
movslq 0xcc(%rsp), %rcx
movl (%rax,%rcx,4), %eax
addl 0xd0(%rsp), %eax
addl 0xc4(%rsp), %eax
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x90(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x88(%rsp)
movl 0xd0(%rsp), %eax
addl 0xbc(%rsp), %eax
addl 0xc0(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x88(%rsp), %rax
movl %edx, %ecx
movl 0x90(%rsp), %edx
movslq %ecx, %rcx
addl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xc4(%rsp), %edx
movq 0xa8(%rsp), %rax
movslq 0xd0(%rsp), %rcx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xd0(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0xb8(%rsp)
movl %edx, 0xd0(%rsp)
movl 0xcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xcc(%rsp)
jmp 0x1660
jmp 0x1837
movl 0xcc(%rsp), %eax
cmpl 0xc8(%rsp), %eax
jge 0x19ba
movq 0xa8(%rsp), %rax
movslq 0xd0(%rsp), %rcx
movl 0x8(%rax,%rcx,4), %edi
movq 0xa8(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0xd0(%rsp), %eax
addl 0xbc(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x38(%rsp), %rax
movslq %edx, %rcx
xorl 0x8(%rax,%rcx,4), %edi
movq 0xa8(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0xd0(%rsp), %eax
addl 0xb8(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0xb8(%rsp)
movq 0x40(%rsp), %rax
movslq %edx, %rcx
xorl 0x8(%rax,%rcx,4), %edi
callq 0x1ba0
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x54(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x48(%rsp)
movl 0xd0(%rsp), %eax
addl 0xbc(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x48(%rsp), %rax
movl %edx, %ecx
movl 0x54(%rsp), %edx
movslq %ecx, %rcx
addl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xd0(%rsp), %eax
addl 0xc4(%rsp), %eax
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x64(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x58(%rsp)
movl 0xd0(%rsp), %eax
addl 0xbc(%rsp), %eax
addl 0xc0(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x58(%rsp), %rax
movl %edx, %ecx
movl 0x64(%rsp), %edx
movslq %ecx, %rcx
addl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xc4(%rsp), %edx
movq 0xa8(%rsp), %rax
movslq 0xd0(%rsp), %rcx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xd0(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0xb8(%rsp)
movl %edx, 0xd0(%rsp)
movl 0xcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xcc(%rsp)
jmp 0x1837
movl $0x0, 0xcc(%rsp)
movl 0xcc(%rsp), %eax
cmpl 0xb8(%rsp), %eax
jge 0x1b4a
movq 0xa8(%rsp), %rax
movslq 0xd0(%rsp), %rcx
movl 0x8(%rax,%rcx,4), %edi
movq 0xa8(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0xd0(%rsp), %eax
addl 0xbc(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x8(%rsp), %rax
movslq %edx, %rcx
addl 0x8(%rax,%rcx,4), %edi
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0xd0(%rsp), %eax
addl 0xb8(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0xb8(%rsp)
movq 0x10(%rsp), %rax
movslq %edx, %rcx
addl 0x8(%rax,%rcx,4), %edi
callq 0x1bc0
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0xd0(%rsp), %eax
addl 0xbc(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x18(%rsp), %rax
movl %edx, %ecx
movl 0x24(%rsp), %edx
movslq %ecx, %rcx
xorl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xd0(%rsp), %ecx
movl 0xc4(%rsp), %eax
subl %ecx, %eax
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x34(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0xd0(%rsp), %eax
addl 0xbc(%rsp), %eax
addl 0xc0(%rsp), %eax
cltd
idivl 0xb8(%rsp)
movq 0x28(%rsp), %rax
movl %edx, %ecx
movl 0x34(%rsp), %edx
movslq %ecx, %rcx
xorl 0x8(%rax,%rcx,4), %edx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xc4(%rsp), %edx
movq 0xa8(%rsp), %rax
movslq 0xd0(%rsp), %rcx
movl %edx, 0x8(%rax,%rcx,4)
movl 0xd0(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0xb8(%rsp)
movl %edx, 0xd0(%rsp)
movl 0xcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xcc(%rsp)
jmp 0x19c5
movq 0xa8(%rsp), %rax
movl 0xb8(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, 0x8(%rax,%rcx,4)
jne 0x1b83
movq 0xa8(%rsp), %rax
movl 0xb8(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl $0x4d544750, 0x8(%rax,%rcx,4) # imm = 0x4D544750
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
addq $0xf8, %rsp
retq
nopl (%rax)