// File: /workspace/github_c_makefile_star2_O0/ajpaulson[P]srogue11/xcrypt.c
// Function: des_setkey
static int des_setkey(const char *key)
{
	unsigned int k0, k1, rawkey0, rawkey1;
	int	shifts, round;

	if (!des_initialised)
		des_init();

	rawkey0 = ntohl(*(unsigned int *) key);
	rawkey1 = ntohl(*(unsigned int *) (key + 4));

	if ((rawkey0 | rawkey1)
	    && rawkey0 == old_rawkey0
	    && rawkey1 == old_rawkey1) {
		/*
		 * Already setup for this key.
		 * This optimisation fails on a zero key (which is weak and
		 * has bad parity anyway) in order to simplify the starting
		 * conditions.
		 */
		return(0);
	}
	old_rawkey0 = rawkey0;
	old_rawkey1 = rawkey1;

	/*
	 *	Do key permutation and split into two 28-bit subkeys.
	 */
	k0 = key_perm_maskl[0][rawkey0 >> 25]
	   | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f]
	   | key_perm_maskl[2][(rawkey0 >> 9) & 0x7f]
	   | key_perm_maskl[3][(rawkey0 >> 1) & 0x7f]
	   | key_perm_maskl[4][rawkey1 >> 25]
	   | key_perm_maskl[5][(rawkey1 >> 17) & 0x7f]
	   | key_perm_maskl[6][(rawkey1 >> 9) & 0x7f]
	   | key_perm_maskl[7][(rawkey1 >> 1) & 0x7f];
	k1 = key_perm_maskr[0][rawkey0 >> 25]
	   | key_perm_maskr[1][(rawkey0 >> 17) & 0x7f]
	   | key_perm_maskr[2][(rawkey0 >> 9) & 0x7f]
	   | key_perm_maskr[3][(rawkey0 >> 1) & 0x7f]
	   | key_perm_maskr[4][rawkey1 >> 25]
	   | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f]
	   | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f]
	   | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f];
	/*
	 *	Rotate subkeys and do compression permutation.
	 */
	shifts = 0;
	for (round = 0; round < 16; round++) {
		unsigned int	t0, t1;

		shifts += key_shifts[round];

		t0 = (k0 << shifts) | (k0 >> (28 - shifts));
		t1 = (k1 << shifts) | (k1 >> (28 - shifts));

		de_keysl[15 - round] =
		en_keysl[round] = comp_maskl[0][(t0 >> 21) & 0x7f]
				| comp_maskl[1][(t0 >> 14) & 0x7f]
				| comp_maskl[2][(t0 >> 7) & 0x7f]
				| comp_maskl[3][t0 & 0x7f]
				| comp_maskl[4][(t1 >> 21) & 0x7f]
				| comp_maskl[5][(t1 >> 14) & 0x7f]
				| comp_maskl[6][(t1 >> 7) & 0x7f]
				| comp_maskl[7][t1 & 0x7f];

		de_keysr[15 - round] =
		en_keysr[round] = comp_maskr[0][(t0 >> 21) & 0x7f]
				| comp_maskr[1][(t0 >> 14) & 0x7f]
				| comp_maskr[2][(t0 >> 7) & 0x7f]
				| comp_maskr[3][t0 & 0x7f]
				| comp_maskr[4][(t1 >> 21) & 0x7f]
				| comp_maskr[5][(t1 >> 14) & 0x7f]
				| comp_maskr[6][(t1 >> 7) & 0x7f]
				| comp_maskr[7][t1 & 0x7f];
	}
	return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
cmpl $0x0, 0x154f5(%rip)     # 0x3c9c8
jne 0x274da
callq 0x280c0
movq -0x10(%rbp), %rax
movl (%rax), %edi
callq 0x6540
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x6540
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
orl -0x20(%rbp), %eax
cmpl $0x0, %eax
je 0x27524
movl -0x1c(%rbp), %eax
cmpl 0x154c5(%rip), %eax     # 0x3c9d0
jne 0x27524
movl -0x20(%rbp), %eax
cmpl 0x154b6(%rip), %eax     # 0x3c9cc
jne 0x27524
movl $0x0, -0x4(%rbp)
jmp 0x27930
movl -0x1c(%rbp), %eax
movl %eax, 0x154a3(%rip)     # 0x3c9d0
movl -0x20(%rbp), %eax
movl %eax, 0x15496(%rip)     # 0x3c9cc
movl -0x1c(%rbp), %eax
shrl $0x19, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x217a9(%rip), %rax     # 0x48cf0
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
shrl $0x11, %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x21792(%rip), %rcx     # 0x48cf0
orl 0x200(%rcx,%rdx,4), %eax
movl -0x1c(%rbp), %ecx
shrl $0x9, %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x21777(%rip), %rcx     # 0x48cf0
orl 0x400(%rcx,%rdx,4), %eax
movl -0x1c(%rbp), %ecx
shrl %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x2175d(%rip), %rcx     # 0x48cf0
orl 0x600(%rcx,%rdx,4), %eax
movl -0x20(%rbp), %ecx
shrl $0x19, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x21745(%rip), %rcx     # 0x48cf0
orl 0x800(%rcx,%rdx,4), %eax
movl -0x20(%rbp), %ecx
shrl $0x11, %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x2172a(%rip), %rcx     # 0x48cf0
orl 0xa00(%rcx,%rdx,4), %eax
movl -0x20(%rbp), %ecx
shrl $0x9, %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x2170f(%rip), %rcx     # 0x48cf0
orl 0xc00(%rcx,%rdx,4), %eax
movl -0x20(%rbp), %ecx
shrl %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x216f5(%rip), %rcx     # 0x48cf0
orl 0xe00(%rcx,%rdx,4), %eax
movl %eax, -0x14(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x19, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x226da(%rip), %rax     # 0x49cf0
movl (%rax,%rcx,4), %eax
movl -0x1c(%rbp), %ecx
shrl $0x11, %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x226c3(%rip), %rcx     # 0x49cf0
orl 0x200(%rcx,%rdx,4), %eax
movl -0x1c(%rbp), %ecx
shrl $0x9, %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x226a8(%rip), %rcx     # 0x49cf0
orl 0x400(%rcx,%rdx,4), %eax
movl -0x1c(%rbp), %ecx
shrl %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x2268e(%rip), %rcx     # 0x49cf0
orl 0x600(%rcx,%rdx,4), %eax
movl -0x20(%rbp), %ecx
shrl $0x19, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x22676(%rip), %rcx     # 0x49cf0
orl 0x800(%rcx,%rdx,4), %eax
movl -0x20(%rbp), %ecx
shrl $0x11, %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x2265b(%rip), %rcx     # 0x49cf0
orl 0xa00(%rcx,%rdx,4), %eax
movl -0x20(%rbp), %ecx
shrl $0x9, %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x22640(%rip), %rcx     # 0x49cf0
orl 0xc00(%rcx,%rdx,4), %eax
movl -0x20(%rbp), %ecx
shrl %ecx
andl $0x7f, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x22626(%rip), %rcx     # 0x49cf0
orl 0xe00(%rcx,%rdx,4), %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x10, -0x28(%rbp)
jge 0x27929
movslq -0x28(%rbp), %rcx
leaq 0xf359(%rip), %rax      # 0x36a50
movzbl (%rax,%rcx), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x14(%rbp), %eax
movl -0x24(%rbp), %ecx
shll %cl, %eax
movl -0x14(%rbp), %edx
movl $0x1c, %ecx
subl -0x24(%rbp), %ecx
shrl %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x18(%rbp), %eax
movl -0x24(%rbp), %ecx
shll %cl, %eax
movl -0x18(%rbp), %edx
movl $0x1c, %ecx
subl -0x24(%rbp), %ecx
shrl %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
shrl $0x15, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x235a3(%rip), %rax     # 0x4acf0
movl (%rax,%rcx,4), %edx
movl -0x2c(%rbp), %eax
shrl $0xe, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x2358c(%rip), %rax     # 0x4acf0
orl 0x200(%rax,%rcx,4), %edx
movl -0x2c(%rbp), %eax
shrl $0x7, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x23571(%rip), %rax     # 0x4acf0
orl 0x400(%rax,%rcx,4), %edx
movl -0x2c(%rbp), %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x23559(%rip), %rax     # 0x4acf0
orl 0x600(%rax,%rcx,4), %edx
movl -0x30(%rbp), %eax
shrl $0x15, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x2353e(%rip), %rax     # 0x4acf0
orl 0x800(%rax,%rcx,4), %edx
movl -0x30(%rbp), %eax
shrl $0xe, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x23523(%rip), %rax     # 0x4acf0
orl 0xa00(%rax,%rcx,4), %edx
movl -0x30(%rbp), %eax
shrl $0x7, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x23508(%rip), %rax     # 0x4acf0
orl 0xc00(%rax,%rcx,4), %edx
movl -0x30(%rbp), %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x234f0(%rip), %rax     # 0x4acf0
orl 0xe00(%rax,%rcx,4), %edx
movslq -0x28(%rbp), %rcx
leaq 0x264fe(%rip), %rax     # 0x4dd10
movl %edx, (%rax,%rcx,4)
movl $0xf, %eax
subl -0x28(%rbp), %eax
movslq %eax, %rcx
leaq 0x26529(%rip), %rax     # 0x4dd50
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
shrl $0x15, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x244b2(%rip), %rax     # 0x4bcf0
movl (%rax,%rcx,4), %edx
movl -0x2c(%rbp), %eax
shrl $0xe, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x2449b(%rip), %rax     # 0x4bcf0
orl 0x200(%rax,%rcx,4), %edx
movl -0x2c(%rbp), %eax
shrl $0x7, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x24480(%rip), %rax     # 0x4bcf0
orl 0x400(%rax,%rcx,4), %edx
movl -0x2c(%rbp), %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x24468(%rip), %rax     # 0x4bcf0
orl 0x600(%rax,%rcx,4), %edx
movl -0x30(%rbp), %eax
shrl $0x15, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x2444d(%rip), %rax     # 0x4bcf0
orl 0x800(%rax,%rcx,4), %edx
movl -0x30(%rbp), %eax
shrl $0xe, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x24432(%rip), %rax     # 0x4bcf0
orl 0xa00(%rax,%rcx,4), %edx
movl -0x30(%rbp), %eax
shrl $0x7, %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x24417(%rip), %rax     # 0x4bcf0
orl 0xc00(%rax,%rcx,4), %edx
movl -0x30(%rbp), %eax
andl $0x7f, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x243ff(%rip), %rax     # 0x4bcf0
orl 0xe00(%rax,%rcx,4), %edx
movslq -0x28(%rbp), %rcx
leaq 0x2648d(%rip), %rax     # 0x4dd90
movl %edx, (%rax,%rcx,4)
movl $0xf, %eax
subl -0x28(%rbp), %eax
movslq %eax, %rcx
leaq 0x264b8(%rip), %rax     # 0x4ddd0
movl %edx, (%rax,%rcx,4)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x276e2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)