// File: CK7[P]abawaca/src/TinyMT-src-1.0.1/tinymt/tinymt32.c
// Function: tinymt32_init_by_array(TINYMT32_T*, unsigned int*, int)
void tinymt32_init_by_array(tinymt32_t * random, uint32_t init_key[],
			    int key_length) {
    const int lag = 1;
    const int mid = 1;
    const int size = 4;
    int i, j;
    int count;
    uint32_t r;
    uint32_t * st = &random->status[0];

    st[0] = 0;
    st[1] = random->mat1;
    st[2] = random->mat2;
    st[3] = random->tmat;
    if (key_length + 1 > MIN_LOOP) {
	count = key_length + 1;
    } else {
	count = MIN_LOOP;
    }
    r = ini_func1(st[0] ^ st[mid % size]
		  ^ st[(size - 1) % size]);
    st[mid % size] += r;
    r += key_length;
    st[(mid + lag) % size] += r;
    st[0] = r;
    count--;
    for (i = 1, j = 0; (j < count) && (j < key_length); j++) {
	r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
	st[(i + mid) % size] += r;
	r += init_key[j] + i;
	st[(i + mid + lag) % size] += r;
	st[i] = r;
	i = (i + 1) % size;
    }
    for (; j < count; j++) {
	r = ini_func1(st[i] ^ st[(i + mid) % size] ^ st[(i + size - 1) % size]);
	st[(i + mid) % size] += r;
	r += i;
	st[(i + mid + lag) % size] += r;
	st[i] = r;
	i = (i + 1) % size;
    }
    for (j = 0; j < size; j++) {
	r = ini_func2(st[i] + st[(i + mid) % size] + st[(i + size - 1) % size]);
	st[(i + mid) % size] ^= r;
	r -= i;
	st[(i + mid + lag) % size] ^= r;
	st[i] = r;
	i = (i + 1) % size;
    }
    period_certification(random);
    for (i = 0; i < PRE_LOOP; i++) {
	tinymt32_next_state(random);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x1, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movl $0x4, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
cmpl $0x8, %eax
jle 0x11fdd
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x11fe4
movl $0x8, -0x2c(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %edi
movq -0x38(%rbp), %rax
xorl 0x4(%rax), %edi
movq -0x38(%rbp), %rax
xorl 0xc(%rax), %edi
callq 0x123c0
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %ecx
movq -0x38(%rbp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movl -0x14(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %ecx
movq -0x38(%rbp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movl -0x30(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
movl $0x1, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %ecx
xorl %eax, %eax
cmpl -0x2c(%rbp), %ecx
movb %al, -0x39(%rbp)
jge 0x1205c
movl -0x28(%rbp), %eax
cmpl -0x14(%rbp), %eax
setl %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x12068
jmp 0x1215e
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0x68(%rbp), %rax
movslq %edx, %rcx
xorl (%rax,%rcx,4), %edi
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x24(%rbp), %eax
addl $0x4, %eax
subl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0x60(%rbp), %rax
movslq %edx, %rcx
xorl (%rax,%rcx,4), %edi
callq 0x123c0
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0x58(%rbp), %rax
movl %edx, %ecx
movl -0x4c(%rbp), %edx
movslq %ecx, %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0x24(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0x48(%rbp), %rax
movl %edx, %ecx
movl -0x40(%rbp), %edx
movslq %ecx, %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %edx
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %edx, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x12043
jmp 0x12160
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x12269
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x38(%rbp), %rax
movq %rax, -0x98(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0x98(%rbp), %rax
movslq %edx, %rcx
xorl (%rax,%rcx,4), %edi
movq -0x38(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x24(%rbp), %eax
addl $0x4, %eax
subl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0x90(%rbp), %rax
movslq %edx, %rcx
xorl (%rax,%rcx,4), %edi
callq 0x123c0
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0x88(%rbp), %rax
movl %edx, %ecx
movl -0x7c(%rbp), %edx
movslq %ecx, %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0x78(%rbp), %rax
movl %edx, %ecx
movl -0x6c(%rbp), %edx
movslq %ecx, %rcx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %edx
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %edx, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x12160
movl $0x0, -0x28(%rbp)
cmpl $0x4, -0x28(%rbp)
jge 0x1238b
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x38(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0xc8(%rbp), %rax
movslq %edx, %rcx
addl (%rax,%rcx,4), %edi
movq -0x38(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x24(%rbp), %eax
addl $0x4, %eax
subl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0xc0(%rbp), %rax
movslq %edx, %rcx
addl (%rax,%rcx,4), %edi
callq 0x123e0
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0xb8(%rbp), %rax
movl %edx, %ecx
movl -0xac(%rbp), %edx
movslq %ecx, %rcx
xorl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movq -0xa8(%rbp), %rax
movl %edx, %ecx
movl -0x9c(%rbp), %edx
movslq %ecx, %rcx
xorl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %edx
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %edx, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x12270
movq -0x8(%rbp), %rdi
callq 0x11e30
movl $0x0, -0x24(%rbp)
cmpl $0x8, -0x24(%rbp)
jge 0x123b5
movq -0x8(%rbp), %rdi
callq 0x11ea0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1239b
addq $0xd0, %rsp
popq %rbp
retq
nop