// File: /workspace/github_c_makefile_star2_O1/ajpaulson[P]srogue11/xcrypt.c
// Function: des_init
static void des_init()
{
	int	i, j, b, k, inbit, obit;
	unsigned int	*p, *il, *ir, *fl, *fr;

	old_rawkey0 = old_rawkey1 = 0;
	saltbits = 0;
	old_salt = 0;
	bits24 = (bits28 = bits32 + 4) + 4;

	/*
	 * Invert the S-boxes, reordering the input bits.
	 */
	for (i = 0; i < 8; i++)
		for (j = 0; j < 64; j++) {
			b = (j & 0x20) | ((j & 1) << 4) | ((j >> 1) & 0xf);
			u_sbox[i][j] = sbox[i][b];
		}

	/*
	 * Convert the inverted S-boxes into 4 arrays of 8 bits.
	 * Each will handle 12 bits of the S-box input.
	 */
	for (b = 0; b < 4; b++)
		for (i = 0; i < 64; i++)
			for (j = 0; j < 64; j++)
				m_sbox[b][(i << 6) | j] =
					(u_sbox[(b << 1)][i] << 4) |
					u_sbox[(b << 1) + 1][j];

	/*
	 * Set up the initial & final permutations into a useful form, and
	 * initialise the inverted key permutation.
	 */
	for (i = 0; i < 64; i++) {
		init_perm[final_perm[i] = IP[i] - 1] = i;
		inv_key_perm[i] = 255;
	}

	/*
	 * Invert the key permutation and initialise the inverted key
	 * compression permutation.
	 */
	for (i = 0; i < 56; i++) {
		inv_key_perm[key_perm[i] - 1] = i;
		inv_comp_perm[i] = 255;
	}

	/*
	 * Invert the key compression permutation.
	 */
	for (i = 0; i < 48; i++) {
		inv_comp_perm[comp_perm[i] - 1] = i;
	}

	/*
	 * Set up the OR-mask arrays for the initial and final permutations,
	 * and for the key initial and compression permutations.
	 */
	for (k = 0; k < 8; k++) {
		for (i = 0; i < 256; i++) {
			*(il = &ip_maskl[k][i]) = 0;
			*(ir = &ip_maskr[k][i]) = 0;
			*(fl = &fp_maskl[k][i]) = 0;
			*(fr = &fp_maskr[k][i]) = 0;
			for (j = 0; j < 8; j++) {
				inbit = 8 * k + j;
				if (i & bits8[j]) {
					if ((obit = init_perm[inbit]) < 32)
						*il |= bits32[obit];
					else
						*ir |= bits32[obit-32];
					if ((obit = final_perm[inbit]) < 32)
						*fl |= bits32[obit];
					else
						*fr |= bits32[obit - 32];
				}
			}
		}
		for (i = 0; i < 128; i++) {
			*(il = &key_perm_maskl[k][i]) = 0;
			*(ir = &key_perm_maskr[k][i]) = 0;
			for (j = 0; j < 7; j++) {
				inbit = 8 * k + j;
				if (i & bits8[j + 1]) {
					if ((obit = inv_key_perm[inbit]) == 255)
						continue;
					if (obit < 28)
						*il |= bits28[obit];
					else
						*ir |= bits28[obit - 28];
				}
			}
			*(il = &comp_maskl[k][i]) = 0;
			*(ir = &comp_maskr[k][i]) = 0;
			for (j = 0; j < 7; j++) {
				inbit = 7 * k + j;
				if (i & bits8[j + 1]) {
					if ((obit=inv_comp_perm[inbit]) == 255)
						continue;
					if (obit < 24)
						*il |= bits24[obit];
					else
						*ir |= bits24[obit - 24];
				}
			}
		}
	}

	/*
	 * Invert the P-box permutation, and convert into OR-masks for
	 * handling the output of the S-box arrays setup above.
	 */
	for (i = 0; i < 32; i++)
		un_pbox[pbox[i] - 1] = i;

	for (b = 0; b < 4; b++)
		for (i = 0; i < 256; i++) {
			*(p = &psbox[b][i]) = 0;
			for (j = 0; j < 8; j++) {
				if (i & bits8[j])
					*p |= bits32[un_pbox[8 * b + j]];
			}
		}

	des_initialised = 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
xorl %eax, %eax
movl %eax, 0x15399(%rip)     # 0x3355c
movl %eax, 0x15397(%rip)     # 0x33560
movl %eax, 0x15395(%rip)     # 0x33564
movl %eax, 0x15393(%rip)     # 0x33568
leaq 0x15394(%rip), %rcx     # 0x33570
leaq 0x588d(%rip), %rdx      # 0x23a70
movq %rax, %rsi
shlq $0x6, %rsi
addq %rdx, %rsi
xorl %edi, %edi
xorl %r8d, %r8d
movl %r8d, %r9d
andl $0x20, %r9d
movl %edi, %r10d
andl $0x10, %r10d
orq %r9, %r10
movl %r8d, %r9d
shrl %r9d
andl $0xf, %r9d
orq %r10, %r9
movb (%rsi,%r9), %r9b
movb %r9b, (%rcx,%r8)
incq %r8
addq $0x10, %rdi
cmpq $0x40, %r8
jne 0x1e1f2
incq %rax
addq $0x40, %rcx
cmpq $0x8, %rax
jne 0x1e1e3
leaq 0x15377(%rip), %rax     # 0x335b0
leaq 0x15530(%rip), %rcx     # 0x33770
xorl %edx, %edx
leaq 0x15327(%rip), %rsi     # 0x33570
leaq (%rdx,%rdx), %rdi
shlq $0x6, %rdi
addq %rsi, %rdi
movq %rcx, %r8
xorl %r9d, %r9d
movb (%r9,%rdi), %r10b
shlb $0x4, %r10b
xorl %r11d, %r11d
movb (%rax,%r11), %bl
orb %r10b, %bl
movb %bl, (%r8,%r11)
incq %r11
cmpq $0x40, %r11
jne 0x1e265
incq %r9
addq $0x40, %r8
cmpq $0x40, %r9
jne 0x1e25a
incq %rdx
subq $-0x80, %rax
addq $0x1000, %rcx           # imm = 0x1000
cmpq $0x4, %rdx
jne 0x1e249
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x1957a(%rip)    # 0x37820
movdqa %xmm0, 0x19562(%rip)    # 0x37810
movdqa %xmm0, 0x1954a(%rip)    # 0x37800
movdqa %xmm0, 0x19532(%rip)    # 0x377f0
xorl %eax, %eax
leaq 0x59a9(%rip), %rsi      # 0x23c70
leaq 0x194e2(%rip), %rcx     # 0x377b0
leaq 0x1949b(%rip), %rdx     # 0x37770
movb (%rax,%rsi), %dil
decb %dil
movb %dil, (%rax,%rcx)
movzbl %dil, %edi
movb %al, (%rdi,%rdx)
incq %rax
cmpq $0x40, %rax
jne 0x1e2d5
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x19554(%rip)    # 0x37850
movdqa %xmm0, 0x1953c(%rip)    # 0x37840
movdqa %xmm0, 0x19524(%rip)    # 0x37830
movq $-0x1, 0x19549(%rip) # 0x37860
xorl %eax, %eax
leaq 0x5990(%rip), %rsi      # 0x23cb0
leaq 0x194c9(%rip), %rdi     # 0x377f0
movzbl (%rax,%rsi), %r8d
movb %al, -0x1(%r8,%rdi)
incq %rax
cmpq $0x38, %rax
jne 0x1e327
xorl %eax, %eax
leaq 0x59ad(%rip), %rsi      # 0x23cf0
leaq 0x194e6(%rip), %r8      # 0x37830
movzbl (%rax,%rsi), %r9d
movb %al, -0x1(%r9,%r8)
incq %rax
cmpq $0x30, %rax
jne 0x1e34a
movl $0xffffffe0, %r9d       # imm = 0xFFFFFFE0
xorl %r12d, %r12d
leaq 0x59b3(%rip), %rax      # 0x23d20
leaq 0x567c(%rip), %rsi      # 0x239f0
xorl %r13d, %r13d
xorl %ecx, %ecx
movq %rcx, -0x18(%rsp)
movq %rcx, %rdx
shlq $0xa, %rdx
leaq 0x194e4(%rip), %rcx     # 0x37870
addq %rdx, %rcx
movq %rcx, -0x28(%rsp)
leaq 0x1b4d5(%rip), %rcx     # 0x39870
addq %rdx, %rcx
movq %rcx, -0x8(%rsp)
leaq 0x1d4c6(%rip), %rcx     # 0x3b870
addq %rdx, %rcx
movq %rcx, -0x10(%rsp)
leaq 0x1f4b7(%rip), %rcx     # 0x3d870
addq %rcx, %rdx
movq %rdx, -0x20(%rsp)
xorl %ebp, %ebp
movq -0x28(%rsp), %rcx
leaq (%rcx,%rbp,4), %r11
movl %r12d, (%r11)
movq -0x8(%rsp), %rcx
leaq (%rcx,%rbp,4), %r10
movl %r12d, (%r10)
movq -0x10(%rsp), %rcx
leaq (%rcx,%rbp,4), %rbx
movl %r12d, (%rbx)
movq -0x20(%rsp), %rcx
leaq (%rcx,%rbp,4), %r15
movl %r12d, (%r15)
xorl %r14d, %r14d
movzbl (%r14,%rax), %r12d
testl %r12d, %ebp
je 0x1e44a
leaq (%r14,%r13), %r12
leaq 0x19365(%rip), %rcx     # 0x37770
movzbl (%rcx,%r12), %ecx
leal (%rcx,%r9), %edx
cmpl $0x20, %ecx
cmovbq %rcx, %rdx
movq %r10, %rcx
cmovbq %r11, %rcx
movl (%rsi,%rdx,4), %edx
orl %edx, (%rcx)
leaq 0x19382(%rip), %rcx     # 0x377b0
movzbl (%rcx,%r12), %ecx
leal (%rcx,%r9), %edx
cmpl $0x20, %ecx
cmovbq %rcx, %rdx
movq %r15, %rcx
cmovbq %rbx, %rcx
movl (%rsi,%rdx,4), %edx
orl %edx, (%rcx)
incq %r14
cmpq $0x8, %r14
jne 0x1e3f6
incq %rbp
cmpq $0x100, %rbp            # imm = 0x100
movl $0x0, %r12d
jne 0x1e3c3
movq -0x18(%rsp), %rbp
shlq $0x9, %rbp
leaq 0x213f7(%rip), %rcx     # 0x3f870
addq %rbp, %rcx
movq %rcx, -0x20(%rsp)
leaq 0x223e8(%rip), %rcx     # 0x40870
addq %rbp, %rcx
movq %rcx, -0x28(%rsp)
xorl %r11d, %r11d
movq -0x20(%rsp), %rcx
leaq (%rcx,%r11,4), %r10
movl %r12d, (%r10)
movq -0x28(%rsp), %rcx
leaq (%rcx,%r11,4), %rbx
movl %r12d, (%rbx)
xorl %r14d, %r14d
movzbl 0x1(%r14,%rax), %ecx
testl %ecx, %r11d
je 0x1e4ee
leaq (%r14,%r13), %rcx
movzbl (%rdi,%rcx), %r15d
cmpq $0xff, %r15
je 0x1e4ee
cmpb $0x1c, %r15b
leaq 0x54ba(%rip), %rcx      # 0x23990
leaq 0x5523(%rip), %rdx      # 0x23a00
cmovbq %rdx, %rcx
movq %rbx, %rdx
cmovbq %r10, %rdx
movl (%rcx,%r15,4), %ecx
orl %ecx, (%rdx)
incq %r14
cmpq $0x7, %r14
jne 0x1e4ae
leaq 0x23372(%rip), %rcx     # 0x41870
addq %rbp, %rcx
leaq (%rcx,%r11,4), %r10
movl %r12d, (%r10)
leaq 0x24361(%rip), %rcx     # 0x42870
addq %rbp, %rcx
leaq (%rcx,%r11,4), %rbx
movl %r12d, (%rbx)
xorl %r14d, %r14d
movzbl 0x1(%r14,%rax), %ecx
testl %ecx, %r11d
je 0x1e558
movzbl (%r8,%r14), %r15d
cmpq $0xff, %r15
je 0x1e558
cmpb $0x18, %r15b
leaq 0x5470(%rip), %rcx      # 0x239b0
leaq 0x54c9(%rip), %rdx      # 0x23a10
cmovbq %rdx, %rcx
movq %rbx, %rdx
cmovbq %r10, %rdx
movl (%rcx,%r15,4), %ecx
orl %ecx, (%rdx)
incq %r14
cmpq $0x7, %r14
jne 0x1e51c
incq %r11
cmpq $0x80, %r11
jne 0x1e493
movq -0x18(%rsp), %rcx
incq %rcx
addq $0x8, %r13
addq $0x7, %r8
cmpq $0x8, %rcx
jne 0x1e379
xorl %edx, %edx
leaq 0x579c(%rip), %rdi      # 0x23d30
leaq 0x252d5(%rip), %rcx     # 0x43870
movzbl (%rdx,%rdi), %r8d
movb %dl, -0x1(%r8,%rcx)
incq %rdx
cmpq $0x20, %rdx
jne 0x1e59b
xorl %edx, %edx
leaq 0x252d9(%rip), %rdi     # 0x43890
movq %rdx, %r8
shlq $0xa, %r8
addq %rdi, %r8
xorl %r9d, %r9d
leaq (%r8,%r9,4), %r10
movl $0x0, (%r10)
xorl %r11d, %r11d
movzbl (%r11,%rax), %ebx
testl %ebx, %r9d
je 0x1e5e7
movzbl (%rcx,%r11), %ebx
movl (%rsi,%rbx,4), %ebx
orl %ebx, (%r10)
incq %r11
cmpq $0x8, %r11
jne 0x1e5d2
incq %r9
cmpq $0x100, %r9             # imm = 0x100
jne 0x1e5c4
incq %rdx
addq $0x8, %rcx
cmpq $0x4, %rdx
jne 0x1e5b7
movb $0x1, 0x14f48(%rip)     # 0x33558
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq