// File: /workspace/github_c_makefile_star2_O0/MersenneTwister-Lab[P]MTGP/mtgp64-fast.c
// Function: mtgp64_init_by_array
int mtgp64_init_by_array(mtgp64_fast_t *mtgp64,
			 const mtgp64_params_fast_t *para,
			 uint64_t *array, int length) {
    int i, j, count;
    uint64_t r;
    int lag;
    int mid;
    int size = para->mexp / 64 + 1;
    uint64_t hidden_seed;
    uint64_t tmp;
    mtgp64_status_fast_t *st;
    int rc;

    rc = alloc_state(mtgp64, para);
    if (rc) {
	return rc;
    }

    st = mtgp64->status;
    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[4] ^ (para->tbl[8] << 16);
    tmp = hidden_seed >> 32;
    tmp += tmp >> 16;
    tmp += tmp >> 8;
    memset(st->array, tmp & 0xff, sizeof(uint64_t) * size);
    mtgp64->params = *para;
    mtgp64->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 $0x118, %rsp            # imm = 0x118
movq %rdi, 0x108(%rsp)
movq %rsi, 0x100(%rsp)
movq %rdx, 0xf8(%rsp)
movl %ecx, 0xf4(%rsp)
movq 0x100(%rsp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, 0xd4(%rsp)
movq 0x108(%rsp), %rdi
movq 0x100(%rsp), %rsi
callq 0x1250
movl %eax, 0xb4(%rsp)
cmpl $0x0, 0xb4(%rsp)
je 0x14fb
movl 0xb4(%rsp), %eax
movl %eax, 0x114(%rsp)
jmp 0x1d51
movq 0x108(%rsp), %rax
movq 0x1b0(%rax), %rax
movq %rax, 0xb8(%rsp)
cmpl $0x26f, 0xd4(%rsp) # imm = 0x26F
jl 0x152c
movl $0xb, 0xdc(%rsp)
jmp 0x1569
cmpl $0x44, 0xd4(%rsp)
jl 0x1543
movl $0x7, 0xdc(%rsp)
jmp 0x1567
cmpl $0x27, 0xd4(%rsp)
jl 0x155a
movl $0x5, 0xdc(%rsp)
jmp 0x1565
movl $0x3, 0xdc(%rsp)
jmp 0x1567
jmp 0x1569
movl 0xd4(%rsp), %eax
subl 0xdc(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, 0xd8(%rsp)
movq 0x100(%rsp), %rax
movq 0x30(%rax), %rax
movq 0x100(%rsp), %rcx
movq 0x50(%rcx), %rcx
shlq $0x10, %rcx
xorq %rcx, %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
shrq $0x20, %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
shrq $0x10, %rax
addq 0xc0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
shrq $0x8, %rax
addq 0xc0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xb8(%rsp), %rdi
addq $0x10, %rdi
movq 0xc0(%rsp), %rax
andq $0xff, %rax
movslq 0xd4(%rsp), %rdx
shlq $0x3, %rdx
movzbl %al, %esi
callq 0x1070
movq 0x108(%rsp), %rdi
movq 0x100(%rsp), %rsi
movl $0x1b0, %edx            # imm = 0x1B0
callq 0x10a0
movq 0xb8(%rsp), %rcx
movq 0x108(%rsp), %rax
movq %rcx, 0x1b0(%rax)
movl 0xd4(%rsp), %ecx
movq 0xb8(%rsp), %rax
movl %ecx, 0x4(%rax)
movl 0xd4(%rsp), %ecx
subl $0x1, %ecx
movq 0xb8(%rsp), %rax
movl %ecx, (%rax)
movq 0xc8(%rsp), %rcx
movq 0xb8(%rsp), %rax
movq %rcx, 0x10(%rax)
movl 0xf4(%rsp), %eax
addl $0x1, %eax
cmpl 0xd4(%rsp), %eax
jle 0x16b8
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe8(%rsp)
jmp 0x16c6
movl 0xd4(%rsp), %eax
movl %eax, 0xe8(%rsp)
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0xb8(%rsp), %rax
movslq 0xd8(%rsp), %rcx
xorq 0x10(%rax,%rcx,8), %rdi
movq 0xb8(%rsp), %rax
movl 0xd4(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
xorq 0x10(%rax,%rcx,8), %rdi
callq 0x1d60
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rdx
movq 0xb8(%rsp), %rax
movslq 0xd8(%rsp), %rcx
addq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movslq 0xf4(%rsp), %rax
addq 0xe0(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl 0xd8(%rsp), %eax
addl 0xdc(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0xa0(%rsp), %rax
movl %edx, %ecx
movq 0xa8(%rsp), %rdx
movslq %ecx, %rcx
addq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movq 0xe0(%rsp), %rcx
movq 0xb8(%rsp), %rax
movq %rcx, 0x10(%rax)
movl $0x1, 0xf0(%rsp)
movl 0xe8(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xe8(%rsp)
movl $0x1, 0xf0(%rsp)
movl $0x0, 0xec(%rsp)
movl 0xec(%rsp), %ecx
xorl %eax, %eax
cmpl 0xe8(%rsp), %ecx
movb %al, 0x9f(%rsp)
jge 0x1814
movl 0xec(%rsp), %eax
cmpl 0xf4(%rsp), %eax
setl %al
movb %al, 0x9f(%rsp)
movb 0x9f(%rsp), %al
testb $0x1, %al
jne 0x1824
jmp 0x19cf
movq 0xb8(%rsp), %rax
movslq 0xf0(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rdi
movq 0xb8(%rsp), %rax
movq %rax, 0x68(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd8(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0x68(%rsp), %rax
movslq %edx, %rcx
xorq 0x10(%rax,%rcx,8), %rdi
movq 0xb8(%rsp), %rax
movq %rax, 0x70(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd4(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0xd4(%rsp)
movq 0x70(%rsp), %rax
movslq %edx, %rcx
xorq 0x10(%rax,%rcx,8), %rdi
callq 0x1d60
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x78(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd8(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0x78(%rsp), %rax
movl %edx, %ecx
movq 0x80(%rsp), %rdx
movslq %ecx, %rcx
addq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movq 0xf8(%rsp), %rax
movslq 0xec(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0xf0(%rsp), %rcx
addq %rcx, %rax
addq 0xe0(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x88(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd8(%rsp), %eax
addl 0xdc(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0x88(%rsp), %rax
movl %edx, %ecx
movq 0x90(%rsp), %rdx
movslq %ecx, %rcx
addq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movq 0xe0(%rsp), %rdx
movq 0xb8(%rsp), %rax
movslq 0xf0(%rsp), %rcx
movq %rdx, 0x10(%rax,%rcx,8)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0xd4(%rsp)
movl %edx, 0xf0(%rsp)
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x17e3
jmp 0x19d1
movl 0xec(%rsp), %eax
cmpl 0xe8(%rsp), %eax
jge 0x1b67
movq 0xb8(%rsp), %rax
movslq 0xf0(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rdi
movq 0xb8(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd8(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0x38(%rsp), %rax
movslq %edx, %rcx
xorq 0x10(%rax,%rcx,8), %rdi
movq 0xb8(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd4(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0xd4(%rsp)
movq 0x40(%rsp), %rax
movslq %edx, %rcx
xorq 0x10(%rax,%rcx,8), %rdi
callq 0x1d60
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x48(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd8(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0x48(%rsp), %rax
movl %edx, %ecx
movq 0x50(%rsp), %rdx
movslq %ecx, %rcx
addq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movslq 0xf0(%rsp), %rax
addq 0xe0(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x58(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd8(%rsp), %eax
addl 0xdc(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0x58(%rsp), %rax
movl %edx, %ecx
movq 0x60(%rsp), %rdx
movslq %ecx, %rcx
addq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movq 0xe0(%rsp), %rdx
movq 0xb8(%rsp), %rax
movslq 0xf0(%rsp), %rcx
movq %rdx, 0x10(%rax,%rcx,8)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0xd4(%rsp)
movl %edx, 0xf0(%rsp)
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x19d1
movl $0x0, 0xec(%rsp)
movl 0xec(%rsp), %eax
cmpl 0xd4(%rsp), %eax
jge 0x1d0b
movq 0xb8(%rsp), %rax
movslq 0xf0(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rdi
movq 0xb8(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd8(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0x8(%rsp), %rax
movslq %edx, %rcx
addq 0x10(%rax,%rcx,8), %rdi
movq 0xb8(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd4(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0xd4(%rsp)
movq 0x10(%rsp), %rax
movslq %edx, %rcx
addq 0x10(%rax,%rcx,8), %rdi
callq 0x1d90
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd8(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0x18(%rsp), %rax
movl %edx, %ecx
movq 0x20(%rsp), %rdx
movslq %ecx, %rcx
xorq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movslq 0xf0(%rsp), %rcx
movq 0xe0(%rsp), %rax
subq %rcx, %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0xf0(%rsp), %eax
addl 0xd8(%rsp), %eax
addl 0xdc(%rsp), %eax
cltd
idivl 0xd4(%rsp)
movq 0x28(%rsp), %rax
movl %edx, %ecx
movq 0x30(%rsp), %rdx
movslq %ecx, %rcx
xorq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movq 0xe0(%rsp), %rdx
movq 0xb8(%rsp), %rax
movslq 0xf0(%rsp), %rcx
movq %rdx, 0x10(%rax,%rcx,8)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0xd4(%rsp)
movl %edx, 0xf0(%rsp)
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x1b72
movq 0xb8(%rsp), %rax
movl 0xd4(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq $0x0, 0x10(%rax,%rcx,8)
jne 0x1d46
movq 0xb8(%rsp), %rax
movl 0xd4(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq $0x4d544750, 0x10(%rax,%rcx,8) # imm = 0x4D544750
movl $0x0, 0x114(%rsp)
movl 0x114(%rsp), %eax
addq $0x118, %rsp            # imm = 0x118
retq