#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 int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ gostcrypt(int *, int *, int const *);
void gostcfbencrypt(uint32_t const *in, uint32_t *out, int len, uint32_t iv[2],
                    uint32_t const key[8]) {
  while (len--) {
    gostcrypt(iv, iv, key);
    iv[0] = *out++ ^= iv[0];
    iv[1] = *out++ ^= iv[1];
  }
}


x86 assembly (clang, -O0):
<gostcfbencrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1195 <gostcfbencrypt+0x85>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <gostcrypt@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x10(%rbp)
xor    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x10(%rbp)
xor    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
jmp    112b <gostcfbencrypt+0x1b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gostcfbencrypt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
je     1169 <gostcfbencrypt+0x59>
mov    %r8,%r14
mov    %rcx,%r13
mov    %rsi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1030 <gostcrypt@plt>
mov    (%r15,%rbx,8),%eax
xor    0x0(%r13),%eax
mov    %eax,(%r15,%rbx,8)
mov    %eax,0x0(%r13)
mov    0x4(%r15,%rbx,8),%eax
xor    0x4(%r13),%eax
mov    %eax,0x4(%r15,%rbx,8)
mov    %eax,0x4(%r13)
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1130 <gostcfbencrypt+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @gostcfbencrypt(i32* %0, i32* %1, i32 %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32* %4, i32** %10
br label %11
11: ; preds = %15, %5
%12 = load i32, i32* %8
%13 = add nsw i32 %12, -1
store i32 %13, i32* %8
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %38
15: ; preds = %11
%16 = load i32*, i32** %9
%17 = load i32*, i32** %9
%18 = load i32*, i32** %10
%19 = call i32 @gostcrypt(i32* %16, i32* %17, i32* %18)
%20 = load i32*, i32** %9
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = load i32*, i32** %7
%24 = getelementptr inbounds i32, i32* %23, i32 1
store i32* %24, i32** %7
%25 = load i32, i32* %23
%26 = xor i32 %25, %22
store i32 %26, i32* %23
%27 = load i32*, i32** %9
%28 = getelementptr inbounds i32, i32* %27, i64 0
store i32 %26, i32* %28
%29 = load i32*, i32** %9
%30 = getelementptr inbounds i32, i32* %29, i64 1
%31 = load i32, i32* %30
%32 = load i32*, i32** %7
%33 = getelementptr inbounds i32, i32* %32, i32 1
store i32* %33, i32** %7
%34 = load i32, i32* %32
%35 = xor i32 %34, %31
store i32 %35, i32* %32
%36 = load i32*, i32** %9
%37 = getelementptr inbounds i32, i32* %36, i64 1
store i32 %35, i32* %37
br label %11
38: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @gostcfbencrypt(i32* nocapture readnone %0, i32* nocapture %1, i32 %2, i32* %3, i32* %4) {
%6 = icmp eq i32 %2, 0
br i1 %6, label %23, label %7
7: ; preds = %5
%8 = getelementptr inbounds i32, i32* %3, i64 1
br label %9
9: ; preds = %7, %9
%10 = phi i32* [ %1, %7 ], [ %19, %9 ]
%11 = phi i32 [ %2, %7 ], [ %12, %9 ]
%12 = add nsw i32 %11, -1
%13 = tail call i32 @gostcrypt(i32* %3, i32* %3, i32* %4)
%14 = load i32, i32* %3
%15 = getelementptr inbounds i32, i32* %10, i64 1
%16 = load i32, i32* %10
%17 = xor i32 %16, %14
store i32 %17, i32* %10
store i32 %17, i32* %3
%18 = load i32, i32* %8
%19 = getelementptr inbounds i32, i32* %10, i64 2
%20 = load i32, i32* %15
%21 = xor i32 %20, %18
store i32 %21, i32* %15
store i32 %21, i32* %8
%22 = icmp eq i32 %12, 0
br i1 %22, label %23, label %9
23: ; preds = %9, %5
ret void
}