#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 /*<<< orphan*/ uint32_t;

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


x86 assembly (clang, -O0):
<gostcfbdecrypt>:
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     11ad <gostcfbdecrypt+0x9d>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <gostcrypt@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
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    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
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    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
jmp    112b <gostcfbdecrypt+0x1b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gostcfbdecrypt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
je     116d <gostcfbdecrypt+0x5d>
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
mov    0x0(%r13),%ecx
xor    %eax,%ecx
mov    %ecx,(%r15,%rbx,8)
mov    %eax,0x0(%r13)
mov    0x4(%r15,%rbx,8),%eax
mov    0x4(%r13),%ecx
xor    %eax,%ecx
mov    %ecx,0x4(%r15,%rbx,8)
mov    %eax,0x4(%r13)
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1130 <gostcfbdecrypt+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @gostcfbdecrypt(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*
%11 = 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 %12
12: ; preds = %16, %5
%13 = load i32, i32* %8
%14 = add nsw i32 %13, -1
store i32 %14, i32* %8
%15 = icmp ne i32 %13, 0
br i1 %15, label %16, label %45
16: ; preds = %12
%17 = load i32*, i32** %9
%18 = load i32*, i32** %9
%19 = load i32*, i32** %10
%20 = call i32 @gostcrypt(i32* %17, i32* %18, i32* %19)
%21 = load i32*, i32** %7
%22 = load i32, i32* %21
store i32 %22, i32* %11
%23 = load i32*, i32** %9
%24 = getelementptr inbounds i32, i32* %23, i64 0
%25 = load i32, i32* %24
%26 = load i32*, i32** %7
%27 = getelementptr inbounds i32, i32* %26, i32 1
store i32* %27, i32** %7
%28 = load i32, i32* %26
%29 = xor i32 %28, %25
store i32 %29, i32* %26
%30 = load i32, i32* %11
%31 = load i32*, i32** %9
%32 = getelementptr inbounds i32, i32* %31, i64 0
store i32 %30, i32* %32
%33 = load i32*, i32** %7
%34 = load i32, i32* %33
store i32 %34, i32* %11
%35 = load i32*, i32** %9
%36 = getelementptr inbounds i32, i32* %35, i64 1
%37 = load i32, i32* %36
%38 = load i32*, i32** %7
%39 = getelementptr inbounds i32, i32* %38, i32 1
store i32* %39, i32** %7
%40 = load i32, i32* %38
%41 = xor i32 %40, %37
store i32 %41, i32* %38
%42 = load i32, i32* %11
%43 = load i32*, i32** %9
%44 = getelementptr inbounds i32, i32* %43, i64 1
store i32 %42, i32* %44
br label %12
45: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @gostcfbdecrypt(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 ], [ %20, %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* %10
%15 = load i32, i32* %3
%16 = getelementptr inbounds i32, i32* %10, i64 1
%17 = xor i32 %15, %14
store i32 %17, i32* %10
store i32 %14, i32* %3
%18 = load i32, i32* %16
%19 = load i32, i32* %8
%20 = getelementptr inbounds i32, i32* %10, i64 2
%21 = xor i32 %19, %18
store i32 %21, i32* %16
store i32 %18, i32* %8
%22 = icmp eq i32 %12, 0
br i1 %22, label %23, label %9
23: ; preds = %9, %5
ret void
}