// File: /workspace/github_c_makefile_star2_O3/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, 0x15493(%rip)     # 0x3355c
movl %eax, 0x15491(%rip)     # 0x33560
movl %eax, 0x1548f(%rip)     # 0x33564
movl %eax, 0x1548d(%rip)     # 0x33568
leaq 0x1548e(%rip), %rcx     # 0x33570
leaq 0x5a27(%rip), %rdx      # 0x23b10
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 0x1e0f8
incq %rax
addq $0x40, %rcx
cmpq $0x8, %rax
jne 0x1e0e9
leaq 0x15471(%rip), %rax     # 0x335b0
leaq 0x1562a(%rip), %rcx     # 0x33770
xorl %edx, %edx
leaq 0x15421(%rip), %rsi     # 0x33570
movdqa 0x58c9(%rip), %xmm0     # 0x23a20
leaq (%rdx,%rdx), %rdi
shlq $0x6, %rdi
addq %rsi, %rdi
movq %rcx, %r8
xorl %r9d, %r9d
movzbl (%r9,%rdi), %r10d
movd %r10d, %xmm1
punpcklbw %xmm1, %xmm1    # xmm1 = xmm1[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
psllw $0x4, %xmm1
pand %xmm0, %xmm1
xorl %r10d, %r10d
movdqa (%rax,%r10), %xmm2
por %xmm1, %xmm2
movdqa %xmm2, (%r8,%r10)
addq $0x10, %r10
cmpq $0x40, %r10
jne 0x1e18c
incq %r9
addq $0x40, %r8
cmpq $0x40, %r9
jne 0x1e168
incq %rdx
subq $-0x80, %rax
addq $0x1000, %rcx           # imm = 0x1000
cmpq $0x4, %rdx
jne 0x1e157
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x1964d(%rip)    # 0x37820
movdqa %xmm0, 0x19635(%rip)    # 0x37810
movdqa %xmm0, 0x1961d(%rip)    # 0x37800
movdqa %xmm0, 0x19605(%rip)    # 0x377f0
xorl %eax, %eax
leaq 0x5b1c(%rip), %rcx      # 0x23d10
leaq 0x195b5(%rip), %r9      # 0x377b0
leaq 0x1956e(%rip), %rsi     # 0x37770
movb (%rax,%rcx), %dl
decb %dl
movb %dl, (%rax,%r9)
movzbl %dl, %edx
movb %al, (%rdx,%rsi)
incq %rax
cmpq $0x40, %rax
jne 0x1e202
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x1962a(%rip)    # 0x37850
movdqa %xmm0, 0x19612(%rip)    # 0x37840
movdqa %xmm0, 0x195fa(%rip)    # 0x37830
movq $-0x1, 0x1961f(%rip) # 0x37860
xorl %eax, %eax
leaq 0x5b06(%rip), %rcx      # 0x23d50
leaq 0x1959f(%rip), %rsi     # 0x377f0
movzbl (%rax,%rcx), %edx
movb %al, -0x1(%rdx,%rsi)
incq %rax
cmpq $0x38, %rax
jne 0x1e251
xorl %eax, %eax
leaq 0x5b25(%rip), %rcx      # 0x23d90
leaq 0x195be(%rip), %r13     # 0x37830
movzbl (%rax,%rcx), %edx
movb %al, -0x1(%rdx,%r13)
incq %rax
cmpq $0x30, %rax
jne 0x1e272
xorl %r10d, %r10d
leaq 0x5b32(%rip), %rax      # 0x23dc0
leaq 0x57fb(%rip), %rcx      # 0x23a90
xorl %edx, %edx
movq %r13, -0x38(%rsp)
movq %rdx, -0x40(%rsp)
movq %rdx, %rsi
shlq $0xa, %rsi
leaq 0x195c1(%rip), %rdx     # 0x37870
addq %rsi, %rdx
movq %rdx, -0x20(%rsp)
leaq 0x1b5b2(%rip), %rdx     # 0x39870
addq %rsi, %rdx
movq %rdx, -0x28(%rsp)
leaq 0x1d5a3(%rip), %rdx     # 0x3b870
addq %rsi, %rdx
movq %rdx, -0x30(%rsp)
leaq 0x1f594(%rip), %rdx     # 0x3d870
addq %rdx, %rsi
movq %rsi, -0x18(%rsp)
xorl %ebp, %ebp
movq -0x20(%rsp), %rdx
leaq (%rdx,%rbp,4), %rdx
xorl %ebx, %ebx
movq %rdx, -0x8(%rsp)
movl %ebx, (%rdx)
movq -0x28(%rsp), %rdx
leaq (%rdx,%rbp,4), %rdx
movq %rdx, -0x10(%rsp)
movl %ebx, (%rdx)
movq -0x30(%rsp), %rdx
leaq (%rdx,%rbp,4), %r12
movl %ebx, (%r12)
movq -0x18(%rsp), %rdx
leaq (%rdx,%rbp,4), %r13
movl %ebx, (%r13)
xorl %r14d, %r14d
xorl %edx, %edx
xorl %esi, %esi
xorl %edi, %edi
movzbl (%rdi,%rax), %r8d
testl %r8d, %ebp
je 0x1e39a
movq %r9, %r11
leaq (%r10,%rdi), %r9
leaq 0x1942d(%rip), %r8      # 0x37770
movzbl (%r8,%r9), %r8d
cmpq $0x1f, %r8
ja 0x1e35c
orl (%rcx,%r8,4), %edx
movq -0x8(%rsp), %r8
movl %edx, (%r8)
jmp 0x1e371
movl $0xffffffe0, %r15d      # imm = 0xFFFFFFE0
addl %r15d, %r8d
orl (%rcx,%r8,4), %esi
movq -0x10(%rsp), %r8
movl %esi, (%r8)
movzbl (%r11,%r9), %r8d
movq %r11, %r9
cmpq $0x1f, %r8
ja 0x1e389
orl (%rcx,%r8,4), %ebx
movl %ebx, (%r12)
jmp 0x1e39a
movl $0xffffffe0, %r11d      # imm = 0xFFFFFFE0
addl %r11d, %r8d
orl (%rcx,%r8,4), %r14d
movl %r14d, (%r13)
incq %rdi
cmpq $0x8, %rdi
jne 0x1e32b
incq %rbp
cmpq $0x100, %rbp            # imm = 0x100
jne 0x1e2e6
xorl %r14d, %r14d
leaq 0x19433(%rip), %r12     # 0x377f0
movq -0x38(%rsp), %r13
leaq 0x214a7(%rip), %rbp     # 0x3f870
movq -0x40(%rsp), %rdx
shlq $0x9, %rdx
leaq (%rdx,%rbp), %rsi
leaq (%rsi,%r14,4), %rsi
xorl %edi, %edi
movl %edi, (%rsi)
leaq 0x2248b(%rip), %r8      # 0x40870
addq %rdx, %r8
leaq (%r8,%r14,4), %r11
movl %edi, (%r11)
xorl %ebx, %ebx
xorl %r15d, %r15d
movzbl 0x1(%r15,%rax), %r8d
testl %r8d, %r14d
je 0x1e428
leaq (%r10,%r15), %r8
movzbl (%r12,%r8), %r8d
cmpq $0xff, %r8
je 0x1e428
cmpb $0x1b, %r8b
ja 0x1e420
orl 0x10(%rcx,%r8,4), %edi
movl %edi, (%rsi)
jmp 0x1e428
orl -0x60(%rcx,%r8,4), %ebx
movl %ebx, (%r11)
incq %r15
cmpq $0x7, %r15
jne 0x1e3f4
leaq 0x23438(%rip), %rsi     # 0x41870
addq %rdx, %rsi
leaq (%rsi,%r14,4), %rsi
xorl %edi, %edi
movl %edi, (%rsi)
leaq 0x24426(%rip), %r8      # 0x42870
addq %r8, %rdx
leaq (%rdx,%r14,4), %rdx
movl %edi, (%rdx)
xorl %r11d, %r11d
xorl %ebx, %ebx
movzbl 0x1(%rbx,%rax), %r8d
testl %r8d, %r14d
je 0x1e489
movzbl (%r13,%rbx), %r8d
cmpq $0xff, %r8
je 0x1e489
cmpb $0x17, %r8b
ja 0x1e481
orl 0x20(%rcx,%r8,4), %edi
movl %edi, (%rsi)
jmp 0x1e489
orl -0x40(%rcx,%r8,4), %r11d
movl %r11d, (%rdx)
incq %rbx
cmpq $0x7, %rbx
jne 0x1e458
incq %r14
cmpq $0x80, %r14
movq -0x40(%rsp), %rdx
jne 0x1e3ce
incq %rdx
addq $0x8, %r10
addq $0x7, %r13
cmpq $0x8, %rdx
jne 0x1e297
xorl %esi, %esi
leaq 0x590b(%rip), %rdi      # 0x23dd0
leaq 0x253a4(%rip), %rdx     # 0x43870
movzbl (%rsi,%rdi), %r8d
movb %sil, -0x1(%r8,%rdx)
incq %rsi
cmpq $0x20, %rsi
jne 0x1e4cc
xorl %esi, %esi
leaq 0x253a8(%rip), %rdi     # 0x43890
movq %rsi, %r8
shlq $0xa, %r8
addq %rdi, %r8
xorl %r9d, %r9d
leaq (%r8,%r9,4), %r10
movl $0x0, (%r10)
xorl %r11d, %r11d
xorl %ebx, %ebx
movzbl (%rbx,%rax), %ebp
testl %ebp, %r9d
je 0x1e51a
movzbl (%rdx,%rbx), %r14d
orl (%rcx,%r14,4), %r11d
movl %r11d, (%r10)
incq %rbx
cmpq $0x8, %rbx
jne 0x1e505
incq %r9
cmpq $0x100, %r9             # imm = 0x100
jne 0x1e4f5
incq %rsi
addq $0x8, %rdx
cmpq $0x4, %rsi
jne 0x1e4e8
movb $0x1, 0x15015(%rip)     # 0x33558
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq