#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 F(int, int);
void gost_encrypt(uint32_t *out, const uint32_t *in) {
  uint32_t A = in[0];
  uint32_t B = in[1];
  for (int i = 0; i < 32; i++) {
    uint32_t A1 = B ^ F(A, i);
    B = A;
    A = A1;
  }
  out[0] = B;
  out[1] = A;
}


x86 assembly (clang, -O0):
<gost_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jge    1179 <gost_encrypt+0x69>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <F@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
xor    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <gost_encrypt+0x2a>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gost_encrypt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rsi),%eax
mov    0x4(%rsi),%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%r15d
mov    %eax,%ebp
mov    %eax,%edi
mov    %ebx,%esi
call   1030 <F@plt>
xor    %r15d,%eax
add    $0x1,%ebx
cmp    $0x20,%ebx
jne    1130 <gost_encrypt+0x20>
mov    %ebp,(%r14)
mov    %eax,0x4(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @gost_encrypt(i32* nocapture writeonly %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = getelementptr inbounds i32, i32* %1, i64 1
%5 = load i32, i32* %4
br label %8
6: ; preds = %8
store i32 %9, i32* %0
%7 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %13, i32* %7
ret void
8: ; preds = %2, %8
%9 = phi i32 [ %3, %2 ], [ %13, %8 ]
%10 = phi i32 [ 0, %2 ], [ %14, %8 ]
%11 = phi i32 [ %5, %2 ], [ %9, %8 ]
%12 = tail call i32 @F(i32 %9, i32 %10)
%13 = xor i32 %12, %11
%14 = add nuw nsw i32 %10, 1
%15 = icmp eq i32 %14, 32
br i1 %15, label %6, label %8
}