#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_ofb64_encrypt(const unsigned char *in, unsigned char *out,
                        long length, const CAST_KEY *schedule,
                        unsigned char *ivec, int *num) {
  register CAST_LONG v0, v1, t;
  register int n = *num;
  register long l = length;
  unsigned char d[8];
  register char *dp;
  CAST_LONG ti[2];
  unsigned char *iv;
  int save = 0;
  iv = ivec;
  (v0 = ((unsigned long)(*((iv)++))) << 24L,
   v0 |= ((unsigned long)(*((iv)++))) << 16L,
   v0 |= ((unsigned long)(*((iv)++))) << 8L,
   v0 |= ((unsigned long)(*((iv)++))));
  (v1 = ((unsigned long)(*((iv)++))) << 24L,
   v1 |= ((unsigned long)(*((iv)++))) << 16L,
   v1 |= ((unsigned long)(*((iv)++))) << 8L,
   v1 |= ((unsigned long)(*((iv)++))));
  ti[0] = v0;
  ti[1] = v1;
  dp = (char *)d;
  (*((dp)++) = (unsigned char)(((v0) >> 24L) & 0xff),
   *((dp)++) = (unsigned char)(((v0) >> 16L) & 0xff),
   *((dp)++) = (unsigned char)(((v0) >> 8L) & 0xff),
   *((dp)++) = (unsigned char)(((v0)) & 0xff));
  (*((dp)++) = (unsigned char)(((v1) >> 24L) & 0xff),
   *((dp)++) = (unsigned char)(((v1) >> 16L) & 0xff),
   *((dp)++) = (unsigned char)(((v1) >> 8L) & 0xff),
   *((dp)++) = (unsigned char)(((v1)) & 0xff));
  while (l--) {
    if (n == 0) {
      CAST_encrypt((CAST_LONG *)ti, schedule);
      dp = (char *)d;
      t = ti[0];
      (*((dp)++) = (unsigned char)(((t) >> 24L) & 0xff),
       *((dp)++) = (unsigned char)(((t) >> 16L) & 0xff),
       *((dp)++) = (unsigned char)(((t) >> 8L) & 0xff),
       *((dp)++) = (unsigned char)(((t)) & 0xff));
      t = ti[1];
      (*((dp)++) = (unsigned char)(((t) >> 24L) & 0xff),
       *((dp)++) = (unsigned char)(((t) >> 16L) & 0xff),
       *((dp)++) = (unsigned char)(((t) >> 8L) & 0xff),
       *((dp)++) = (unsigned char)(((t)) & 0xff));
      save++;
    }
    *(out++) = *(in++) ^ d[n];
    n = (n + 1) & 0x07;
  }
  if (save) {
    v0 = ti[0];
    v1 = ti[1];
    iv = ivec;
    (*((iv)++) = (unsigned char)(((v0) >> 24L) & 0xff),
     *((iv)++) = (unsigned char)(((v0) >> 16L) & 0xff),
     *((iv)++) = (unsigned char)(((v0) >> 8L) & 0xff),
     *((iv)++) = (unsigned char)(((v0)) & 0xff));
    (*((iv)++) = (unsigned char)(((v1) >> 24L) & 0xff),
     *((iv)++) = (unsigned char)(((v1) >> 16L) & 0xff),
     *((iv)++) = (unsigned char)(((v1) >> 8L) & 0xff),
     *((iv)++) = (unsigned char)(((v1)) & 0xff));
  }
  t = v0 = v1 = ti[0] = ti[1] = 0;
  *num = n;
}


x86 assembly (clang, -O0):
<CAST_ofb64_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
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)
movl   $0x0,-0x8c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x88(%rbp)
movzbl (%rax),%eax
shl    $0x18,%rax
mov    %rax,-0x38(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x88(%rbp)
movzbl (%rax),%eax
shl    $0x10,%rax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x88(%rbp)
movzbl (%rax),%eax
shl    $0x8,%rax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x88(%rbp)
movzbl (%rax),%eax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x88(%rbp)
movzbl (%rax),%eax
shl    $0x18,%rax
mov    %rax,-0x40(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x88(%rbp)
movzbl (%rax),%eax
shl    $0x10,%rax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x88(%rbp)
movzbl (%rax),%eax
shl    $0x8,%rax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x88(%rbp)
movzbl (%rax),%eax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x38(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x58(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x58(%rbp)
cmp    $0x0,%rax
je     1519 <CAST_ofb64_encrypt+0x409>
cmpl   $0x0,-0x4c(%rbp)
jne    14d8 <CAST_ofb64_encrypt+0x3c8>
lea    -0x80(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <CAST_encrypt@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x78(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x48(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x68(%rbp)
mov    %cl,(%rax)
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movzbl (%rax),%eax
movslq -0x4c(%rbp),%rcx
movzbl -0x60(%rbp,%rcx,1),%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    1381 <CAST_ofb64_encrypt+0x271>
cmpl   $0x0,-0x8c(%rbp)
je     1671 <CAST_ofb64_encrypt+0x561>
mov    -0x80(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x38(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x88(%rbp)
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x88(%rbp)
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x88(%rbp)
mov    %cl,(%rax)
mov    -0x38(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x88(%rbp)
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x88(%rbp)
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x88(%rbp)
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x88(%rbp)
mov    %cl,(%rax)
mov    -0x40(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x88(%rbp)
mov    %cl,(%rax)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x4c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CAST_ofb64_encrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,%r10
mov    %r8,%r11
mov    %rcx,0x30(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r13
mov    (%r9),%r14d
movzbl (%r8),%r8d
movzbl 0x1(%r11),%r9d
movzbl 0x2(%r11),%ecx
movzbl 0x3(%r11),%esi
movzbl 0x4(%r11),%edi
movzbl 0x5(%r11),%ebp
movzbl 0x6(%r11),%eax
mov    %r11,0x28(%rsp)
movzbl 0x7(%r11),%edx
mov    %r8b,(%rsp)
shl    $0x18,%r8
mov    %r9b,0x1(%rsp)
shl    $0x10,%r9
or     %r8,%r9
mov    %cl,0x2(%rsp)
shl    $0x8,%rcx
or     %r9,%rcx
or     %rsi,%rcx
mov    %sil,0x3(%rsp)
mov    %dil,0x4(%rsp)
shl    $0x18,%rdi
mov    %bpl,0x5(%rsp)
shl    $0x10,%rbp
or     %rdi,%rbp
mov    %al,0x6(%rsp)
shl    $0x8,%rax
or     %rbp,%rax
or     %rdx,%rax
mov    %dl,0x7(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rax,0x18(%rsp)
test   %rbx,%rbx
je     1264 <CAST_ofb64_encrypt+0x154>
mov    %r10,0x8(%rsp)
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    11f1 <CAST_ofb64_encrypt+0xe1>
xchg   %ax,%ax
movslq %r14d,%rdx
movzbl (%rsp,%rdx,1),%edx
xor    0x0(%r13,%r15,1),%dl
mov    %dl,(%r12,%r15,1)
add    $0x1,%r14d
and    $0x7,%r14d
add    $0x1,%r15
cmp    %r15,%rbx
je     1223 <CAST_ofb64_encrypt+0x113>
test   %r14d,%r14d
jne    11d0 <CAST_ofb64_encrypt+0xc0>
lea    0x10(%rsp),%rdi
mov    0x30(%rsp),%rsi
call   1030 <CAST_encrypt@plt>
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%rax
mov    %ecx,%edx
bswap  %edx
mov    %edx,(%rsp)
mov    %eax,%edx
bswap  %edx
mov    %edx,0x4(%rsp)
add    $0x1,%ebp
jmp    11d0 <CAST_ofb64_encrypt+0xc0>
test   %ebp,%ebp
je     125f <CAST_ofb64_encrypt+0x14f>
mov    %rcx,%rdx
shr    $0x18,%rdx
mov    0x28(%rsp),%rsi
mov    %dl,(%rsi)
mov    %rcx,%rdx
shr    $0x10,%rdx
mov    %dl,0x1(%rsi)
mov    %ch,0x2(%rsi)
mov    %cl,0x3(%rsi)
mov    %rax,%rcx
shr    $0x18,%rcx
mov    %cl,0x4(%rsi)
mov    %rax,%rcx
shr    $0x10,%rcx
mov    %cl,0x5(%rsi)
mov    %ah,0x6(%rsi)
mov    %al,0x7(%rsi)
mov    0x8(%rsp),%r10
mov    %r14d,(%r10)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @CAST_ofb64_encrypt(i8* nocapture %0, i8* nocapture writeonly %1, i64 %2, i32* %3, i8* nocapture %4, i32* nocapture %5) {
%7 = alloca [8 x i8]
%8 = alloca [2 x i64]
%9 = load i32, i32* %5
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%11 = bitcast [2 x i64]* %8 to i8*
%12 = getelementptr inbounds i8, i8* %4, i64 1
%13 = load i8, i8* %4
%14 = zext i8 %13 to i64
%15 = shl nuw nsw i64 %14, 24
%16 = getelementptr inbounds i8, i8* %4, i64 2
%17 = load i8, i8* %12
%18 = zext i8 %17 to i64
%19 = shl nuw nsw i64 %18, 16
%20 = or i64 %19, %15
%21 = getelementptr inbounds i8, i8* %4, i64 3
%22 = load i8, i8* %16
%23 = zext i8 %22 to i64
%24 = shl nuw nsw i64 %23, 8
%25 = or i64 %20, %24
%26 = getelementptr inbounds i8, i8* %4, i64 4
%27 = load i8, i8* %21
%28 = zext i8 %27 to i64
%29 = or i64 %25, %28
%30 = getelementptr inbounds i8, i8* %4, i64 5
%31 = load i8, i8* %26
%32 = zext i8 %31 to i64
%33 = shl nuw nsw i64 %32, 24
%34 = getelementptr inbounds i8, i8* %4, i64 6
%35 = load i8, i8* %30
%36 = zext i8 %35 to i64
%37 = shl nuw nsw i64 %36, 16
%38 = or i64 %37, %33
%39 = getelementptr inbounds i8, i8* %4, i64 7
%40 = load i8, i8* %34
%41 = zext i8 %40 to i64
%42 = shl nuw nsw i64 %41, 8
%43 = or i64 %38, %42
%44 = load i8, i8* %39
%45 = zext i8 %44 to i64
%46 = or i64 %43, %45
%47 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 0
store i64 %29, i64* %47
%48 = getelementptr inbounds [2 x i64], [2 x i64]* %8, i64 0, i64 1
store i64 %46, i64* %48
%49 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 1
store i8 %13, i8* %10
%50 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 2
store i8 %17, i8* %49
%51 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 3
store i8 %22, i8* %50
%52 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 4
store i8 %27, i8* %51
%53 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 5
store i8 %31, i8* %52
%54 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 6
store i8 %35, i8* %53
%55 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 7
store i8 %40, i8* %54
store i8 %44, i8* %55
%56 = icmp eq i64 %2, 0
br i1 %56, label %117, label %57
57: ; preds = %6, %86
%58 = phi i64 [ %87, %86 ], [ %46, %6 ]
%59 = phi i64 [ %88, %86 ], [ %29, %6 ]
%60 = phi i64 [ %65, %86 ], [ %2, %6 ]
%61 = phi i32 [ %89, %86 ], [ 0, %6 ]
%62 = phi i32 [ %98, %86 ], [ %9, %6 ]
%63 = phi i8* [ %90, %86 ], [ %0, %6 ]
%64 = phi i8* [ %96, %86 ], [ %1, %6 ]
%65 = add nsw i64 %60, -1
%66 = icmp eq i32 %62, 0
br i1 %66, label %67, label %86
67: ; preds = %57
%68 = call i32 @CAST_encrypt(i64* %47, i32* %3)
%69 = load i64, i64* %47
%70 = lshr i64 %69, 24
%71 = trunc i64 %70 to i8
store i8 %71, i8* %10
%72 = lshr i64 %69, 16
%73 = trunc i64 %72 to i8
store i8 %73, i8* %49
%74 = lshr i64 %69, 8
%75 = trunc i64 %74 to i8
store i8 %75, i8* %50
%76 = trunc i64 %69 to i8
store i8 %76, i8* %51
%77 = load i64, i64* %48
%78 = lshr i64 %77, 24
%79 = trunc i64 %78 to i8
store i8 %79, i8* %52
%80 = lshr i64 %77, 16
%81 = trunc i64 %80 to i8
store i8 %81, i8* %53
%82 = lshr i64 %77, 8
%83 = trunc i64 %82 to i8
store i8 %83, i8* %54
%84 = trunc i64 %77 to i8
store i8 %84, i8* %55
%85 = add nsw i32 %61, 1
br label %86
86: ; preds = %67, %57
%87 = phi i64 [ %77, %67 ], [ %58, %57 ]
%88 = phi i64 [ %69, %67 ], [ %59, %57 ]
%89 = phi i32 [ %85, %67 ], [ %61, %57 ]
%90 = getelementptr inbounds i8, i8* %63, i64 1
%91 = load i8, i8* %63
%92 = sext i32 %62 to i64
%93 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = xor i8 %94, %91
%96 = getelementptr inbounds i8, i8* %64, i64 1
store i8 %95, i8* %64
%97 = add nsw i32 %62, 1
%98 = and i32 %97, 7
%99 = icmp eq i64 %65, 0
br i1 %99, label %100, label %57
100: ; preds = %86
%101 = icmp eq i32 %89, 0
br i1 %101, label %117, label %102
102: ; preds = %100
%103 = lshr i64 %88, 24
%104 = trunc i64 %103 to i8
store i8 %104, i8* %4
%105 = lshr i64 %88, 16
%106 = trunc i64 %105 to i8
store i8 %106, i8* %12
%107 = lshr i64 %88, 8
%108 = trunc i64 %107 to i8
store i8 %108, i8* %16
%109 = trunc i64 %88 to i8
store i8 %109, i8* %21
%110 = lshr i64 %87, 24
%111 = trunc i64 %110 to i8
store i8 %111, i8* %26
%112 = lshr i64 %87, 16
%113 = trunc i64 %112 to i8
store i8 %113, i8* %30
%114 = lshr i64 %87, 8
%115 = trunc i64 %114 to i8
store i8 %115, i8* %34
%116 = trunc i64 %87 to i8
store i8 %116, i8* %39
br label %117
117: ; preds = %6, %102, %100
%118 = phi i32 [ %98, %102 ], [ %98, %100 ], [ %9, %6 ]
store i32 %118, i32* %5
ret void
}