// File: /workspace/github_c_makefile_star2_O1/fritzw[P]cube-utils/blowfish.c
// Function: blowfish_encrypt
void blowfish_encrypt(const BYTE in[], BYTE out[], const BLOWFISH_KEY *keystruct, int compatibility_mode)
{
    WORD l,r,t; //,i;

    // Swap input byte order to conform with broken encoding
    if (compatibility_mode) {
        l = (in[3] << 24) | (in[2] << 16) | (in[1] << 8) | (in[0]);
        r = (in[7] << 24) | (in[6] << 16) | (in[5] << 8) | (in[4]);
    } else {
        l = (in[0] << 24) | (in[1] << 16) | (in[2] << 8) | (in[3]);
        r = (in[4] << 24) | (in[5] << 16) | (in[6] << 8) | (in[7]);
    }

    ITERATION(l,r,t,0);
    ITERATION(l,r,t,1);
    ITERATION(l,r,t,2);
    ITERATION(l,r,t,3);
    ITERATION(l,r,t,4);
    ITERATION(l,r,t,5);
    ITERATION(l,r,t,6);
    ITERATION(l,r,t,7);
    ITERATION(l,r,t,8);
    ITERATION(l,r,t,9);
    ITERATION(l,r,t,10);
    ITERATION(l,r,t,11);
    ITERATION(l,r,t,12);
    ITERATION(l,r,t,13);
    ITERATION(l,r,t,14);
    l ^= keystruct->p[15]; F(l,t); r^= t; //Last iteration has no swap()
    r ^= keystruct->p[16];
    l ^= keystruct->p[17];

    if (compatibility_mode) {
        // Swap input byte order to conform with broken encoding
        out[3] = l >> 24;
        out[2] = l >> 16;
        out[1] = l >> 8;
        out[0] = l;
        out[7] = r >> 24;
        out[6] = r >> 16;
        out[5] = r >> 8;
        out[4] = r;
    } else {
        out[0] = l >> 24;
        out[1] = l >> 16;
        out[2] = l >> 8;
        out[3] = l;
        out[4] = r >> 24;
        out[5] = r >> 16;
        out[6] = r >> 8;
        out[7] = r;
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testl %ecx, %ecx
je 0x15fe
movzbl 0x3(%rdi), %eax
shll $0x18, %eax
movzbl 0x2(%rdi), %r8d
shll $0x10, %r8d
orl %eax, %r8d
movzbl 0x1(%rdi), %r9d
shll $0x8, %r9d
orl %r8d, %r9d
movl $0x4, %eax
movl $0x5, %r10d
movl $0x6, %r11d
movl $0x7, %ebx
movq %rdi, %r8
jmp 0x1636
movzbl (%rdi), %eax
shll $0x18, %eax
movzbl 0x1(%rdi), %r8d
shll $0x10, %r8d
orl %eax, %r8d
movzbl 0x2(%rdi), %r9d
shll $0x8, %r9d
orl %r8d, %r9d
leaq 0x3(%rdi), %r8
movl $0x7, %eax
movl $0x6, %r10d
movl $0x5, %r11d
movl $0x4, %ebx
movzbl (%r8), %r8d
orl %r9d, %r8d
movzbl (%rdi,%rbx), %r9d
shll $0x18, %r9d
movzbl (%rdi,%r11), %r11d
shll $0x10, %r11d
orl %r9d, %r11d
movzbl (%rdi,%r10), %r9d
shll $0x8, %r9d
orl %r11d, %r9d
movzbl (%rdi,%rax), %r10d
xorl (%rdx), %r8d
orl %r9d, %r10d
movl %r8d, %eax
shrl $0x18, %eax
movl %r8d, %r9d
shrl $0xe, %r9d
movl $0x3fc, %edi            # imm = 0x3FC
andl %edi, %r9d
movl 0x448(%rdx,%r9), %r9d
addl 0x48(%rdx,%rax,4), %r9d
movl %r8d, %r11d
shrl $0x8, %r11d
movl $0xff, %eax
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r9d
movl %r8d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r9d
xorl %r10d, %r9d
xorl 0x4(%rdx), %r9d
movl %r9d, %r11d
shrl $0x18, %r11d
movl %r9d, %r10d
shrl $0xe, %r10d
andl %edi, %r10d
movl 0x448(%rdx,%r10), %r10d
addl 0x48(%rdx,%r11,4), %r10d
movl %r9d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r10d
movl %r9d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r10d
xorl 0x8(%rdx), %r10d
xorl %r8d, %r10d
movl %r10d, %r11d
shrl $0x18, %r11d
movl %r10d, %r8d
shrl $0xe, %r8d
andl %edi, %r8d
movl 0x448(%rdx,%r8), %r8d
addl 0x48(%rdx,%r11,4), %r8d
movl %r10d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r8d
movl %r10d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r8d
xorl 0xc(%rdx), %r8d
xorl %r9d, %r8d
movl %r8d, %r11d
shrl $0x18, %r11d
movl %r8d, %r9d
shrl $0xe, %r9d
andl %edi, %r9d
movl 0x448(%rdx,%r9), %r9d
addl 0x48(%rdx,%r11,4), %r9d
movl %r8d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r9d
movl %r8d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r9d
xorl 0x10(%rdx), %r9d
xorl %r10d, %r9d
movl %r9d, %r11d
shrl $0x18, %r11d
movl %r9d, %r10d
shrl $0xe, %r10d
andl %edi, %r10d
movl 0x448(%rdx,%r10), %r10d
addl 0x48(%rdx,%r11,4), %r10d
movl %r9d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r10d
movl %r9d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r10d
xorl 0x14(%rdx), %r10d
xorl %r8d, %r10d
movl %r10d, %r11d
shrl $0x18, %r11d
movl %r10d, %r8d
shrl $0xe, %r8d
andl %edi, %r8d
movl 0x448(%rdx,%r8), %r8d
addl 0x48(%rdx,%r11,4), %r8d
movl %r10d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r8d
movl %r10d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r8d
xorl 0x18(%rdx), %r8d
xorl %r9d, %r8d
movl %r8d, %r11d
shrl $0x18, %r11d
movl %r8d, %r9d
shrl $0xe, %r9d
andl %edi, %r9d
movl 0x448(%rdx,%r9), %r9d
addl 0x48(%rdx,%r11,4), %r9d
movl %r8d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r9d
movl %r8d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r9d
xorl 0x1c(%rdx), %r9d
xorl %r10d, %r9d
movl %r9d, %r11d
shrl $0x18, %r11d
movl %r9d, %r10d
shrl $0xe, %r10d
andl %edi, %r10d
movl 0x448(%rdx,%r10), %r10d
addl 0x48(%rdx,%r11,4), %r10d
movl %r9d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r10d
movl %r9d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r10d
xorl 0x20(%rdx), %r10d
xorl %r8d, %r10d
movl %r10d, %r11d
shrl $0x18, %r11d
movl %r10d, %r8d
shrl $0xe, %r8d
andl %edi, %r8d
movl 0x448(%rdx,%r8), %r8d
addl 0x48(%rdx,%r11,4), %r8d
movl %r10d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r8d
movl %r10d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r8d
xorl 0x24(%rdx), %r8d
xorl %r9d, %r8d
movl %r8d, %r11d
shrl $0x18, %r11d
movl %r8d, %r9d
shrl $0xe, %r9d
andl %edi, %r9d
movl 0x448(%rdx,%r9), %r9d
addl 0x48(%rdx,%r11,4), %r9d
movl %r8d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r9d
movl %r8d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r9d
xorl 0x28(%rdx), %r9d
xorl %r10d, %r9d
movl %r9d, %r11d
shrl $0x18, %r11d
movl %r9d, %r10d
shrl $0xe, %r10d
andl %edi, %r10d
movl 0x448(%rdx,%r10), %r10d
addl 0x48(%rdx,%r11,4), %r10d
movl %r9d, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
xorl 0x848(%rdx,%r11,4), %r10d
movl %r9d, %r11d
andl %eax, %r11d
addl 0xc48(%rdx,%r11,4), %r10d
xorl 0x2c(%rdx), %r10d
xorl %r8d, %r10d
movl %r10d, %r8d
shrl $0x18, %r8d
movl %r10d, %r11d
shrl $0xe, %r11d
andl %edi, %r11d
movl 0x448(%rdx,%r11), %r11d
addl 0x48(%rdx,%r8,4), %r11d
movl %r10d, %r8d
shrl $0x8, %r8d
andl %eax, %r8d
xorl 0x848(%rdx,%r8,4), %r11d
movl %r10d, %r8d
andl %eax, %r8d
addl 0xc48(%rdx,%r8,4), %r11d
xorl 0x30(%rdx), %r11d
xorl %r9d, %r11d
movl %r11d, %r8d
shrl $0x18, %r8d
movl %r11d, %r9d
shrl $0xe, %r9d
andl %edi, %r9d
movl 0x448(%rdx,%r9), %r9d
addl 0x48(%rdx,%r8,4), %r9d
movl %r11d, %r8d
shrl $0x8, %r8d
andl %eax, %r8d
xorl 0x848(%rdx,%r8,4), %r9d
movl %r11d, %r8d
andl %eax, %r8d
addl 0xc48(%rdx,%r8,4), %r9d
xorl 0x34(%rdx), %r9d
xorl %r10d, %r9d
movl %r9d, %r10d
shrl $0x18, %r10d
movl %r9d, %r8d
shrl $0xe, %r8d
andl %edi, %r8d
movl 0x448(%rdx,%r8), %r8d
addl 0x48(%rdx,%r10,4), %r8d
movl %r9d, %r10d
shrl $0x8, %r10d
andl %eax, %r10d
xorl 0x848(%rdx,%r10,4), %r8d
movl %r9d, %r10d
andl %eax, %r10d
addl 0xc48(%rdx,%r10,4), %r8d
xorl 0x38(%rdx), %r8d
xorl %r11d, %r8d
movl %r8d, %r10d
shrl $0x18, %r10d
movl %r8d, %r11d
shrl $0xe, %r11d
andl %edi, %r11d
movl 0x448(%rdx,%r11), %ebx
addl 0x48(%rdx,%r10,4), %ebx
movl %r8d, %r10d
shrl $0x8, %r10d
andl %eax, %r10d
xorl 0x848(%rdx,%r10,4), %ebx
movl %r8d, %r10d
andl %eax, %r10d
addl 0xc48(%rdx,%r10,4), %ebx
xorl 0x3c(%rdx), %ebx
xorl %r9d, %ebx
movl %ebx, %r9d
shrl $0x18, %r9d
movl %ebx, %r10d
shrl $0xe, %r10d
andl %edi, %r10d
movl %ebx, %r11d
shrl $0x8, %r11d
andl %eax, %r11d
andl %ebx, %eax
xorl 0x44(%rdx), %ebx
movl %ebx, %ebp
shrl $0x18, %ebp
movl 0x48(%rdx,%r9,4), %r9d
movl 0x448(%rdx,%r10), %edi
movl 0x848(%rdx,%r11,4), %r10d
movl 0xc48(%rdx,%rax,4), %r11d
movl 0x40(%rdx), %eax
testl %ecx, %ecx
je 0x1aed
movb %bpl, 0x3(%rsi)
movl %ebx, %ecx
shrl $0x10, %ecx
movb %cl, 0x2(%rsi)
movb %bh, 0x1(%rsi)
movb %bl, (%rsi)
movl $0x4, %ecx
movl $0x5, %edx
movl $0x6, %ebx
movl $0x7, %r14d
jmp 0x1b13
movb %bpl, (%rsi)
movl %ebx, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rsi)
movb %bh, 0x2(%rsi)
movb %bl, 0x3(%rsi)
movl $0x7, %ecx
movl $0x6, %edx
movl $0x5, %ebx
movl $0x4, %r14d
addl %r9d, %edi
xorl %r10d, %edi
addl %r11d, %edi
xorl %r8d, %eax
xorl %edi, %eax
movl %eax, %edi
shrl $0x18, %edi
movb %dil, (%rsi,%r14)
movl %eax, %edi
shrl $0x10, %edi
movb %dil, (%rsi,%rbx)
movb %ah, (%rsi,%rdx)
movb %al, (%rsi,%rcx)
popq %rbx
popq %r14
popq %rbp
retq