#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 const *, int *, int const *);
void gostofb(uint32_t const *in, uint32_t *out, int len, uint32_t const iv[2],
             uint32_t const key[8]) {
  uint32_t temp[2];
  uint32_t gamma[2];
  gostcrypt(iv, temp, key);
  while (len--) {
    temp[0] += 0x01010101;
    if (temp[0] < 0x01010101)
      temp[0]++;
    temp[1] += 0x01010104;
    if (temp[1] < 0x01010104)
      temp[1]++;
    gostcrypt(temp, gamma, key);
    *out++ = *in++ ^ gamma[0];
    *out++ = *in++ ^ gamma[1];
  }
}


x86 assembly (clang, -O0):
<gostofb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <gostcrypt@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11f2 <gostofb+0xe2>
mov    -0x30(%rbp),%eax
add    $0x1010101,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x1010101,-0x30(%rbp)
jge    1171 <gostofb+0x61>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1010104,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x1010104,-0x2c(%rbp)
jge    1192 <gostofb+0x82>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <gostcrypt@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%ecx
xor    -0x38(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%ecx
xor    -0x34(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x10(%rbp)
mov    %ecx,(%rax)
jmp    113c <gostofb+0x2c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gostofb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
mov    %rcx,%rdi
mov    %r8,%rdx
call   1030 <gostcrypt@plt>
test   %ebp,%ebp
je     11ab <gostofb+0x9b>
mov    %ebp,%ebp
xor    %r12d,%r12d
lea    0x10(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
mov    %eax,%edx
shr    $0x1f,%edx
add    %edx,%eax
add    $0x1010101,%eax
mov    %eax,0x8(%rsp)
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
add    $0x1010104,%eax
mov    %eax,0xc(%rsp)
lea    0x8(%rsp),%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1030 <gostcrypt@plt>
mov    0x10(%rsp),%eax
xor    (%rbx,%r12,8),%eax
mov    %eax,(%r15,%r12,8)
mov    0x14(%rsp),%eax
xor    0x4(%rbx,%r12,8),%eax
mov    %eax,0x4(%r15,%r12,8)
add    $0x1,%r12
cmp    %r12d,%ebp
jne    1150 <gostofb+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gostofb(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 [2 x i32]
%12 = alloca [2 x 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
%13 = load i32*, i32** %9
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%15 = load i32*, i32** %10
%16 = call i32 @gostcrypt(i32* %13, i32* %14, i32* %15)
br label %17
17: ; preds = %43, %5
%18 = load i32, i32* %8
%19 = add nsw i32 %18, -1
store i32 %19, i32* %8
%20 = icmp ne i32 %18, 0
br i1 %20, label %21, label %64
21: ; preds = %17
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%23 = load i32, i32* %22
%24 = add nsw i32 %23, 16843009
store i32 %24, i32* %22
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%26 = load i32, i32* %25
%27 = icmp slt i32 %26, 16843009
br i1 %27, label %28, label %32
28: ; preds = %21
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
br label %32
32: ; preds = %28, %21
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 16843012
store i32 %35, i32* %33
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%37 = load i32, i32* %36
%38 = icmp slt i32 %37, 16843012
br i1 %38, label %39, label %43
39: ; preds = %32
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%41 = load i32, i32* %40
%42 = add nsw i32 %41, 1
store i32 %42, i32* %40
br label %43
43: ; preds = %39, %32
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%46 = load i32*, i32** %10
%47 = call i32 @gostcrypt(i32* %44, i32* %45, i32* %46)
%48 = load i32*, i32** %6
%49 = getelementptr inbounds i32, i32* %48, i32 1
store i32* %49, i32** %6
%50 = load i32, i32* %48
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%52 = load i32, i32* %51
%53 = xor i32 %50, %52
%54 = load i32*, i32** %7
%55 = getelementptr inbounds i32, i32* %54, i32 1
store i32* %55, i32** %7
store i32 %53, i32* %54
%56 = load i32*, i32** %6
%57 = getelementptr inbounds i32, i32* %56, i32 1
store i32* %57, i32** %6
%58 = load i32, i32* %56
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%60 = load i32, i32* %59
%61 = xor i32 %58, %60
%62 = load i32*, i32** %7
%63 = getelementptr inbounds i32, i32* %62, i32 1
store i32* %63, i32** %7
store i32 %61, i32* %62
br label %17
64: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @gostofb(i32* nocapture %0, i32* nocapture writeonly %1, i32 %2, i32* %3, i32* %4) {
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = bitcast [2 x i32]* %6 to i8*
%9 = bitcast [2 x i32]* %7 to i8*
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%11 = call i32 @gostcrypt(i32* %3, i32* %10, i32* %4)
%12 = icmp eq i32 %2, 0
br i1 %12, label %42, label %13
13: ; preds = %5
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
br label %17
17: ; preds = %13, %17
%18 = phi i32* [ %0, %13 ], [ %36, %17 ]
%19 = phi i32* [ %1, %13 ], [ %40, %17 ]
%20 = phi i32 [ %2, %13 ], [ %21, %17 ]
%21 = add nsw i32 %20, -1
%22 = load i32, i32* %10
%23 = icmp slt i32 %22, 0
%24 = select i1 %23, i32 16843010, i32 16843009
%25 = add nsw i32 %24, %22
store i32 %25, i32* %10
%26 = load i32, i32* %14
%27 = icmp slt i32 %26, 0
%28 = select i1 %27, i32 16843013, i32 16843012
%29 = add nsw i32 %28, %26
store i32 %29, i32* %14
%30 = call i32 @gostcrypt(i32* %10, i32* %15, i32* %4)
%31 = getelementptr inbounds i32, i32* %18, i64 1
%32 = load i32, i32* %18
%33 = load i32, i32* %15
%34 = xor i32 %33, %32
%35 = getelementptr inbounds i32, i32* %19, i64 1
store i32 %34, i32* %19
%36 = getelementptr inbounds i32, i32* %18, i64 2
%37 = load i32, i32* %31
%38 = load i32, i32* %16
%39 = xor i32 %38, %37
%40 = getelementptr inbounds i32, i32* %19, i64 2
store i32 %39, i32* %35
%41 = icmp eq i32 %21, 0
br i1 %41, label %42, label %17
42: ; preds = %17, %5
ret void
}