// File: /workspace/github_cpp_makefile_star2_O3/JenTus[P]TCEM/src_TCEM/sfmt/SFMT.c
// Function: sfmt_init_by_array
void sfmt_init_by_array(sfmt_t * sfmt, uint32_t *init_key, int key_length) {
    int i, j, count;
    uint32_t r;
    int lag;
    int mid;
    int size = SFMT_N * 4;
    uint32_t *psfmt32 = &sfmt->state[0].u[0];

    if (size >= 623) {
	lag = 11;
    } else if (size >= 68) {
	lag = 7;
    } else if (size >= 39) {
	lag = 5;
    } else {
	lag = 3;
    }
    mid = (size - lag) / 2;

    memset(sfmt, 0x8b, sizeof(sfmt_t));
    if (key_length + 1 > SFMT_N32) {
	count = key_length + 1;
    } else {
	count = SFMT_N32;
    }
    r = func1(psfmt32[idxof(0)] ^ psfmt32[idxof(mid)]
	      ^ psfmt32[idxof(SFMT_N32 - 1)]);
    psfmt32[idxof(mid)] += r;
    r += key_length;
    psfmt32[idxof(mid + lag)] += r;
    psfmt32[idxof(0)] = r;

    count--;
    for (i = 1, j = 0; (j < count) && (j < key_length); j++) {
	r = func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % SFMT_N32)]
		  ^ psfmt32[idxof((i + SFMT_N32 - 1) % SFMT_N32)]);
	psfmt32[idxof((i + mid) % SFMT_N32)] += r;
	r += init_key[j] + i;
	psfmt32[idxof((i + mid + lag) % SFMT_N32)] += r;
	psfmt32[idxof(i)] = r;
	i = (i + 1) % SFMT_N32;
    }
    for (; j < count; j++) {
	r = func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % SFMT_N32)]
		  ^ psfmt32[idxof((i + SFMT_N32 - 1) % SFMT_N32)]);
	psfmt32[idxof((i + mid) % SFMT_N32)] += r;
	r += i;
	psfmt32[idxof((i + mid + lag) % SFMT_N32)] += r;
	psfmt32[idxof(i)] = r;
	i = (i + 1) % SFMT_N32;
    }
    for (j = 0; j < SFMT_N32; j++) {
	r = func2(psfmt32[idxof(i)] + psfmt32[idxof((i + mid) % SFMT_N32)]
		  + psfmt32[idxof((i + SFMT_N32 - 1) % SFMT_N32)]);
	psfmt32[idxof((i + mid) % SFMT_N32)] ^= r;
	r -= i;
	psfmt32[idxof((i + mid + lag) % SFMT_N32)] ^= r;
	psfmt32[idxof(i)] = r;
	i = (i + 1) % SFMT_N32;
    }

    sfmt->idx = SFMT_N32;
    period_certification(sfmt);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movl $0x9c8, %edx            # imm = 0x9C8
movl $0x8b, %esi
callq 0x3180
cmpl $0x270, %r14d           # imm = 0x270
movl $0x26f, %eax            # imm = 0x26F
cmovgel %r14d, %eax
movl $0xdd4afe5d, %ecx       # imm = 0xDD4AFE5D
movl %ecx, 0x4c8(%rbx)
leal 0x51bf72d2(%r14), %edx
addl %r14d, %ecx
movl %ecx, 0x4f4(%rbx)
movl %edx, (%rbx)
testl %r14d, %r14d
jle 0x10f8b
movl %r14d, %ecx
movl $0x1, %esi
xorl %edx, %edx
movslq %esi, %rsi
movl (%rbx,%rsi,4), %edi
leal 0x132(%rsi), %r8d
movslq %r8d, %r8
imulq $-0x2df2df2d, %r8, %r8  # imm = 0xD20D20D3
shrq $0x20, %r8
addl %esi, %r8d
addl $0x132, %r8d            # imm = 0x132
movl %r8d, %r9d
shrl $0x1f, %r9d
sarl $0x9, %r8d
addl %r9d, %r8d
imull $0x270, %r8d, %r8d      # imm = 0x270
leal 0x26f(%rsi), %r9d
movslq %r9d, %r9
imulq $-0x2df2df2d, %r9, %r9  # imm = 0xD20D20D3
negl %r8d
shrq $0x20, %r9
addl %esi, %r9d
addl $0x26f, %r9d            # imm = 0x26F
movl %r9d, %r10d
addl %esi, %r8d
addl $0x132, %r8d            # imm = 0x132
shrl $0x1f, %r10d
sarl $0x9, %r9d
addl %r10d, %r9d
movslq %r8d, %r8
imull $0x270, %r9d, %r9d      # imm = 0x270
negl %r9d
leal (%rsi,%r9), %r10d
addl $0x26f, %r10d           # imm = 0x26F
movl (%rbx,%r8,4), %r9d
movslq %r10d, %r10
xorl (%rbx,%r10,4), %edi
xorl %r9d, %edi
movl %edi, %r10d
shrl $0x1b, %r10d
xorl %edi, %r10d
imull $0x19660d, %r10d, %edi  # imm = 0x19660D
leal 0x13d(%rsi), %r10d
movslq %r10d, %r10
imulq $-0x2df2df2d, %r10, %r10 # imm = 0xD20D20D3
addl %edi, %r9d
shrq $0x20, %r10
addl %esi, %r10d
addl $0x13d, %r10d           # imm = 0x13D
movl %r10d, %r11d
shrl $0x1f, %r11d
sarl $0x9, %r10d
addl %r11d, %r10d
imull $0x270, %r10d, %r10d    # imm = 0x270
movl %r9d, (%rbx,%r8,4)
negl %r10d
leal (%rsi,%r10), %r8d
addl $0x13d, %r8d            # imm = 0x13D
movslq %r8d, %r8
movl (%r15,%rdx,4), %r9d
leal 0x1(%rsi), %r10d
movslq %r10d, %r10
imulq $-0x2df2df2d, %r10, %r10 # imm = 0xD20D20D3
addl %esi, %r9d
shrq $0x20, %r10
addl %esi, %r10d
incl %r10d
movl %r10d, %r11d
addl %edi, %r9d
shrl $0x1f, %r11d
addl %r9d, (%rbx,%r8,4)
sarl $0x9, %r10d
addl %r11d, %r10d
imull $0x270, %r10d, %edi     # imm = 0x270
movl %r9d, (%rbx,%rsi,4)
negl %edi
addl %edi, %esi
incl %esi
incq %rdx
cmpq %rdx, %rcx
jne 0x10e35
cmpl $0x26e, %r14d           # imm = 0x26E
jle 0x10f93
jmp 0x110ad
xorl %r14d, %r14d
movl $0x1, %esi
subl %r14d, %eax
movslq %esi, %rcx
movl (%rbx,%rcx,4), %edx
leal 0x132(%rcx), %esi
movslq %esi, %rsi
imulq $-0x2df2df2d, %rsi, %rsi # imm = 0xD20D20D3
shrq $0x20, %rsi
addl %ecx, %esi
addl $0x132, %esi            # imm = 0x132
movl %esi, %edi
shrl $0x1f, %edi
sarl $0x9, %esi
addl %edi, %esi
imull $0x270, %esi, %esi      # imm = 0x270
negl %esi
addl %ecx, %esi
addl $0x132, %esi            # imm = 0x132
movslq %esi, %rsi
movl (%rbx,%rsi,4), %edi
leal 0x26f(%rcx), %r8d
movslq %r8d, %r8
imulq $-0x2df2df2d, %r8, %r8  # imm = 0xD20D20D3
shrq $0x20, %r8
addl %ecx, %r8d
addl $0x26f, %r8d            # imm = 0x26F
movl %r8d, %r9d
shrl $0x1f, %r9d
sarl $0x9, %r8d
addl %r9d, %r8d
imull $0x270, %r8d, %r8d      # imm = 0x270
negl %r8d
addl %ecx, %r8d
addl $0x26f, %r8d            # imm = 0x26F
movslq %r8d, %r8
xorl (%rbx,%r8,4), %edx
xorl %edi, %edx
movl %edx, %r8d
shrl $0x1b, %r8d
xorl %edx, %r8d
imull $0x19660d, %r8d, %edx   # imm = 0x19660D
addl %edx, %edi
movl %edi, (%rbx,%rsi,4)
addl %ecx, %edx
leal 0x13d(%rcx), %esi
movslq %esi, %rsi
imulq $-0x2df2df2d, %rsi, %rsi # imm = 0xD20D20D3
shrq $0x20, %rsi
addl %ecx, %esi
addl $0x13d, %esi            # imm = 0x13D
movl %esi, %edi
shrl $0x1f, %edi
sarl $0x9, %esi
addl %edi, %esi
imull $0x270, %esi, %esi      # imm = 0x270
negl %esi
addl %ecx, %esi
addl $0x13d, %esi            # imm = 0x13D
movslq %esi, %rsi
addl %edx, (%rbx,%rsi,4)
movl %edx, (%rbx,%rcx,4)
leal 0x1(%rcx), %edx
movslq %edx, %rdx
imulq $-0x2df2df2d, %rdx, %rdx # imm = 0xD20D20D3
shrq $0x20, %rdx
addl %ecx, %edx
incl %edx
movl %edx, %esi
shrl $0x1f, %esi
sarl $0x9, %edx
addl %esi, %edx
imull $0x270, %edx, %edx      # imm = 0x270
negl %edx
leal (%rcx,%rdx), %esi
incl %esi
decl %eax
jne 0x10f96
movl $0x270, %eax            # imm = 0x270
movslq %esi, %rcx
leal 0x132(%rcx), %edx
movslq %edx, %rdx
imulq $-0x2df2df2d, %rdx, %rdx # imm = 0xD20D20D3
shrq $0x20, %rdx
addl %ecx, %edx
addl $0x132, %edx            # imm = 0x132
movl %edx, %esi
shrl $0x1f, %esi
sarl $0x9, %edx
addl %esi, %edx
imull $0x270, %edx, %edx      # imm = 0x270
negl %edx
addl %ecx, %edx
addl $0x132, %edx            # imm = 0x132
movslq %edx, %rdx
movl (%rbx,%rdx,4), %esi
movl (%rbx,%rcx,4), %edi
addl %esi, %edi
leal 0x26f(%rcx), %r8d
movslq %r8d, %r8
imulq $-0x2df2df2d, %r8, %r8  # imm = 0xD20D20D3
shrq $0x20, %r8
addl %ecx, %r8d
addl $0x26f, %r8d            # imm = 0x26F
movl %r8d, %r9d
shrl $0x1f, %r9d
sarl $0x9, %r8d
addl %r9d, %r8d
imull $0x270, %r8d, %r8d      # imm = 0x270
negl %r8d
addl %ecx, %r8d
addl $0x26f, %r8d            # imm = 0x26F
movslq %r8d, %r8
addl (%rbx,%r8,4), %edi
movl %edi, %r8d
shrl $0x1b, %r8d
xorl %edi, %r8d
imull $0x5d588b65, %r8d, %edi # imm = 0x5D588B65
xorl %edi, %esi
movl %esi, (%rbx,%rdx,4)
subl %ecx, %edi
leal 0x13d(%rcx), %edx
movslq %edx, %rdx
imulq $-0x2df2df2d, %rdx, %rdx # imm = 0xD20D20D3
shrq $0x20, %rdx
addl %ecx, %edx
addl $0x13d, %edx            # imm = 0x13D
movl %edx, %esi
shrl $0x1f, %esi
sarl $0x9, %edx
addl %esi, %edx
imull $0x270, %edx, %edx      # imm = 0x270
negl %edx
addl %ecx, %edx
addl $0x13d, %edx            # imm = 0x13D
movslq %edx, %rdx
xorl %edi, (%rbx,%rdx,4)
movl %edi, (%rbx,%rcx,4)
leal 0x1(%rcx), %edx
movslq %edx, %rdx
imulq $-0x2df2df2d, %rdx, %rdx # imm = 0xD20D20D3
shrq $0x20, %rdx
addl %ecx, %edx
incl %edx
movl %edx, %esi
shrl $0x1f, %esi
sarl $0x9, %edx
addl %esi, %edx
imull $0x270, %edx, %edx      # imm = 0x270
negl %edx
leal (%rcx,%rdx), %esi
incl %esi
decl %eax
jne 0x110b2
movl $0x270, 0x9c0(%rbx)     # imm = 0x270
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x10d9e