// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %r8d
movq %rdi, %rbx
movl 0x10(%rdi), %eax
movl 0x18(%rdi), %ecx
movl %ecx, 0xc(%rdi)
xorl %eax, %ecx
movl %ecx, %edx
shrl $0x1b, %edx
xorl %ecx, %edx
imull $0x19660d, %edx, %ecx   # imm = 0x19660D
addl %ecx, %eax
movl %eax, 0x4(%rdi)
addl %r8d, %ecx
movl 0x14(%rdi), %eax
addl %ecx, %eax
movl %eax, 0x8(%rdi)
movl %ecx, (%rdi)
xorl %r10d, %r10d
testl %r8d, %r8d
movl $0x0, %r9d
cmovgl %r8d, %r9d
pushq $0x1
popq %rcx
pushq $0x4
popq %rdi
cmpq %r10, %r9
je 0x8e08
movslq %ecx, %r11
movl (%rbx,%r11,4), %r14d
leal 0x1(%r11), %eax
cltd
idivl %edi
movl %edx, %ecx
movslq %edx, %r15
movl (%rbx,%r15,4), %r12d
leal 0x3(%r11), %eax
cltd
idivl %edi
movslq %edx, %rax
xorl (%rbx,%rax,4), %r14d
xorl %r12d, %r14d
movl %r14d, %eax
shrl $0x1b, %eax
xorl %r14d, %eax
imull $0x19660d, %eax, %eax   # imm = 0x19660D
addl %eax, %r12d
movl %r12d, (%rbx,%r15,4)
movl (%rsi,%r10,4), %r14d
addl %r11d, %r14d
addl %eax, %r14d
leal 0x2(%r11), %eax
cltd
idivl %edi
movslq %edx, %rax
addl %r14d, (%rbx,%rax,4)
movl %r14d, (%rbx,%r11,4)
incq %r10
jmp 0x8da4
cmpl $0x8, %r8d
pushq $0x7
popq %rsi
cmovgel %r8d, %esi
cmpl %esi, %r9d
jae 0x8e71
movslq %ecx, %r8
movl (%rbx,%r8,4), %r10d
leal 0x1(%r8), %eax
cltd
idivl %edi
movl %edx, %ecx
movslq %edx, %r11
movl (%rbx,%r11,4), %r14d
leal 0x3(%r8), %eax
cltd
idivl %edi
movslq %edx, %rax
xorl (%rbx,%rax,4), %r10d
xorl %r14d, %r10d
movl %r10d, %eax
shrl $0x1b, %eax
xorl %r10d, %eax
imull $0x19660d, %eax, %r10d  # imm = 0x19660D
addl %r10d, %r14d
movl %r14d, (%rbx,%r11,4)
addl %r8d, %r10d
leal 0x2(%r8), %eax
cltd
idivl %edi
movslq %edx, %rax
addl %r10d, (%rbx,%rax,4)
movl %r10d, (%rbx,%r8,4)
incl %r9d
jmp 0x8e13
movl %edi, %esi
subl $0x1, %esi
jb 0x8ece
movslq %ecx, %r8
leal 0x1(%r8), %eax
cltd
idivl %edi
movl %edx, %ecx
movslq %edx, %r9
movl (%rbx,%r9,4), %r10d
movl (%rbx,%r8,4), %r11d
addl %r10d, %r11d
leal 0x3(%r8), %eax
cltd
idivl %edi
movslq %edx, %rax
addl (%rbx,%rax,4), %r11d
movl %r11d, %eax
shrl $0x1b, %eax
xorl %r11d, %eax
imull $0x5d588b65, %eax, %r11d # imm = 0x5D588B65
xorl %r11d, %r10d
movl %r10d, (%rbx,%r9,4)
subl %r8d, %r11d
leal 0x2(%r8), %eax
cltd
idivl %edi
movslq %edx, %rax
xorl %r11d, (%rbx,%rax,4)
movl %r11d, (%rbx,%r8,4)
jmp 0x8e73
movq %rbx, %rdi
callq 0x8cda
pushq $0x8
popq %r14
subl $0x1, %r14d
jb 0x8eea
movq %rbx, %rdi
callq 0x8d05
jmp 0x8eda
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop