#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*/ const uint64_t;

/* Variables and functions */
int /*<<< orphan*/ blkcpy(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *, size_t);
int /*<<< orphan*/ blkxor(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *, int);
int /*<<< orphan*/ block_pwxform(int /*<<< orphan*/ const *,
                                 int /*<<< orphan*/ const *);
int /*<<< orphan*/ salsa20_8(int /*<<< orphan*/ const *);
void blockmix_pwxform(const uint64_t *Bin, uint64_t *Bout, uint64_t *S,
                      size_t r) {
  size_t r1, r2, i;
  r1 = r * 128 / ((4 * 2) * 8);
  blkcpy(Bout, &Bin[(r1 - 1) * (4 * 2)], (4 * 2));
  blkxor(Bout, Bin, (4 * 2));
  block_pwxform(Bout, S);
  for (i = 1; i < r1; i++) {
    blkcpy(&Bout[i * (4 * 2)], &Bout[(i - 1) * (4 * 2)], (4 * 2));
    blkxor(&Bout[i * (4 * 2)], &Bin[i * (4 * 2)], (4 * 2));
    block_pwxform(&Bout[i * (4 * 2)], S);
  }
  if (i * (4 * 2) < r * 16)
    blkcpy(&Bout[i * (4 * 2)], &Bin[i * (4 * 2)], r * 16 - i * (4 * 2));
  i = (r1 - 1) * (4 * 2) / 8;
  r2 = r * 2;
  salsa20_8(&Bout[i * 8]);
  i++;
  for (; i < r2; i++) {
    blkxor(&Bout[i * 8], &Bout[(i - 1) * 8], 8);
    salsa20_8(&Bout[i * 8]);
  }
}


x86 assembly (clang, -O0):
<blockmix_pwxform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x7,%rax
shr    $0x6,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x8,%edx
call   1060 <blkcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1040 <blkxor@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <block_pwxform@plt>
movq   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1253 <blockmix_pwxform+0x113>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x38(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x8,%edx
call   1060 <blkcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x8,%edx
call   1040 <blkxor@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <block_pwxform@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11b4 <blockmix_pwxform+0x74>
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
mov    -0x20(%rbp),%rcx
shl    $0x4,%rcx
cmp    %rcx,%rax
jae    12aa <blockmix_pwxform+0x16a>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
shl    $0x4,%rdx
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
sub    %rax,%rdx
call   1060 <blkcpy@plt>
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
shr    $0x3,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1050 <salsa20_8@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1359 <blockmix_pwxform+0x219>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x38(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x8,%edx
call   1040 <blkxor@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1050 <salsa20_8@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    12ee <blockmix_pwxform+0x1ae>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blockmix_pwxform>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbp
mov    %rcx,0x20(%rsp)
lea    (%rcx,%rcx,1),%r14
movabs $0x3fffffffffffffe,%r15
ff ff 03
and    %r14,%r15
lea    0x0(,%r15,8),%rax
mov    %rax,0x18(%rsp)
lea    (%rdi,%rax,4),%rsi
add    $0xffffffffffffffe0,%rsi
mov    $0x8,%ebx
mov    $0x8,%edx
mov    %r13,%rdi
call   1060 <blkcpy@plt>
mov    %r13,%rdi
mov    %rbp,0x8(%rsp)
mov    %rbp,%rsi
mov    $0x8,%edx
call   1040 <blkxor@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <block_pwxform@plt>
test   %r15,%r15
je     1213 <blockmix_pwxform+0xd3>
mov    %r14,0x10(%rsp)
lea    -0x1(%r15),%r14
mov    0x8(%rsp),%rax
lea    0x20(%rax),%rbx
mov    %r13,%rsi
xchg   %ax,%ax
lea    0x20(%rsi),%rbp
mov    $0x8,%edx
mov    %rbp,%rdi
call   1060 <blkcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1040 <blkxor@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <block_pwxform@plt>
add    $0x20,%rbx
mov    %rbp,%rsi
add    $0xffffffffffffffff,%r14
jne    11d0 <blockmix_pwxform+0x90>
mov    0x18(%rsp),%rbx
mov    0x10(%rsp),%r14
lea    -0x8(,%r15,8),%rbp
ff
mov    0x20(%rsp),%rdx
shl    $0x4,%rdx
sub    %rbx,%rdx
jbe    1242 <blockmix_pwxform+0x102>
lea    0x0(,%rbx,4),%rdi
add    %r13,%rdi
mov    0x8(%rsp),%rax
lea    (%rax,%rbx,4),%rsi
call   1060 <blkcpy@plt>
lea    0x0(,%rbp,4),%rdi
add    %r13,%rdi
shr    $0x3,%rbp
call   1050 <salsa20_8@plt>
lea    0x1(%rbp),%rax
cmp    %r14,%rax
jae    1295 <blockmix_pwxform+0x155>
mov    %rbp,%rax
shl    $0x5,%rax
add    %rax,%r13
not    %rbp
add    %r14,%rbp
nop
lea    0x20(%r13),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x8,%edx
call   1040 <blkxor@plt>
mov    %rbx,%rdi
call   1050 <salsa20_8@plt>
mov    %rbx,%r13
add    $0xffffffffffffffff,%rbp
jne    1270 <blockmix_pwxform+0x130>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @blockmix_pwxform(i32* %0, i32* %1, i32* %2, i64 %3) {
%5 = shl i64 %3, 1
%6 = and i64 %5, 288230376151711742
%7 = shl nuw nsw i64 %6, 3
%8 = add nsw i64 %7, -8
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = tail call i32 @blkcpy(i32* %1, i32* %9, i64 8)
%11 = tail call i32 @blkxor(i32* %1, i32* %0, i32 8)
%12 = tail call i32 @block_pwxform(i32* %1, i32* %2)
%13 = icmp eq i64 %6, 0
br i1 %13, label %28, label %14
14: ; preds = %4, %14
%15 = phi i64 [ %24, %14 ], [ 1, %4 ]
%16 = shl i64 %15, 3
%17 = getelementptr inbounds i32, i32* %1, i64 %16
%18 = add nsw i64 %16, -8
%19 = getelementptr inbounds i32, i32* %1, i64 %18
%20 = tail call i32 @blkcpy(i32* %17, i32* %19, i64 8)
%21 = getelementptr inbounds i32, i32* %0, i64 %16
%22 = tail call i32 @blkxor(i32* %17, i32* %21, i32 8)
%23 = tail call i32 @block_pwxform(i32* %17, i32* %2)
%24 = add nuw nsw i64 %15, 1
%25 = icmp eq i64 %24, %6
br i1 %25, label %26, label %14
26: ; preds = %14
%27 = shl nuw nsw i64 %6, 3
br label %28
28: ; preds = %4, %26
%29 = phi i64 [ %27, %26 ], [ 8, %4 ]
%30 = shl i64 %3, 4
%31 = icmp ugt i64 %30, %29
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = getelementptr inbounds i32, i32* %1, i64 %29
%34 = getelementptr inbounds i32, i32* %0, i64 %29
%35 = sub i64 %30, %29
%36 = tail call i32 @blkcpy(i32* %33, i32* %34, i64 %35)
br label %37
37: ; preds = %32, %28
%38 = lshr exact i64 %8, 3
%39 = getelementptr inbounds i32, i32* %1, i64 %8
%40 = tail call i32 @salsa20_8(i32* %39)
%41 = add nuw nsw i64 %38, 1
%42 = icmp ult i64 %41, %5
br i1 %42, label %43, label %54
43: ; preds = %37, %43
%44 = phi i64 [ %52, %43 ], [ %41, %37 ]
%45 = phi i64 [ %44, %43 ], [ %38, %37 ]
%46 = shl i64 %44, 3
%47 = getelementptr inbounds i32, i32* %1, i64 %46
%48 = shl i64 %45, 3
%49 = getelementptr inbounds i32, i32* %1, i64 %48
%50 = tail call i32 @blkxor(i32* %47, i32* %49, i32 8)
%51 = tail call i32 @salsa20_8(i32* %47)
%52 = add nuw i64 %44, 1
%53 = icmp eq i64 %52, %5
br i1 %53, label %54, label %43
54: ; preds = %43, %37
ret void
}