// File: /workspace/github_c_makefile_star2_O0/ajpaulson[P]srogue11/xcrypt.c
// Function: do_des
static int do_des(unsigned int l_in,unsigned int r_in,unsigned int *l_out,unsigned int *r_out,int count)
{
	/*
	 *	l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
	 */
	unsigned int	l, r, *kl, *kr, *kl1, *kr1;
	unsigned int	f, r48l, r48r;
	int		round;

	if (count == 0) {
		return(1);
	} else if (count > 0) {
		/*
		 * Encrypting
		 */
		kl1 = en_keysl;
		kr1 = en_keysr;
	} else {
		/*
		 * Decrypting
		 */
		count = -count;
		kl1 = de_keysl;
		kr1 = de_keysr;
	}

	/*
	 *	Do initial permutation (IP).
	 */
	l = ip_maskl[0][l_in >> 24]
	  | ip_maskl[1][(l_in >> 16) & 0xff]
	  | ip_maskl[2][(l_in >> 8) & 0xff]
	  | ip_maskl[3][l_in & 0xff]
	  | ip_maskl[4][r_in >> 24]
	  | ip_maskl[5][(r_in >> 16) & 0xff]
	  | ip_maskl[6][(r_in >> 8) & 0xff]
	  | ip_maskl[7][r_in & 0xff];
	r = ip_maskr[0][l_in >> 24]
	  | ip_maskr[1][(l_in >> 16) & 0xff]
	  | ip_maskr[2][(l_in >> 8) & 0xff]
	  | ip_maskr[3][l_in & 0xff]
	  | ip_maskr[4][r_in >> 24]
	  | ip_maskr[5][(r_in >> 16) & 0xff]
	  | ip_maskr[6][(r_in >> 8) & 0xff]
	  | ip_maskr[7][r_in & 0xff];

	while (count--) {
		/*
		 * Do each round.
		 */
		kl = kl1;
		kr = kr1;
		round = 16;
		while (round--) {
			/*
			 * Expand R to 48 bits (simulate the E-box).
			 */
			r48l	= ((r & 0x00000001) << 23)
				| ((r & 0xf8000000) >> 9)
				| ((r & 0x1f800000) >> 11)
				| ((r & 0x01f80000) >> 13)
				| ((r & 0x001f8000) >> 15);

			r48r	= ((r & 0x0001f800) << 7)
				| ((r & 0x00001f80) << 5)
				| ((r & 0x000001f8) << 3)
				| ((r & 0x0000001f) << 1)
				| ((r & 0x80000000) >> 31);
			/*
			 * Do salting for crypt() and friends, and
			 * XOR with the permuted key.
			 */
			f = (r48l ^ r48r) & saltbits;
			r48l ^= f ^ *kl++;
			r48r ^= f ^ *kr++;
			/*
			 * Do sbox lookups (which shrink it back to 32 bits)
			 * and do the pbox permutation at the same time.
			 */
			f = psbox[0][m_sbox[0][r48l >> 12]]
			  | psbox[1][m_sbox[1][r48l & 0xfff]]
			  | psbox[2][m_sbox[2][r48r >> 12]]
			  | psbox[3][m_sbox[3][r48r & 0xfff]];
			/*
			 * Now that we've permuted things, complete f().
			 */
			f ^= l;
			l = r;
			r = f;
		}
		r = l;
		l = f;
	}
	/*
	 * Do final permutation (inverse of IP).
	 */
	*l_out	= fp_maskl[0][l >> 24]
		| fp_maskl[1][(l >> 16) & 0xff]
		| fp_maskl[2][(l >> 8) & 0xff]
		| fp_maskl[3][l & 0xff]
		| fp_maskl[4][r >> 24]
		| fp_maskl[5][(r >> 16) & 0xff]
		| fp_maskl[6][(r >> 8) & 0xff]
		| fp_maskl[7][r & 0xff];
	*r_out	= fp_maskr[0][l >> 24]
		| fp_maskr[1][(l >> 16) & 0xff]
		| fp_maskr[2][(l >> 8) & 0xff]
		| fp_maskr[3][l & 0xff]
		| fp_maskr[4][r >> 24]
		| fp_maskr[5][(r >> 16) & 0xff]
		| fp_maskr[6][(r >> 8) & 0xff]
		| fp_maskr[7][r & 0xff];
	return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x27b28
movl $0x1, -0x4(%rbp)
jmp 0x280b3
cmpl $0x0, -0x24(%rbp)
jle 0x27b46
leaq 0x261db(%rip), %rax     # 0x4dd10
movq %rax, -0x48(%rbp)
leaq 0x26250(%rip), %rax     # 0x4dd90
movq %rax, -0x50(%rbp)
jmp 0x27b64
xorl %eax, %eax
subl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
leaq 0x261fb(%rip), %rax     # 0x4dd50
movq %rax, -0x48(%rbp)
leaq 0x26270(%rip), %rax     # 0x4ddd0
movq %rax, -0x50(%rbp)
jmp 0x27b66
movl -0x8(%rbp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x19179(%rip), %rax     # 0x40cf0
movl (%rax,%rcx,4), %eax
movl -0x8(%rbp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x1915f(%rip), %rcx     # 0x40cf0
orl 0x400(%rcx,%rdx,4), %eax
movl -0x8(%rbp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x19141(%rip), %rcx     # 0x40cf0
orl 0x800(%rcx,%rdx,4), %eax
movl -0x8(%rbp), %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x19126(%rip), %rcx     # 0x40cf0
orl 0xc00(%rcx,%rdx,4), %eax
movl -0xc(%rbp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x1910e(%rip), %rcx     # 0x40cf0
orl 0x1000(%rcx,%rdx,4), %eax
movl -0xc(%rbp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x190f0(%rip), %rcx     # 0x40cf0
orl 0x1400(%rcx,%rdx,4), %eax
movl -0xc(%rbp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x190d2(%rip), %rcx     # 0x40cf0
orl 0x1800(%rcx,%rdx,4), %eax
movl -0xc(%rbp), %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x190b7(%rip), %rcx     # 0x40cf0
orl 0x1c00(%rcx,%rdx,4), %eax
movl %eax, -0x28(%rbp)
movl -0x8(%rbp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x1b09c(%rip), %rax     # 0x42cf0
movl (%rax,%rcx,4), %eax
movl -0x8(%rbp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x1b082(%rip), %rcx     # 0x42cf0
orl 0x400(%rcx,%rdx,4), %eax
movl -0x8(%rbp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x1b064(%rip), %rcx     # 0x42cf0
orl 0x800(%rcx,%rdx,4), %eax
movl -0x8(%rbp), %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x1b049(%rip), %rcx     # 0x42cf0
orl 0xc00(%rcx,%rdx,4), %eax
movl -0xc(%rbp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x1b031(%rip), %rcx     # 0x42cf0
orl 0x1000(%rcx,%rdx,4), %eax
movl -0xc(%rbp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x1b013(%rip), %rcx     # 0x42cf0
orl 0x1400(%rcx,%rdx,4), %eax
movl -0xc(%rbp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x1aff5(%rip), %rcx     # 0x42cf0
orl 0x1800(%rcx,%rdx,4), %eax
movl -0xc(%rbp), %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x1afda(%rip), %rcx     # 0x42cf0
orl 0x1c00(%rcx,%rdx,4), %eax
movl %eax, -0x2c(%rbp)
movl -0x24(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x24(%rbp)
cmpl $0x0, %eax
je 0x27ef8
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x10, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x60(%rbp)
cmpl $0x0, %eax
je 0x27ee7
movl -0x2c(%rbp), %eax
andl $0x1, %eax
shll $0x17, %eax
movl -0x2c(%rbp), %ecx
andl $0xf8000000, %ecx       # imm = 0xF8000000
shrl $0x9, %ecx
orl %ecx, %eax
movl -0x2c(%rbp), %ecx
andl $0x1f800000, %ecx       # imm = 0x1F800000
shrl $0xb, %ecx
orl %ecx, %eax
movl -0x2c(%rbp), %ecx
andl $0x1f80000, %ecx        # imm = 0x1F80000
shrl $0xd, %ecx
orl %ecx, %eax
movl -0x2c(%rbp), %ecx
andl $0x1f8000, %ecx         # imm = 0x1F8000
shrl $0xf, %ecx
orl %ecx, %eax
movl %eax, -0x58(%rbp)
movl -0x2c(%rbp), %eax
andl $0x1f800, %eax          # imm = 0x1F800
shll $0x7, %eax
movl -0x2c(%rbp), %ecx
andl $0x1f80, %ecx           # imm = 0x1F80
shll $0x5, %ecx
orl %ecx, %eax
movl -0x2c(%rbp), %ecx
andl $0x1f8, %ecx            # imm = 0x1F8
shll $0x3, %ecx
orl %ecx, %eax
movl -0x2c(%rbp), %ecx
andl $0x1f, %ecx
shll %ecx
orl %ecx, %eax
movl -0x2c(%rbp), %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
shrl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x5c(%rbp)
movl -0x58(%rbp), %eax
xorl -0x5c(%rbp), %eax
andl 0x14be3(%rip), %eax     # 0x3c9d4
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x4, %rdx
movq %rdx, -0x38(%rbp)
xorl (%rcx), %eax
xorl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
movq -0x40(%rbp), %rcx
movq %rcx, %rdx
addq $0x4, %rdx
movq %rdx, -0x40(%rbp)
xorl (%rcx), %eax
xorl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x58(%rbp), %eax
shrl $0xc, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x14db7(%rip), %rax     # 0x3cbf0
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x24eca(%rip), %rax     # 0x4cd10
movl (%rax,%rcx,4), %eax
movl -0x58(%rbp), %ecx
andl $0xfff, %ecx            # imm = 0xFFF
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x14d93(%rip), %rcx     # 0x3cbf0
movzbl 0x1000(%rcx,%rdx), %ecx
movl %ecx, %edx
leaq 0x24ea2(%rip), %rcx     # 0x4cd10
orl 0x400(%rcx,%rdx,4), %eax
movl -0x5c(%rbp), %ecx
shrl $0xc, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x14d6a(%rip), %rcx     # 0x3cbf0
movzbl 0x2000(%rcx,%rdx), %ecx
movl %ecx, %edx
leaq 0x24e79(%rip), %rcx     # 0x4cd10
orl 0x800(%rcx,%rdx,4), %eax
movl -0x5c(%rbp), %ecx
andl $0xfff, %ecx            # imm = 0xFFF
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x14d3e(%rip), %rcx     # 0x3cbf0
movzbl 0x3000(%rcx,%rdx), %ecx
movl %ecx, %edx
leaq 0x24e4d(%rip), %rcx     # 0x4cd10
orl 0xc00(%rcx,%rdx,4), %eax
movl %eax, -0x54(%rbp)
movl -0x28(%rbp), %eax
xorl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x27d4b
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x27d20
movl -0x28(%rbp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x1cde7(%rip), %rax     # 0x44cf0
movl (%rax,%rcx,4), %ecx
movl -0x28(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1cdce(%rip), %rax     # 0x44cf0
orl 0x400(%rax,%rdx,4), %ecx
movl -0x28(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1cdb1(%rip), %rax     # 0x44cf0
orl 0x800(%rax,%rdx,4), %ecx
movl -0x28(%rbp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1cd97(%rip), %rax     # 0x44cf0
orl 0xc00(%rax,%rdx,4), %ecx
movl -0x2c(%rbp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1cd7f(%rip), %rax     # 0x44cf0
orl 0x1000(%rax,%rdx,4), %ecx
movl -0x2c(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1cd62(%rip), %rax     # 0x44cf0
orl 0x1400(%rax,%rdx,4), %ecx
movl -0x2c(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1cd45(%rip), %rax     # 0x44cf0
orl 0x1800(%rax,%rdx,4), %ecx
movl -0x2c(%rbp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1cd2b(%rip), %rax     # 0x44cf0
orl 0x1c00(%rax,%rdx,4), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x28(%rbp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x1ed0d(%rip), %rax     # 0x46cf0
movl (%rax,%rcx,4), %ecx
movl -0x28(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1ecf4(%rip), %rax     # 0x46cf0
orl 0x400(%rax,%rdx,4), %ecx
movl -0x28(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1ecd7(%rip), %rax     # 0x46cf0
orl 0x800(%rax,%rdx,4), %ecx
movl -0x28(%rbp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1ecbd(%rip), %rax     # 0x46cf0
orl 0xc00(%rax,%rdx,4), %ecx
movl -0x2c(%rbp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1eca5(%rip), %rax     # 0x46cf0
orl 0x1000(%rax,%rdx,4), %ecx
movl -0x2c(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1ec88(%rip), %rax     # 0x46cf0
orl 0x1400(%rax,%rdx,4), %ecx
movl -0x2c(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1ec6b(%rip), %rax     # 0x46cf0
orl 0x1800(%rax,%rdx,4), %ecx
movl -0x2c(%rbp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x1ec51(%rip), %rax     # 0x46cf0
orl 0x1c00(%rax,%rdx,4), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)