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

/* Variables and functions */
int /*<<< orphan*/ memcpy(int *, int const *, int);
void chacha_setup(uint32_t X[16], const uint32_t key[8], uint64_t n,
                  uint64_t l) {
  memcpy(&X[4], key, 8 * sizeof(uint32_t));
  X[0] = 1145093211;
  X[1] = 1566258456;
  X[2] = 440612657;
  X[3] = 1721837295;
  X[12] = (int32_t)n;
  X[13] = (int32_t)l;
  n >>= 32;
  l >>= 32;
  X[14] = (int32_t)n;
  X[15] = (int32_t)l;
}


x86 assembly (clang, -O0):
<chacha_setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x20,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
movl   $0x4440bc5b,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x5d5b3518,0x4(%rax)
mov    -0x8(%rbp),%rax
movl   $0x1a433731,0x8(%rax)
mov    -0x8(%rbp),%rax
movl   $0x66a126ef,0xc(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x34(%rax)
mov    -0x14(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x38(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x3c(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chacha_setup>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rdi,%rbx
add    $0x10,%rdi
mov    $0x20,%edx
call   1030 <memcpy@plt>
movaps 0xecf(%rip),%xmm0
movups %xmm0,(%rbx)
mov    %ebp,0x30(%rbx)
mov    %r14d,0x34(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @chacha_setup(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32*, i32** %5
%10 = getelementptr inbounds i32, i32* %9, i64 4
%11 = load i32*, i32** %6
%12 = call i32 @memcpy(i32* %10, i32* %11, i32 32)
%13 = load i32*, i32** %5
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 1145093211, i32* %14
%15 = load i32*, i32** %5
%16 = getelementptr inbounds i32, i32* %15, i64 1
store i32 1566258456, i32* %16
%17 = load i32*, i32** %5
%18 = getelementptr inbounds i32, i32* %17, i64 2
store i32 440612657, i32* %18
%19 = load i32*, i32** %5
%20 = getelementptr inbounds i32, i32* %19, i64 3
store i32 1721837295, i32* %20
%21 = load i32, i32* %7
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i64 12
store i32 %21, i32* %23
%24 = load i32, i32* %8
%25 = load i32*, i32** %5
%26 = getelementptr inbounds i32, i32* %25, i64 13
store i32 %24, i32* %26
%27 = load i32, i32* %7
%28 = ashr i32 %27, 32
store i32 %28, i32* %7
%29 = load i32, i32* %8
%30 = ashr i32 %29, 32
store i32 %30, i32* %8
%31 = load i32, i32* %7
%32 = load i32*, i32** %5
%33 = getelementptr inbounds i32, i32* %32, i64 14
store i32 %31, i32* %33
%34 = load i32, i32* %8
%35 = load i32*, i32** %5
%36 = getelementptr inbounds i32, i32* %35, i64 15
store i32 %34, i32* %36
ret void
}

LLVM IR (-O2):
define void @chacha_setup(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = getelementptr inbounds i32, i32* %0, i64 4
%6 = tail call i32 @memcpy(i32* %5, i32* %1, i32 32)
%7 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> <i32 1145093211, i32 1566258456, i32 440612657, i32 1721837295>, <4 x i32>* %7
%8 = getelementptr inbounds i32, i32* %0, i64 12
store i32 %2, i32* %8
%9 = getelementptr inbounds i32, i32* %0, i64 13
store i32 %3, i32* %9
ret void
}