// File: /workspace/github_c_makefile_star2_O0/MersenneTwister-Lab[P]MTGP/mtgp64-ref.c
// Function: mtgp64_init_by_array
int mtgp64_init_by_array(mtgp64_ref_t *mtgp64,
			 const mtgp64_params_ref_t *para,
			 const 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_ref_t *st;

    st = (mtgp64_status_ref_t *)malloc(sizeof(mtgp64_status_ref_t)
				     + sizeof(uint64_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 >> 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 $0x108, %rsp            # imm = 0x108
movq %rdi, 0xf8(%rsp)
movq %rsi, 0xf0(%rsp)
movq %rdx, 0xe8(%rsp)
movl %ecx, 0xe4(%rsp)
movq 0xf0(%rsp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
movslq 0xc4(%rsp), %rdi
shlq $0x3, %rdi
addq $0x8, %rdi
callq 0x10b0
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0xa8(%rsp)
jne 0x13ea
movl $0xffffffff, 0x104(%rsp) # imm = 0xFFFFFFFF
jmp 0x1c1e
cmpl $0x26f, 0xc4(%rsp) # imm = 0x26F
jl 0x1404
movl $0xb, 0xcc(%rsp)
jmp 0x1441
cmpl $0x44, 0xc4(%rsp)
jl 0x141b
movl $0x7, 0xcc(%rsp)
jmp 0x143f
cmpl $0x27, 0xc4(%rsp)
jl 0x1432
movl $0x5, 0xcc(%rsp)
jmp 0x143d
movl $0x3, 0xcc(%rsp)
jmp 0x143f
jmp 0x1441
movl 0xc4(%rsp), %eax
subl 0xcc(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, 0xc8(%rsp)
movq 0xf0(%rsp), %rax
movq 0x20(%rax), %rax
movq 0xf0(%rsp), %rcx
movq 0x28(%rcx), %rcx
shlq $0x10, %rcx
xorq %rcx, %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
shrq $0x20, %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
shrq $0x10, %rax
addq 0xb0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
shrq $0x8, %rax
addq 0xb0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xa8(%rsp), %rdi
addq $0x8, %rdi
movq 0xb0(%rsp), %rax
andq $0xff, %rax
movslq 0xc4(%rsp), %rdx
shlq $0x3, %rdx
movzbl %al, %esi
callq 0x1070
movq 0xf8(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movl $0x70, %edx
callq 0x10a0
movq 0xa8(%rsp), %rcx
movq 0xf8(%rsp), %rax
movq %rcx, 0x70(%rax)
movl 0xc4(%rsp), %ecx
movq 0xa8(%rsp), %rax
movl %ecx, (%rax)
movl 0xc4(%rsp), %ecx
subl $0x1, %ecx
movq 0xa8(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0xb8(%rsp), %rcx
movq 0xa8(%rsp), %rax
movq %rcx, 0x8(%rax)
movl 0xe4(%rsp), %eax
addl $0x1, %eax
cmpl 0xc4(%rsp), %eax
jle 0x158d
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd8(%rsp)
jmp 0x159b
movl 0xc4(%rsp), %eax
movl %eax, 0xd8(%rsp)
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0xa8(%rsp), %rax
movslq 0xc8(%rsp), %rcx
xorq 0x8(%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rax
movl 0xc4(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
xorq 0x8(%rax,%rcx,8), %rdi
callq 0x1c30
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rdx
movq 0xa8(%rsp), %rax
movslq 0xc8(%rsp), %rcx
addq 0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x8(%rax,%rcx,8)
movslq 0xe4(%rsp), %rax
addq 0xd0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movl 0xc8(%rsp), %eax
addl 0xcc(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq 0x98(%rsp), %rax
movl %edx, %ecx
movq 0xa0(%rsp), %rdx
movslq %ecx, %rcx
addq 0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x8(%rax,%rcx,8)
movq 0xd0(%rsp), %rcx
movq 0xa8(%rsp), %rax
movq %rcx, 0x8(%rax)
movl $0x1, 0xe0(%rsp)
movl 0xd8(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xd8(%rsp)
movl $0x1, 0xe0(%rsp)
movl $0x0, 0xdc(%rsp)
movl 0xdc(%rsp), %ecx
xorl %eax, %eax
cmpl 0xd8(%rsp), %ecx
movb %al, 0x97(%rsp)
jge 0x16e9
movl 0xdc(%rsp), %eax
cmpl 0xe4(%rsp), %eax
setl %al
movb %al, 0x97(%rsp)
movb 0x97(%rsp), %al
testb $0x1, %al
jne 0x16f9
jmp 0x189e
movq 0xa8(%rsp), %rax
movslq 0xe0(%rsp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rax
movq %rax, 0x60(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc8(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq 0x60(%rsp), %rax
movslq %edx, %rcx
xorq 0x8(%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rax
movq %rax, 0x68(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc4(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0xc4(%rsp)
movq 0x68(%rsp), %rax
movslq %edx, %rcx
xorq 0x8(%rax,%rcx,8), %rdi
callq 0x1c30
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x70(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc8(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq 0x70(%rsp), %rax
movl %edx, %ecx
movq 0x78(%rsp), %rdx
movslq %ecx, %rcx
addq 0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x8(%rax,%rcx,8)
movq 0xe8(%rsp), %rax
movslq 0xdc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0xe0(%rsp), %rcx
addq %rcx, %rax
addq 0xd0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x80(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc8(%rsp), %eax
addl 0xcc(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq 0x80(%rsp), %rax
movl %edx, %ecx
movq 0x88(%rsp), %rdx
movslq %ecx, %rcx
addq 0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x8(%rax,%rcx,8)
movq 0xd0(%rsp), %rdx
movq 0xa8(%rsp), %rax
movslq 0xe0(%rsp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movl 0xe0(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0xc4(%rsp)
movl %edx, 0xe0(%rsp)
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdc(%rsp)
jmp 0x16b8
jmp 0x18a0
movl 0xdc(%rsp), %eax
cmpl 0xd8(%rsp), %eax
jge 0x1a36
movq 0xa8(%rsp), %rax
movslq 0xe0(%rsp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc8(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq 0x30(%rsp), %rax
movslq %edx, %rcx
xorq 0x8(%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc4(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0xc4(%rsp)
movq 0x38(%rsp), %rax
movslq %edx, %rcx
xorq 0x8(%rax,%rcx,8), %rdi
callq 0x1c30
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc8(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq 0x40(%rsp), %rax
movl %edx, %ecx
movq 0x48(%rsp), %rdx
movslq %ecx, %rcx
addq 0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x8(%rax,%rcx,8)
movslq 0xe0(%rsp), %rax
addq 0xd0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc8(%rsp), %eax
addl 0xcc(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq 0x50(%rsp), %rax
movl %edx, %ecx
movq 0x58(%rsp), %rdx
movslq %ecx, %rcx
addq 0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x8(%rax,%rcx,8)
movq 0xd0(%rsp), %rdx
movq 0xa8(%rsp), %rax
movslq 0xe0(%rsp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movl 0xe0(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0xc4(%rsp)
movl %edx, 0xe0(%rsp)
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdc(%rsp)
jmp 0x18a0
movl $0x0, 0xdc(%rsp)
movl 0xdc(%rsp), %eax
cmpl 0xc4(%rsp), %eax
jge 0x1bd8
movq 0xa8(%rsp), %rax
movslq 0xe0(%rsp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rax
movq %rax, (%rsp)
movl 0xe0(%rsp), %eax
addl 0xc8(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq (%rsp), %rax
movslq %edx, %rcx
addq 0x8(%rax,%rcx,8), %rdi
movq 0xa8(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc4(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0xc4(%rsp)
movq 0x8(%rsp), %rax
movslq %edx, %rcx
addq 0x8(%rax,%rcx,8), %rdi
callq 0x1c60
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc8(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq 0x10(%rsp), %rax
movl %edx, %ecx
movq 0x18(%rsp), %rdx
movslq %ecx, %rcx
xorq 0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x8(%rax,%rcx,8)
movslq 0xe0(%rsp), %rcx
movq 0xd0(%rsp), %rax
subq %rcx, %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0xe0(%rsp), %eax
addl 0xc8(%rsp), %eax
addl 0xcc(%rsp), %eax
cltd
idivl 0xc4(%rsp)
movq 0x20(%rsp), %rax
movl %edx, %ecx
movq 0x28(%rsp), %rdx
movslq %ecx, %rcx
xorq 0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x8(%rax,%rcx,8)
movq 0xd0(%rsp), %rdx
movq 0xa8(%rsp), %rax
movslq 0xe0(%rsp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movl 0xe0(%rsp), %eax
addl $0x1, %eax
cltd
idivl 0xc4(%rsp)
movl %edx, 0xe0(%rsp)
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdc(%rsp)
jmp 0x1a41
movq 0xa8(%rsp), %rax
movl 0xc4(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq $0x0, 0x8(%rax,%rcx,8)
jne 0x1c13
movq 0xa8(%rsp), %rax
movl 0xc4(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq $0x4d544750, 0x8(%rax,%rcx,8) # imm = 0x4D544750
movl $0x0, 0x104(%rsp)
movl 0x104(%rsp), %eax
addq $0x108, %rsp            # imm = 0x108
retq
nopl (%rax)