#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef unsigned long CAST_LONG;
typedef int /*<<< orphan*/ CAST_KEY;

/* Variables and functions */
int /*<<< orphan*/ CAST_encrypt(unsigned long *, int /*<<< orphan*/ const *);
void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,
                        long length, const CAST_KEY *schedule,
                        unsigned char *ivec, int *num, int enc) {
  CAST_LONG v0, v1, t;
  int n = *num;
  long l = length;
  CAST_LONG ti[2];
  unsigned char *iv, c, cc;
  iv = ivec;
  if (enc) {
    while (l--) {
      if (n == 0) {
        (v0 = ((unsigned long)(*((iv)++))) << 24L,
         v0 |= ((unsigned long)(*((iv)++))) << 16L,
         v0 |= ((unsigned long)(*((iv)++))) << 8L,
         v0 |= ((unsigned long)(*((iv)++))));
        ti[0] = v0;
        (v1 = ((unsigned long)(*((iv)++))) << 24L,
         v1 |= ((unsigned long)(*((iv)++))) << 16L,
         v1 |= ((unsigned long)(*((iv)++))) << 8L,
         v1 |= ((unsigned long)(*((iv)++))));
        ti[1] = v1;
        CAST_encrypt((CAST_LONG *)ti, schedule);
        iv = ivec;
        t = ti[0];
        (*((iv)++) = (unsigned char)(((t) >> 24L) & 0xff),
         *((iv)++) = (unsigned char)(((t) >> 16L) & 0xff),
         *((iv)++) = (unsigned char)(((t) >> 8L) & 0xff),
         *((iv)++) = (unsigned char)(((t)) & 0xff));
        t = ti[1];
        (*((iv)++) = (unsigned char)(((t) >> 24L) & 0xff),
         *((iv)++) = (unsigned char)(((t) >> 16L) & 0xff),
         *((iv)++) = (unsigned char)(((t) >> 8L) & 0xff),
         *((iv)++) = (unsigned char)(((t)) & 0xff));
        iv = ivec;
      }
      c = *(in++) ^ iv[n];
      *(out++) = c;
      iv[n] = c;
      n = (n + 1) & 0x07;
    }
  } else {
    while (l--) {
      if (n == 0) {
        (v0 = ((unsigned long)(*((iv)++))) << 24L,
         v0 |= ((unsigned long)(*((iv)++))) << 16L,
         v0 |= ((unsigned long)(*((iv)++))) << 8L,
         v0 |= ((unsigned long)(*((iv)++))));
        ti[0] = v0;
        (v1 = ((unsigned long)(*((iv)++))) << 24L,
         v1 |= ((unsigned long)(*((iv)++))) << 16L,
         v1 |= ((unsigned long)(*((iv)++))) << 8L,
         v1 |= ((unsigned long)(*((iv)++))));
        ti[1] = v1;
        CAST_encrypt((CAST_LONG *)ti, schedule);
        iv = ivec;
        t = ti[0];
        (*((iv)++) = (unsigned char)(((t) >> 24L) & 0xff),
         *((iv)++) = (unsigned char)(((t) >> 16L) & 0xff),
         *((iv)++) = (unsigned char)(((t) >> 8L) & 0xff),
         *((iv)++) = (unsigned char)(((t)) & 0xff));
        t = ti[1];
        (*((iv)++) = (unsigned char)(((t) >> 24L) & 0xff),
         *((iv)++) = (unsigned char)(((t) >> 16L) & 0xff),
         *((iv)++) = (unsigned char)(((t) >> 8L) & 0xff),
         *((iv)++) = (unsigned char)(((t)) & 0xff));
        iv = ivec;
      }
      cc = *(in++);
      c = iv[n];
      iv[n] = cc;
      *(out++) = c ^ cc;
      n = (n + 1) & 0x07;
    }
  }
  v0 = v1 = ti[0] = ti[1] = t = c = cc = 0;
  *num = n;
}


x86 assembly (clang, -O0):
<CAST_cfb64_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
cmpl   $0x0,0x10(%rbp)
je     13f9 <CAST_cfb64_encrypt+0x2e9>
jmp    115e <CAST_cfb64_encrypt+0x4e>
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x58(%rbp)
cmp    $0x0,%rax
je     13f4 <CAST_cfb64_encrypt+0x2e4>
cmpl   $0x0,-0x4c(%rbp)
jne    139e <CAST_cfb64_encrypt+0x28e>
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x18,%rax
mov    %rax,-0x38(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x10,%rax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x8,%rax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x18,%rax
mov    %rax,-0x40(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x10,%rax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x8,%rax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <CAST_encrypt@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x68(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%eax
mov    -0x78(%rbp),%rcx
movslq -0x4c(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
xor    %ecx,%eax
mov    %al,-0x79(%rbp)
mov    -0x79(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x79(%rbp),%dl
mov    -0x78(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
and    $0x7,%eax
mov    %eax,-0x4c(%rbp)
jmp    115e <CAST_cfb64_encrypt+0x4e>
jmp    16a1 <CAST_cfb64_encrypt+0x591>
jmp    13fe <CAST_cfb64_encrypt+0x2ee>
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x58(%rbp)
cmp    $0x0,%rax
je     169c <CAST_cfb64_encrypt+0x58c>
cmpl   $0x0,-0x4c(%rbp)
jne    163e <CAST_cfb64_encrypt+0x52e>
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x18,%rax
mov    %rax,-0x38(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x10,%rax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x8,%rax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x18,%rax
mov    %rax,-0x40(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x10,%rax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
shl    $0x8,%rax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x78(%rbp)
movzbl (%rax),%eax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <CAST_encrypt@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x68(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x78(%rbp)
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x7a(%rbp)
mov    -0x78(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x79(%rbp)
mov    -0x7a(%rbp),%dl
mov    -0x78(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movzbl -0x79(%rbp),%eax
movzbl -0x7a(%rbp),%ecx
xor    %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
and    $0x7,%eax
mov    %eax,-0x4c(%rbp)
jmp    13fe <CAST_cfb64_encrypt+0x2ee>
jmp    16a1 <CAST_cfb64_encrypt+0x591>
movb   $0x0,-0x7a(%rbp)
movb   $0x0,-0x79(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x4c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CAST_cfb64_encrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%rbx
mov    %rcx,0x18(%rsp)
mov    %rdx,%r12
mov    %rdi,%r13
mov    %r9,0x20(%rsp)
mov    (%r9),%r14d
cmpl   $0x0,0x60(%rsp)
mov    %rsi,0x10(%rsp)
je     11bc <CAST_cfb64_encrypt+0xac>
test   %r12,%r12
je     123c <CAST_cfb64_encrypt+0x12c>
xor    %ebp,%ebp
mov    %rsp,%r15
jmp    1177 <CAST_cfb64_encrypt+0x67>
movslq %r14d,%rax
movzbl (%rbx,%rax,1),%ecx
xor    0x0(%r13,%rbp,1),%cl
mov    %cl,(%rsi,%rbp,1)
mov    %cl,(%rbx,%rax,1)
add    $0x1,%r14d
and    $0x7,%r14d
add    $0x1,%rbp
cmp    %rbp,%r12
je     123c <CAST_cfb64_encrypt+0x12c>
test   %r14d,%r14d
jne    1150 <CAST_cfb64_encrypt+0x40>
mov    (%rbx),%eax
shl    $0x20,%rax
bswap  %rax
mov    %rax,(%rsp)
mov    0x4(%rbx),%eax
shl    $0x20,%rax
bswap  %rax
mov    %rax,0x8(%rsp)
mov    %r15,%rdi
mov    0x18(%rsp),%rsi
call   1030 <CAST_encrypt@plt>
mov    0x10(%rsp),%rsi
mov    (%rsp),%eax
bswap  %eax
mov    %eax,(%rbx)
mov    0x8(%rsp),%eax
bswap  %eax
mov    %eax,0x4(%rbx)
jmp    1150 <CAST_cfb64_encrypt+0x40>
test   %r12,%r12
je     123c <CAST_cfb64_encrypt+0x12c>
xor    %r15d,%r15d
mov    %rsp,%rbp
jmp    11f7 <CAST_cfb64_encrypt+0xe7>
nopl   0x0(%rax)
movzbl 0x0(%r13,%r15,1),%eax
movslq %r14d,%rcx
movzbl (%rbx,%rcx,1),%edx
xor    %al,%dl
mov    %al,(%rbx,%rcx,1)
mov    %dl,(%rsi,%r15,1)
add    $0x1,%r14d
and    $0x7,%r14d
add    $0x1,%r15
cmp    %r15,%r12
je     123c <CAST_cfb64_encrypt+0x12c>
test   %r14d,%r14d
jne    11d0 <CAST_cfb64_encrypt+0xc0>
mov    (%rbx),%eax
shl    $0x20,%rax
bswap  %rax
mov    %rax,(%rsp)
mov    0x4(%rbx),%eax
shl    $0x20,%rax
bswap  %rax
mov    %rax,0x8(%rsp)
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
call   1030 <CAST_encrypt@plt>
mov    0x10(%rsp),%rsi
mov    (%rsp),%eax
bswap  %eax
mov    %eax,(%rbx)
mov    0x8(%rsp),%eax
bswap  %eax
mov    %eax,0x4(%rbx)
jmp    11d0 <CAST_cfb64_encrypt+0xc0>
mov    0x20(%rsp),%rax
mov    %r14d,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @CAST_cfb64_encrypt(i8* %0, i8* %1, i64 %2, i32* %3, i8* %4, i32* %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32
%19 = alloca i64
%20 = alloca [2 x i64]
%21 = alloca i8*
%22 = alloca i8
%23 = alloca i8
store i8* %0, i8** %8
store i8* %1, i8** %9
store i64 %2, i64* %10
store i32* %3, i32** %11
store i8* %4, i8** %12
store i32* %5, i32** %13
store i32 %6, i32* %14
%24 = load i32*, i32** %13
%25 = load i32, i32* %24
store i32 %25, i32* %18
%26 = load i64, i64* %10
store i64 %26, i64* %19
%27 = load i8*, i8** %12
store i8* %27, i8** %21
%28 = load i32, i32* %14
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %173
30: ; preds = %7
br label %31
31: ; preds = %148, %30
%32 = load i64, i64* %19
%33 = add nsw i64 %32, -1
store i64 %33, i64* %19
%34 = icmp ne i64 %32, 0
br i1 %34, label %35, label %172
35: ; preds = %31
%36 = load i32, i32* %18
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %148
38: ; preds = %35
%39 = load i8*, i8** %21
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %21
%41 = load i8, i8* %39
%42 = zext i8 %41 to i64
%43 = shl i64 %42, 24
store i64 %43, i64* %15
%44 = load i8*, i8** %21
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %21
%46 = load i8, i8* %44
%47 = zext i8 %46 to i64
%48 = shl i64 %47, 16
%49 = load i64, i64* %15
%50 = or i64 %49, %48
store i64 %50, i64* %15
%51 = load i8*, i8** %21
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %21
%53 = load i8, i8* %51
%54 = zext i8 %53 to i64
%55 = shl i64 %54, 8
%56 = load i64, i64* %15
%57 = or i64 %56, %55
store i64 %57, i64* %15
%58 = load i8*, i8** %21
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %21
%60 = load i8, i8* %58
%61 = zext i8 %60 to i64
%62 = load i64, i64* %15
%63 = or i64 %62, %61
store i64 %63, i64* %15
%64 = load i64, i64* %15
%65 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 0
store i64 %64, i64* %65
%66 = load i8*, i8** %21
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %21
%68 = load i8, i8* %66
%69 = zext i8 %68 to i64
%70 = shl i64 %69, 24
store i64 %70, i64* %16
%71 = load i8*, i8** %21
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %21
%73 = load i8, i8* %71
%74 = zext i8 %73 to i64
%75 = shl i64 %74, 16
%76 = load i64, i64* %16
%77 = or i64 %76, %75
store i64 %77, i64* %16
%78 = load i8*, i8** %21
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %21
%80 = load i8, i8* %78
%81 = zext i8 %80 to i64
%82 = shl i64 %81, 8
%83 = load i64, i64* %16
%84 = or i64 %83, %82
store i64 %84, i64* %16
%85 = load i8*, i8** %21
%86 = getelementptr inbounds i8, i8* %85, i32 1
store i8* %86, i8** %21
%87 = load i8, i8* %85
%88 = zext i8 %87 to i64
%89 = load i64, i64* %16
%90 = or i64 %89, %88
store i64 %90, i64* %16
%91 = load i64, i64* %16
%92 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 1
store i64 %91, i64* %92
%93 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 0
%94 = load i32*, i32** %11
%95 = call i32 @CAST_encrypt(i64* %93, i32* %94)
%96 = load i8*, i8** %12
store i8* %96, i8** %21
%97 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 0
%98 = load i64, i64* %97
store i64 %98, i64* %17
%99 = load i64, i64* %17
%100 = lshr i64 %99, 24
%101 = and i64 %100, 255
%102 = trunc i64 %101 to i8
%103 = load i8*, i8** %21
%104 = getelementptr inbounds i8, i8* %103, i32 1
store i8* %104, i8** %21
store i8 %102, i8* %103
%105 = load i64, i64* %17
%106 = lshr i64 %105, 16
%107 = and i64 %106, 255
%108 = trunc i64 %107 to i8
%109 = load i8*, i8** %21
%110 = getelementptr inbounds i8, i8* %109, i32 1
store i8* %110, i8** %21
store i8 %108, i8* %109
%111 = load i64, i64* %17
%112 = lshr i64 %111, 8
%113 = and i64 %112, 255
%114 = trunc i64 %113 to i8
%115 = load i8*, i8** %21
%116 = getelementptr inbounds i8, i8* %115, i32 1
store i8* %116, i8** %21
store i8 %114, i8* %115
%117 = load i64, i64* %17
%118 = and i64 %117, 255
%119 = trunc i64 %118 to i8
%120 = load i8*, i8** %21
%121 = getelementptr inbounds i8, i8* %120, i32 1
store i8* %121, i8** %21
store i8 %119, i8* %120
%122 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 1
%123 = load i64, i64* %122
store i64 %123, i64* %17
%124 = load i64, i64* %17
%125 = lshr i64 %124, 24
%126 = and i64 %125, 255
%127 = trunc i64 %126 to i8
%128 = load i8*, i8** %21
%129 = getelementptr inbounds i8, i8* %128, i32 1
store i8* %129, i8** %21
store i8 %127, i8* %128
%130 = load i64, i64* %17
%131 = lshr i64 %130, 16
%132 = and i64 %131, 255
%133 = trunc i64 %132 to i8
%134 = load i8*, i8** %21
%135 = getelementptr inbounds i8, i8* %134, i32 1
store i8* %135, i8** %21
store i8 %133, i8* %134
%136 = load i64, i64* %17
%137 = lshr i64 %136, 8
%138 = and i64 %137, 255
%139 = trunc i64 %138 to i8
%140 = load i8*, i8** %21
%141 = getelementptr inbounds i8, i8* %140, i32 1
store i8* %141, i8** %21
store i8 %139, i8* %140
%142 = load i64, i64* %17
%143 = and i64 %142, 255
%144 = trunc i64 %143 to i8
%145 = load i8*, i8** %21
%146 = getelementptr inbounds i8, i8* %145, i32 1
store i8* %146, i8** %21
store i8 %144, i8* %145
%147 = load i8*, i8** %12
store i8* %147, i8** %21
br label %148
148: ; preds = %38, %35
%149 = load i8*, i8** %8
%150 = getelementptr inbounds i8, i8* %149, i32 1
store i8* %150, i8** %8
%151 = load i8, i8* %149
%152 = zext i8 %151 to i32
%153 = load i8*, i8** %21
%154 = load i32, i32* %18
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds i8, i8* %153, i64 %155
%157 = load i8, i8* %156
%158 = zext i8 %157 to i32
%159 = xor i32 %152, %158
%160 = trunc i32 %159 to i8
store i8 %160, i8* %22
%161 = load i8, i8* %22
%162 = load i8*, i8** %9
%163 = getelementptr inbounds i8, i8* %162, i32 1
store i8* %163, i8** %9
store i8 %161, i8* %162
%164 = load i8, i8* %22
%165 = load i8*, i8** %21
%166 = load i32, i32* %18
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i8, i8* %165, i64 %167
store i8 %164, i8* %168
%169 = load i32, i32* %18
%170 = add nsw i32 %169, 1
%171 = and i32 %170, 7
store i32 %171, i32* %18
br label %31
172: ; preds = %31
br label %317
173: ; preds = %7
br label %174
174: ; preds = %291, %173
%175 = load i64, i64* %19
%176 = add nsw i64 %175, -1
store i64 %176, i64* %19
%177 = icmp ne i64 %175, 0
br i1 %177, label %178, label %316
178: ; preds = %174
%179 = load i32, i32* %18
%180 = icmp eq i32 %179, 0
br i1 %180, label %181, label %291
181: ; preds = %178
%182 = load i8*, i8** %21
%183 = getelementptr inbounds i8, i8* %182, i32 1
store i8* %183, i8** %21
%184 = load i8, i8* %182
%185 = zext i8 %184 to i64
%186 = shl i64 %185, 24
store i64 %186, i64* %15
%187 = load i8*, i8** %21
%188 = getelementptr inbounds i8, i8* %187, i32 1
store i8* %188, i8** %21
%189 = load i8, i8* %187
%190 = zext i8 %189 to i64
%191 = shl i64 %190, 16
%192 = load i64, i64* %15
%193 = or i64 %192, %191
store i64 %193, i64* %15
%194 = load i8*, i8** %21
%195 = getelementptr inbounds i8, i8* %194, i32 1
store i8* %195, i8** %21
%196 = load i8, i8* %194
%197 = zext i8 %196 to i64
%198 = shl i64 %197, 8
%199 = load i64, i64* %15
%200 = or i64 %199, %198
store i64 %200, i64* %15
%201 = load i8*, i8** %21
%202 = getelementptr inbounds i8, i8* %201, i32 1
store i8* %202, i8** %21
%203 = load i8, i8* %201
%204 = zext i8 %203 to i64
%205 = load i64, i64* %15
%206 = or i64 %205, %204
store i64 %206, i64* %15
%207 = load i64, i64* %15
%208 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 0
store i64 %207, i64* %208
%209 = load i8*, i8** %21
%210 = getelementptr inbounds i8, i8* %209, i32 1
store i8* %210, i8** %21
%211 = load i8, i8* %209
%212 = zext i8 %211 to i64
%213 = shl i64 %212, 24
store i64 %213, i64* %16
%214 = load i8*, i8** %21
%215 = getelementptr inbounds i8, i8* %214, i32 1
store i8* %215, i8** %21
%216 = load i8, i8* %214
%217 = zext i8 %216 to i64
%218 = shl i64 %217, 16
%219 = load i64, i64* %16
%220 = or i64 %219, %218
store i64 %220, i64* %16
%221 = load i8*, i8** %21
%222 = getelementptr inbounds i8, i8* %221, i32 1
store i8* %222, i8** %21
%223 = load i8, i8* %221
%224 = zext i8 %223 to i64
%225 = shl i64 %224, 8
%226 = load i64, i64* %16
%227 = or i64 %226, %225
store i64 %227, i64* %16
%228 = load i8*, i8** %21
%229 = getelementptr inbounds i8, i8* %228, i32 1
store i8* %229, i8** %21
%230 = load i8, i8* %228
%231 = zext i8 %230 to i64
%232 = load i64, i64* %16
%233 = or i64 %232, %231
store i64 %233, i64* %16
%234 = load i64, i64* %16
%235 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 1
store i64 %234, i64* %235
%236 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 0
%237 = load i32*, i32** %11
%238 = call i32 @CAST_encrypt(i64* %236, i32* %237)
%239 = load i8*, i8** %12
store i8* %239, i8** %21
%240 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 0
%241 = load i64, i64* %240
store i64 %241, i64* %17
%242 = load i64, i64* %17
%243 = lshr i64 %242, 24
%244 = and i64 %243, 255
%245 = trunc i64 %244 to i8
%246 = load i8*, i8** %21
%247 = getelementptr inbounds i8, i8* %246, i32 1
store i8* %247, i8** %21
store i8 %245, i8* %246
%248 = load i64, i64* %17
%249 = lshr i64 %248, 16
%250 = and i64 %249, 255
%251 = trunc i64 %250 to i8
%252 = load i8*, i8** %21
%253 = getelementptr inbounds i8, i8* %252, i32 1
store i8* %253, i8** %21
store i8 %251, i8* %252
%254 = load i64, i64* %17
%255 = lshr i64 %254, 8
%256 = and i64 %255, 255
%257 = trunc i64 %256 to i8
%258 = load i8*, i8** %21
%259 = getelementptr inbounds i8, i8* %258, i32 1
store i8* %259, i8** %21
store i8 %257, i8* %258
%260 = load i64, i64* %17
%261 = and i64 %260, 255
%262 = trunc i64 %261 to i8
%263 = load i8*, i8** %21
%264 = getelementptr inbounds i8, i8* %263, i32 1
store i8* %264, i8** %21
store i8 %262, i8* %263
%265 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 1
%266 = load i64, i64* %265
store i64 %266, i64* %17
%267 = load i64, i64* %17
%268 = lshr i64 %267, 24
%269 = and i64 %268, 255
%270 = trunc i64 %269 to i8
%271 = load i8*, i8** %21
%272 = getelementptr inbounds i8, i8* %271, i32 1
store i8* %272, i8** %21
store i8 %270, i8* %271
%273 = load i64, i64* %17
%274 = lshr i64 %273, 16
%275 = and i64 %274, 255
%276 = trunc i64 %275 to i8
%277 = load i8*, i8** %21
%278 = getelementptr inbounds i8, i8* %277, i32 1
store i8* %278, i8** %21
store i8 %276, i8* %277
%279 = load i64, i64* %17
%280 = lshr i64 %279, 8
%281 = and i64 %280, 255
%282 = trunc i64 %281 to i8
%283 = load i8*, i8** %21
%284 = getelementptr inbounds i8, i8* %283, i32 1
store i8* %284, i8** %21
store i8 %282, i8* %283
%285 = load i64, i64* %17
%286 = and i64 %285, 255
%287 = trunc i64 %286 to i8
%288 = load i8*, i8** %21
%289 = getelementptr inbounds i8, i8* %288, i32 1
store i8* %289, i8** %21
store i8 %287, i8* %288
%290 = load i8*, i8** %12
store i8* %290, i8** %21
br label %291
291: ; preds = %181, %178
%292 = load i8*, i8** %8
%293 = getelementptr inbounds i8, i8* %292, i32 1
store i8* %293, i8** %8
%294 = load i8, i8* %292
store i8 %294, i8* %23
%295 = load i8*, i8** %21
%296 = load i32, i32* %18
%297 = sext i32 %296 to i64
%298 = getelementptr inbounds i8, i8* %295, i64 %297
%299 = load i8, i8* %298
store i8 %299, i8* %22
%300 = load i8, i8* %23
%301 = load i8*, i8** %21
%302 = load i32, i32* %18
%303 = sext i32 %302 to i64
%304 = getelementptr inbounds i8, i8* %301, i64 %303
store i8 %300, i8* %304
%305 = load i8, i8* %22
%306 = zext i8 %305 to i32
%307 = load i8, i8* %23
%308 = zext i8 %307 to i32
%309 = xor i32 %306, %308
%310 = trunc i32 %309 to i8
%311 = load i8*, i8** %9
%312 = getelementptr inbounds i8, i8* %311, i32 1
store i8* %312, i8** %9
store i8 %310, i8* %311
%313 = load i32, i32* %18
%314 = add nsw i32 %313, 1
%315 = and i32 %314, 7
store i32 %315, i32* %18
br label %174
316: ; preds = %174
br label %317
317: ; preds = %316, %172
store i8 0, i8* %23
store i8 0, i8* %22
store i64 0, i64* %17
%318 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 1
store i64 0, i64* %318
%319 = getelementptr inbounds [2 x i64], [2 x i64]* %20, i64 0, i64 0
store i64 0, i64* %319
store i64 0, i64* %16
store i64 0, i64* %15
%320 = load i32, i32* %18
%321 = load i32*, i32** %13
store i32 %320, i32* %321
ret void
}

LLVM IR (-O2):
define void @CAST_cfb64_encrypt(i8* nocapture %0, i8* nocapture writeonly %1, i64 %2, i32* %3, i8* %4, i32* nocapture %5, i32 %6) {
%8 = alloca [2 x i64]
%9 = load i32, i32* %5
%10 = bitcast [2 x i64]* %8 to i8*
%11 = icmp eq i32 %6, 0
%12 = icmp eq i64 %2, 0
br i1 %11, label %24, label %13
13: ; preds = %7
br i1 %12, label %163, label %14
14: ; preds = %13
%15 = getelementptr inbounds i8, i8* %4, i64 1
%16 = getelementptr inbounds i8, i8* %4, i64 2
%17 = getelementptr inbounds i8, i8* %4, i64 3
%18 = getelementptr inbounds i8, i8* %4, i64 4
%19 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 0
%20 = getelementptr inbounds i8, i8* %4, i64 5
%21 = getelementptr inbounds i8, i8* %4, i64 6
%22 = getelementptr inbounds i8, i8* %4, i64 7
%23 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 1
br label %35
24: ; preds = %7
br i1 %12, label %163, label %25
25: ; preds = %24
%26 = getelementptr inbounds i8, i8* %4, i64 1
%27 = getelementptr inbounds i8, i8* %4, i64 2
%28 = getelementptr inbounds i8, i8* %4, i64 3
%29 = getelementptr inbounds i8, i8* %4, i64 4
%30 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 0
%31 = getelementptr inbounds i8, i8* %4, i64 5
%32 = getelementptr inbounds i8, i8* %4, i64 6
%33 = getelementptr inbounds i8, i8* %4, i64 7
%34 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 1
br label %99
35: ; preds = %14, %88
%36 = phi i64 [ %2, %14 ], [ %40, %88 ]
%37 = phi i32 [ %9, %14 ], [ %97, %88 ]
%38 = phi i8* [ %0, %14 ], [ %89, %88 ]
%39 = phi i8* [ %1, %14 ], [ %95, %88 ]
%40 = add nsw i64 %36, -1
%41 = icmp eq i32 %37, 0
br i1 %41, label %42, label %88
42: ; preds = %35
%43 = load i8, i8* %4
%44 = zext i8 %43 to i64
%45 = shl nuw nsw i64 %44, 24
%46 = load i8, i8* %15
%47 = zext i8 %46 to i64
%48 = shl nuw nsw i64 %47, 16
%49 = or i64 %48, %45
%50 = load i8, i8* %16
%51 = zext i8 %50 to i64
%52 = shl nuw nsw i64 %51, 8
%53 = or i64 %49, %52
%54 = load i8, i8* %17
%55 = zext i8 %54 to i64
%56 = or i64 %53, %55
store i64 %56, i64* %19
%57 = load i8, i8* %18
%58 = zext i8 %57 to i64
%59 = shl nuw nsw i64 %58, 24
%60 = load i8, i8* %20
%61 = zext i8 %60 to i64
%62 = shl nuw nsw i64 %61, 16
%63 = or i64 %62, %59
%64 = load i8, i8* %21
%65 = zext i8 %64 to i64
%66 = shl nuw nsw i64 %65, 8
%67 = or i64 %63, %66
%68 = load i8, i8* %22
%69 = zext i8 %68 to i64
%70 = or i64 %67, %69
store i64 %70, i64* %23
%71 = call i32 @CAST_encrypt(i64* %19, i32* %3)
%72 = load i64, i64* %19
%73 = lshr i64 %72, 24
%74 = trunc i64 %73 to i8
store i8 %74, i8* %4
%75 = lshr i64 %72, 16
%76 = trunc i64 %75 to i8
store i8 %76, i8* %15
%77 = lshr i64 %72, 8
%78 = trunc i64 %77 to i8
store i8 %78, i8* %16
%79 = trunc i64 %72 to i8
store i8 %79, i8* %17
%80 = load i64, i64* %23
%81 = lshr i64 %80, 24
%82 = trunc i64 %81 to i8
store i8 %82, i8* %18
%83 = lshr i64 %80, 16
%84 = trunc i64 %83 to i8
store i8 %84, i8* %20
%85 = lshr i64 %80, 8
%86 = trunc i64 %85 to i8
store i8 %86, i8* %21
%87 = trunc i64 %80 to i8
store i8 %87, i8* %22
br label %88
88: ; preds = %42, %35
%89 = getelementptr inbounds i8, i8* %38, i64 1
%90 = load i8, i8* %38
%91 = sext i32 %37 to i64
%92 = getelementptr inbounds i8, i8* %4, i64 %91
%93 = load i8, i8* %92
%94 = xor i8 %93, %90
%95 = getelementptr inbounds i8, i8* %39, i64 1
store i8 %94, i8* %39
store i8 %94, i8* %92
%96 = add nsw i32 %37, 1
%97 = and i32 %96, 7
%98 = icmp eq i64 %40, 0
br i1 %98, label %163, label %35
99: ; preds = %25, %152
%100 = phi i64 [ %2, %25 ], [ %104, %152 ]
%101 = phi i32 [ %9, %25 ], [ %161, %152 ]
%102 = phi i8* [ %0, %25 ], [ %153, %152 ]
%103 = phi i8* [ %1, %25 ], [ %159, %152 ]
%104 = add nsw i64 %100, -1
%105 = icmp eq i32 %101, 0
br i1 %105, label %106, label %152
106: ; preds = %99
%107 = load i8, i8* %4
%108 = zext i8 %107 to i64
%109 = shl nuw nsw i64 %108, 24
%110 = load i8, i8* %26
%111 = zext i8 %110 to i64
%112 = shl nuw nsw i64 %111, 16
%113 = or i64 %112, %109
%114 = load i8, i8* %27
%115 = zext i8 %114 to i64
%116 = shl nuw nsw i64 %115, 8
%117 = or i64 %113, %116
%118 = load i8, i8* %28
%119 = zext i8 %118 to i64
%120 = or i64 %117, %119
store i64 %120, i64* %30
%121 = load i8, i8* %29
%122 = zext i8 %121 to i64
%123 = shl nuw nsw i64 %122, 24
%124 = load i8, i8* %31
%125 = zext i8 %124 to i64
%126 = shl nuw nsw i64 %125, 16
%127 = or i64 %126, %123
%128 = load i8, i8* %32
%129 = zext i8 %128 to i64
%130 = shl nuw nsw i64 %129, 8
%131 = or i64 %127, %130
%132 = load i8, i8* %33
%133 = zext i8 %132 to i64
%134 = or i64 %131, %133
store i64 %134, i64* %34
%135 = call i32 @CAST_encrypt(i64* %30, i32* %3)
%136 = load i64, i64* %30
%137 = lshr i64 %136, 24
%138 = trunc i64 %137 to i8
store i8 %138, i8* %4
%139 = lshr i64 %136, 16
%140 = trunc i64 %139 to i8
store i8 %140, i8* %26
%141 = lshr i64 %136, 8
%142 = trunc i64 %141 to i8
store i8 %142, i8* %27
%143 = trunc i64 %136 to i8
store i8 %143, i8* %28
%144 = load i64, i64* %34
%145 = lshr i64 %144, 24
%146 = trunc i64 %145 to i8
store i8 %146, i8* %29
%147 = lshr i64 %144, 16
%148 = trunc i64 %147 to i8
store i8 %148, i8* %31
%149 = lshr i64 %144, 8
%150 = trunc i64 %149 to i8
store i8 %150, i8* %32
%151 = trunc i64 %144 to i8
store i8 %151, i8* %33
br label %152
152: ; preds = %106, %99
%153 = getelementptr inbounds i8, i8* %102, i64 1
%154 = load i8, i8* %102
%155 = sext i32 %101 to i64
%156 = getelementptr inbounds i8, i8* %4, i64 %155
%157 = load i8, i8* %156
store i8 %154, i8* %156
%158 = xor i8 %157, %154
%159 = getelementptr inbounds i8, i8* %103, i64 1
store i8 %158, i8* %103
%160 = add nsw i32 %101, 1
%161 = and i32 %160, 7
%162 = icmp eq i64 %104, 0
br i1 %162, label %163, label %99
163: ; preds = %88, %152, %13, %24
%164 = phi i32 [ %9, %24 ], [ %9, %13 ], [ %161, %152 ], [ %97, %88 ]
store i32 %164, i32* %5
ret void
}