#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;
typedef int /*<<< orphan*/ __m128i;

/* Variables and functions */
int _mm_extract_epi16(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ xor_chacha_sidm(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int);
int /*<<< orphan*/
xor_chacha_sidm_swap(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                     int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                     int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                     int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
void chacha_core_r2_sidm(__m128i *X, uint32_t Loops, uint32_t double_rounds) {
  uint32_t i, j;
  __m128i scratch[Loops * 8 * 4];
  __m128i *calc_1 = (__m128i *)&X[0];
  __m128i *calc_2 = (__m128i *)&X[1];
  __m128i *calc_3 = (__m128i *)&X[2];
  __m128i *calc_4 = (__m128i *)&X[3];
  __m128i *calc_11 = (__m128i *)&X[4];
  __m128i *calc_12 = (__m128i *)&X[5];
  __m128i *calc_13 = (__m128i *)&X[6];
  __m128i *calc_14 = (__m128i *)&X[7];
  __m128i *calc_21 = (__m128i *)&X[8];
  __m128i *calc_22 = (__m128i *)&X[9];
  __m128i *calc_23 = (__m128i *)&X[10];
  __m128i *calc_24 = (__m128i *)&X[11];
  __m128i *calc_31 = (__m128i *)&X[12];
  __m128i *calc_32 = (__m128i *)&X[13];
  __m128i *calc_33 = (__m128i *)&X[14];
  __m128i *calc_34 = (__m128i *)&X[15];
  for (i = 0; i < Loops; i++) {
    scratch[i * 16 + 0] = *calc_1;
    scratch[i * 16 + 1] = *calc_2;
    scratch[i * 16 + 2] = *calc_3;
    scratch[i * 16 + 3] = *calc_4;
    scratch[i * 16 + 4] = *calc_11;
    scratch[i * 16 + 5] = *calc_12;
    scratch[i * 16 + 6] = *calc_13;
    scratch[i * 16 + 7] = *calc_14;
    scratch[i * 16 + 8] = *calc_21;
    scratch[i * 16 + 9] = *calc_22;
    scratch[i * 16 + 10] = *calc_23;
    scratch[i * 16 + 11] = *calc_24;
    scratch[i * 16 + 12] = *calc_31;
    scratch[i * 16 + 13] = *calc_32;
    scratch[i * 16 + 14] = *calc_33;
    scratch[i * 16 + 15] = *calc_34;
    xor_chacha_sidm(calc_1, calc_2, calc_3, calc_4, calc_31, calc_32, calc_33,
                    calc_34, double_rounds);
    xor_chacha_sidm(calc_11, calc_12, calc_13, calc_14, calc_1, calc_2, calc_3,
                    calc_4, double_rounds);
    xor_chacha_sidm_swap(calc_21, calc_22, calc_23, calc_24, calc_11, calc_12,
                         calc_13, calc_14, double_rounds);
    xor_chacha_sidm(calc_31, calc_32, calc_33, calc_34, calc_11, calc_12,
                    calc_13, calc_14, double_rounds);
  }
  for (i = 0; i < Loops; i++) {
    j = 16 * (_mm_extract_epi16(*calc_31, 0x00) & (Loops - 1));
    *calc_1 = _mm_xor_si128(*calc_1, scratch[j]);
    *calc_2 = _mm_xor_si128(*calc_2, scratch[j + 1]);
    *calc_3 = _mm_xor_si128(*calc_3, scratch[j + 2]);
    *calc_4 = _mm_xor_si128(*calc_4, scratch[j + 3]);
    *calc_11 = _mm_xor_si128(*calc_11, scratch[j + 4]);
    *calc_12 = _mm_xor_si128(*calc_12, scratch[j + 5]);
    *calc_13 = _mm_xor_si128(*calc_13, scratch[j + 6]);
    *calc_14 = _mm_xor_si128(*calc_14, scratch[j + 7]);
    *calc_21 = _mm_xor_si128(*calc_21, scratch[j + 8]);
    *calc_22 = _mm_xor_si128(*calc_22, scratch[j + 9]);
    *calc_23 = _mm_xor_si128(*calc_23, scratch[j + 10]);
    *calc_24 = _mm_xor_si128(*calc_24, scratch[j + 11]);
    *calc_31 = _mm_xor_si128(*calc_31, scratch[j + 12]);
    *calc_32 = _mm_xor_si128(*calc_32, scratch[j + 13]);
    *calc_33 = _mm_xor_si128(*calc_33, scratch[j + 14]);
    *calc_34 = _mm_xor_si128(*calc_34, scratch[j + 15]);
    xor_chacha_sidm(calc_1, calc_2, calc_3, calc_4, calc_31, calc_32, calc_33,
                    calc_34, double_rounds);
    xor_chacha_sidm(calc_11, calc_12, calc_13, calc_14, calc_1, calc_2, calc_3,
                    calc_4, double_rounds);
    xor_chacha_sidm_swap(calc_21, calc_22, calc_23, calc_24, calc_11, calc_12,
                         calc_13, calc_14, double_rounds);
    xor_chacha_sidm(calc_31, calc_32, calc_33, calc_34, calc_11, calc_12,
                    calc_13, calc_14, double_rounds);
  }
}


x86 assembly (clang, -O0):
<chacha_core_r2_sidm>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x5,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
shl    $0x2,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1c,%rax
mov    %rax,-0x68(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%rax
add    $0x24,%rax
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rax
add    $0x28,%rax
mov    %rax,-0x80(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2c,%rax
mov    %rax,-0x88(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rax
mov    %rax,-0x90(%rbp)
mov    -0x8(%rbp),%rax
add    $0x34,%rax
mov    %rax,-0x98(%rbp)
mov    -0x8(%rbp),%rax
add    $0x38,%rax
mov    %rax,-0xa0(%rbp)
mov    -0x8(%rbp),%rax
add    $0x3c,%rax
mov    %rax,-0xa8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    14de <chacha_core_r2_sidm+0x39e>
mov    -0xb0(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x40(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x48(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x50(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x58(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x5,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x60(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x68(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x7,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x70(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x8,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x78(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0x9,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x80(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0xa,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x88(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0xb,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x90(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0xc,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x98(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0xd,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xa0(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0xe,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xa8(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x14(%rbp),%ecx
shl    $0x4,%ecx
add    $0xf,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x90(%rbp),%r8
mov    -0x98(%rbp),%r9
mov    -0xa0(%rbp),%r11
mov    -0xa8(%rbp),%r10
mov    -0x10(%rbp),%eax
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <xor_chacha_sidm@plt>
add    $0x20,%rsp
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    -0x40(%rbp),%r11
mov    -0x48(%rbp),%r10
mov    -0x10(%rbp),%eax
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <xor_chacha_sidm@plt>
add    $0x20,%rsp
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x80(%rbp),%rdx
mov    -0x88(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%r11
mov    -0x68(%rbp),%r10
mov    -0x10(%rbp),%eax
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <xor_chacha_sidm_swap@plt>
add    $0x20,%rsp
mov    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    -0xa0(%rbp),%rdx
mov    -0xa8(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%r11
mov    -0x68(%rbp),%r10
mov    -0x10(%rbp),%eax
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <xor_chacha_sidm@plt>
add    $0x20,%rsp
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    124f <chacha_core_r2_sidm+0x10f>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    18a7 <chacha_core_r2_sidm+0x767>
mov    -0x90(%rbp),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <_mm_extract_epi16@plt>
mov    %eax,%ecx
mov    -0xb0(%rbp),%rax
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
and    %edx,%ecx
shl    $0x4,%ecx
mov    %ecx,-0x18(%rbp)
mov    -0x30(%rbp),%rcx
mov    (%rcx),%edi
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x38(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x40(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x48(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x50(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x58(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0x5,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x60(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x68(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0x7,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x68(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x70(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0x8,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x70(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x78(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0x9,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x78(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x80(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0xa,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x88(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0xb,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x90(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0xc,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x90(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0x98(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0xd,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0x98(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0xa0(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0xe,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0xb0(%rbp),%rax
mov    -0xa0(%rbp),%rcx
mov    %edx,(%rcx)
mov    -0xa8(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x18(%rbp),%ecx
add    $0xf,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0xa8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x90(%rbp),%r8
mov    -0x98(%rbp),%r9
mov    -0xa0(%rbp),%r11
mov    -0xa8(%rbp),%r10
mov    -0x10(%rbp),%eax
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <xor_chacha_sidm@plt>
add    $0x20,%rsp
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    -0x40(%rbp),%r11
mov    -0x48(%rbp),%r10
mov    -0x10(%rbp),%eax
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <xor_chacha_sidm@plt>
add    $0x20,%rsp
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x80(%rbp),%rdx
mov    -0x88(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%r11
mov    -0x68(%rbp),%r10
mov    -0x10(%rbp),%eax
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <xor_chacha_sidm_swap@plt>
add    $0x20,%rsp
mov    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    -0xa0(%rbp),%rdx
mov    -0xa8(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%r11
mov    -0x68(%rbp),%r10
mov    -0x10(%rbp),%eax
sub    $0x20,%rsp
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <xor_chacha_sidm@plt>
add    $0x20,%rsp
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    14e5 <chacha_core_r2_sidm+0x3a5>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chacha_core_r2_sidm>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rdx,-0x88(%rbp)
mov    %esi,%eax
shl    $0x5,%eax
mov    %rsp,%r13
shl    $0x2,%rax
sub    %rax,%r13
mov    %r13,%rsp
test   %esi,%esi
jle    1590 <chacha_core_r2_sidm+0x450>
lea    0x4(%rdi),%rax
mov    %rax,-0x80(%rbp)
lea    0x8(%rdi),%rax
mov    %rax,-0x68(%rbp)
lea    0xc(%rdi),%rax
mov    %rax,-0x60(%rbp)
lea    0x10(%rdi),%rax
mov    %rax,-0xc0(%rbp)
lea    0x14(%rdi),%rax
mov    %rax,-0xb8(%rbp)
lea    0x18(%rdi),%r15
lea    0x1c(%rdi),%r12
lea    0x20(%rdi),%rax
mov    %rax,-0xb0(%rbp)
lea    0x24(%rdi),%rax
mov    %rax,-0xa8(%rbp)
lea    0x28(%rdi),%rax
mov    %rax,-0xa0(%rbp)
lea    0x2c(%rdi),%rax
mov    %rax,-0x98(%rbp)
lea    0x30(%rdi),%rax
mov    %rax,-0x58(%rbp)
mov    %rsi,-0x78(%rbp)
mov    %esi,%eax
shl    $0x6,%rax
mov    %rax,-0x70(%rbp)
lea    0x34(%rdi),%rax
mov    %rax,-0x50(%rbp)
lea    0x38(%rdi),%rax
mov    %rax,-0x48(%rbp)
lea    0x3c(%rdi),%rax
mov    %rax,-0x40(%rbp)
mov    %rdi,-0x90(%rbp)
xor    %r14d,%r14d
mov    %r13,-0xc8(%rbp)
mov    %r15,-0x38(%rbp)
mov    %r12,-0x30(%rbp)
xchg   %ax,%ax
mov    -0x90(%rbp),%rbx
movups (%rbx),%xmm0
movaps %xmm0,0x0(%r13,%r14,1)
movups 0x10(%rbx),%xmm0
movaps %xmm0,0x10(%r13,%r14,1)
movups 0x20(%rbx),%xmm0
movaps %xmm0,0x20(%r13,%r14,1)
movups 0x30(%rbx),%xmm0
movaps %xmm0,0x30(%r13,%r14,1)
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    -0x80(%rbp),%r13
mov    %r13,%rsi
mov    -0x68(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    -0x50(%rbp),%r9
push   -0x88(%rbp)
push   -0x40(%rbp)
push   -0x48(%rbp)
call   1050 <xor_chacha_sidm@plt>
add    $0x18,%rsp
mov    -0xc0(%rbp),%r15
mov    %r15,%rdi
mov    -0xb8(%rbp),%r12
mov    %r12,%rsi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    %rbx,%r8
mov    %r13,%r9
mov    -0x88(%rbp),%rbx
mov    -0xc8(%rbp),%r13
push   %rbx
push   -0x60(%rbp)
push   -0x68(%rbp)
call   1050 <xor_chacha_sidm@plt>
add    $0x18,%rsp
mov    -0xb0(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
mov    -0xa0(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    %r15,%r8
mov    %r12,%r9
push   %rbx
push   -0x30(%rbp)
push   -0x38(%rbp)
call   1030 <xor_chacha_sidm_swap@plt>
add    $0x18,%rsp
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    %r15,%r8
mov    -0x38(%rbp),%r15
mov    %r12,%r9
mov    -0x30(%rbp),%r12
push   %rbx
push   %r12
push   %r15
call   1050 <xor_chacha_sidm@plt>
add    $0x20,%rsp
add    $0x40,%r14
cmp    %r14,-0x70(%rbp)
jne    1220 <chacha_core_r2_sidm+0xe0>
mov    -0x78(%rbp),%rax
test   %eax,%eax
mov    -0x90(%rbp),%rbx
jle    1590 <chacha_core_r2_sidm+0x450>
lea    -0x1(%rax),%ecx
mov    %ecx,-0x70(%rbp)
mov    -0x88(%rbp),%r15
mov    -0xb8(%rbp),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rax,-0x78(%rbp)
mov    0x30(%rbx),%edi
xor    %esi,%esi
call   1040 <_mm_extract_epi16@plt>
and    -0x70(%rbp),%eax
shl    $0x4,%eax
mov    (%rbx),%edi
movslq %eax,%r14
mov    0x0(%r13,%r14,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,(%rbx)
mov    0x4(%rbx),%edi
lea    0x1(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x4(%rbx)
mov    0x8(%rbx),%edi
lea    0x2(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x8(%rbx)
mov    0xc(%rbx),%edi
lea    0x3(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0xc(%rbx)
mov    0x10(%rbx),%edi
lea    0x4(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x10(%rbx)
mov    0x14(%rbx),%edi
lea    0x5(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x14(%rbx)
mov    0x18(%rbx),%edi
lea    0x6(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x18(%rbx)
mov    0x1c(%rbx),%edi
lea    0x7(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x1c(%rbx)
mov    0x20(%rbx),%edi
lea    0x8(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x20(%rbx)
mov    0x24(%rbx),%edi
lea    0x9(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x24(%rbx)
mov    0x28(%rbx),%edi
lea    0xa(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x28(%rbx)
mov    0x2c(%rbx),%edi
lea    0xb(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x2c(%rbx)
mov    0x30(%rbx),%edi
lea    0xc(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x30(%rbx)
mov    0x34(%rbx),%edi
lea    0xd(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x34(%rbx)
mov    0x38(%rbx),%edi
lea    0xe(%r14),%eax
cltq
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x38(%rbx)
mov    0x3c(%rbx),%edi
or     $0xf,%r14d
movslq %r14d,%rax
mov    0x0(%r13,%rax,4),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,0x3c(%rbx)
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    -0x80(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    -0x58(%rbp),%r8
mov    -0x50(%rbp),%r9
push   %r15
push   -0x40(%rbp)
push   -0x48(%rbp)
call   1050 <xor_chacha_sidm@plt>
add    $0x18,%rsp
mov    -0xc0(%rbp),%r14
mov    %r14,%rdi
mov    %r12,%rsi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    %rbx,%r8
mov    -0x80(%rbp),%r9
push   %r15
push   -0x60(%rbp)
push   -0x68(%rbp)
call   1050 <xor_chacha_sidm@plt>
add    $0x18,%rsp
mov    -0xb0(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
mov    -0xa0(%rbp),%rdx
mov    -0x98(%rbp),%rcx
mov    %r14,%r8
mov    %r12,%r9
push   %r15
push   -0x30(%rbp)
push   -0x38(%rbp)
call   1030 <xor_chacha_sidm_swap@plt>
add    $0x18,%rsp
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    %r14,%r8
mov    %r12,%r9
push   %r15
push   -0x30(%rbp)
push   -0x38(%rbp)
call   1050 <xor_chacha_sidm@plt>
mov    -0x78(%rbp),%rax
add    $0x20,%rsp
add    $0xffffffff,%eax
jne    1360 <chacha_core_r2_sidm+0x220>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @chacha_core_r2_sidm(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32*
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca i32*
%26 = alloca i32*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%27 = load i32, i32* %5
%28 = mul nsw i32 %27, 8
%29 = mul nsw i32 %28, 4
%30 = zext i32 %29 to i64
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %9
%32 = alloca i32, i64 %30
store i64 %30, i64* %10
%33 = load i32*, i32** %4
%34 = getelementptr inbounds i32, i32* %33, i64 0
store i32* %34, i32** %11
%35 = load i32*, i32** %4
%36 = getelementptr inbounds i32, i32* %35, i64 1
store i32* %36, i32** %12
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i64 2
store i32* %38, i32** %13
%39 = load i32*, i32** %4
%40 = getelementptr inbounds i32, i32* %39, i64 3
store i32* %40, i32** %14
%41 = load i32*, i32** %4
%42 = getelementptr inbounds i32, i32* %41, i64 4
store i32* %42, i32** %15
%43 = load i32*, i32** %4
%44 = getelementptr inbounds i32, i32* %43, i64 5
store i32* %44, i32** %16
%45 = load i32*, i32** %4
%46 = getelementptr inbounds i32, i32* %45, i64 6
store i32* %46, i32** %17
%47 = load i32*, i32** %4
%48 = getelementptr inbounds i32, i32* %47, i64 7
store i32* %48, i32** %18
%49 = load i32*, i32** %4
%50 = getelementptr inbounds i32, i32* %49, i64 8
store i32* %50, i32** %19
%51 = load i32*, i32** %4
%52 = getelementptr inbounds i32, i32* %51, i64 9
store i32* %52, i32** %20
%53 = load i32*, i32** %4
%54 = getelementptr inbounds i32, i32* %53, i64 10
store i32* %54, i32** %21
%55 = load i32*, i32** %4
%56 = getelementptr inbounds i32, i32* %55, i64 11
store i32* %56, i32** %22
%57 = load i32*, i32** %4
%58 = getelementptr inbounds i32, i32* %57, i64 12
store i32* %58, i32** %23
%59 = load i32*, i32** %4
%60 = getelementptr inbounds i32, i32* %59, i64 13
store i32* %60, i32** %24
%61 = load i32*, i32** %4
%62 = getelementptr inbounds i32, i32* %61, i64 14
store i32* %62, i32** %25
%63 = load i32*, i32** %4
%64 = getelementptr inbounds i32, i32* %63, i64 15
store i32* %64, i32** %26
store i32 0, i32* %7
br label %65
65: ; preds = %222, %3
%66 = load i32, i32* %7
%67 = load i32, i32* %5
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %225
69: ; preds = %65
%70 = load i32*, i32** %11
%71 = load i32, i32* %70
%72 = load i32, i32* %7
%73 = mul nsw i32 %72, 16
%74 = add nsw i32 %73, 0
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %32, i64 %75
store i32 %71, i32* %76
%77 = load i32*, i32** %12
%78 = load i32, i32* %77
%79 = load i32, i32* %7
%80 = mul nsw i32 %79, 16
%81 = add nsw i32 %80, 1
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i32, i32* %32, i64 %82
store i32 %78, i32* %83
%84 = load i32*, i32** %13
%85 = load i32, i32* %84
%86 = load i32, i32* %7
%87 = mul nsw i32 %86, 16
%88 = add nsw i32 %87, 2
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i32, i32* %32, i64 %89
store i32 %85, i32* %90
%91 = load i32*, i32** %14
%92 = load i32, i32* %91
%93 = load i32, i32* %7
%94 = mul nsw i32 %93, 16
%95 = add nsw i32 %94, 3
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %32, i64 %96
store i32 %92, i32* %97
%98 = load i32*, i32** %15
%99 = load i32, i32* %98
%100 = load i32, i32* %7
%101 = mul nsw i32 %100, 16
%102 = add nsw i32 %101, 4
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i32, i32* %32, i64 %103
store i32 %99, i32* %104
%105 = load i32*, i32** %16
%106 = load i32, i32* %105
%107 = load i32, i32* %7
%108 = mul nsw i32 %107, 16
%109 = add nsw i32 %108, 5
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i32, i32* %32, i64 %110
store i32 %106, i32* %111
%112 = load i32*, i32** %17
%113 = load i32, i32* %112
%114 = load i32, i32* %7
%115 = mul nsw i32 %114, 16
%116 = add nsw i32 %115, 6
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i32, i32* %32, i64 %117
store i32 %113, i32* %118
%119 = load i32*, i32** %18
%120 = load i32, i32* %119
%121 = load i32, i32* %7
%122 = mul nsw i32 %121, 16
%123 = add nsw i32 %122, 7
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i32, i32* %32, i64 %124
store i32 %120, i32* %125
%126 = load i32*, i32** %19
%127 = load i32, i32* %126
%128 = load i32, i32* %7
%129 = mul nsw i32 %128, 16
%130 = add nsw i32 %129, 8
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i32, i32* %32, i64 %131
store i32 %127, i32* %132
%133 = load i32*, i32** %20
%134 = load i32, i32* %133
%135 = load i32, i32* %7
%136 = mul nsw i32 %135, 16
%137 = add nsw i32 %136, 9
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds i32, i32* %32, i64 %138
store i32 %134, i32* %139
%140 = load i32*, i32** %21
%141 = load i32, i32* %140
%142 = load i32, i32* %7
%143 = mul nsw i32 %142, 16
%144 = add nsw i32 %143, 10
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i32, i32* %32, i64 %145
store i32 %141, i32* %146
%147 = load i32*, i32** %22
%148 = load i32, i32* %147
%149 = load i32, i32* %7
%150 = mul nsw i32 %149, 16
%151 = add nsw i32 %150, 11
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds i32, i32* %32, i64 %152
store i32 %148, i32* %153
%154 = load i32*, i32** %23
%155 = load i32, i32* %154
%156 = load i32, i32* %7
%157 = mul nsw i32 %156, 16
%158 = add nsw i32 %157, 12
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds i32, i32* %32, i64 %159
store i32 %155, i32* %160
%161 = load i32*, i32** %24
%162 = load i32, i32* %161
%163 = load i32, i32* %7
%164 = mul nsw i32 %163, 16
%165 = add nsw i32 %164, 13
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i32, i32* %32, i64 %166
store i32 %162, i32* %167
%168 = load i32*, i32** %25
%169 = load i32, i32* %168
%170 = load i32, i32* %7
%171 = mul nsw i32 %170, 16
%172 = add nsw i32 %171, 14
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds i32, i32* %32, i64 %173
store i32 %169, i32* %174
%175 = load i32*, i32** %26
%176 = load i32, i32* %175
%177 = load i32, i32* %7
%178 = mul nsw i32 %177, 16
%179 = add nsw i32 %178, 15
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i32, i32* %32, i64 %180
store i32 %176, i32* %181
%182 = load i32*, i32** %11
%183 = load i32*, i32** %12
%184 = load i32*, i32** %13
%185 = load i32*, i32** %14
%186 = load i32*, i32** %23
%187 = load i32*, i32** %24
%188 = load i32*, i32** %25
%189 = load i32*, i32** %26
%190 = load i32, i32* %6
%191 = call i32 @xor_chacha_sidm(i32* %182, i32* %183, i32* %184, i32* %185, i32* %186, i32* %187, i32* %188, i32* %189, i32 %190)
%192 = load i32*, i32** %15
%193 = load i32*, i32** %16
%194 = load i32*, i32** %17
%195 = load i32*, i32** %18
%196 = load i32*, i32** %11
%197 = load i32*, i32** %12
%198 = load i32*, i32** %13
%199 = load i32*, i32** %14
%200 = load i32, i32* %6
%201 = call i32 @xor_chacha_sidm(i32* %192, i32* %193, i32* %194, i32* %195, i32* %196, i32* %197, i32* %198, i32* %199, i32 %200)
%202 = load i32*, i32** %19
%203 = load i32*, i32** %20
%204 = load i32*, i32** %21
%205 = load i32*, i32** %22
%206 = load i32*, i32** %15
%207 = load i32*, i32** %16
%208 = load i32*, i32** %17
%209 = load i32*, i32** %18
%210 = load i32, i32* %6
%211 = call i32 @xor_chacha_sidm_swap(i32* %202, i32* %203, i32* %204, i32* %205, i32* %206, i32* %207, i32* %208, i32* %209, i32 %210)
%212 = load i32*, i32** %23
%213 = load i32*, i32** %24
%214 = load i32*, i32** %25
%215 = load i32*, i32** %26
%216 = load i32*, i32** %15
%217 = load i32*, i32** %16
%218 = load i32*, i32** %17
%219 = load i32*, i32** %18
%220 = load i32, i32* %6
%221 = call i32 @xor_chacha_sidm(i32* %212, i32* %213, i32* %214, i32* %215, i32* %216, i32* %217, i32* %218, i32* %219, i32 %220)
br label %222
222: ; preds = %69
%223 = load i32, i32* %7
%224 = add nsw i32 %223, 1
store i32 %224, i32* %7
br label %65
225: ; preds = %65
store i32 0, i32* %7
br label %226
226: ; preds = %421, %225
%227 = load i32, i32* %7
%228 = load i32, i32* %5
%229 = icmp slt i32 %227, %228
br i1 %229, label %230, label %424
230: ; preds = %226
%231 = load i32*, i32** %23
%232 = load i32, i32* %231
%233 = call i32 @_mm_extract_epi16(i32 %232, i32 0)
%234 = load i32, i32* %5
%235 = sub nsw i32 %234, 1
%236 = and i32 %233, %235
%237 = mul nsw i32 16, %236
store i32 %237, i32* %8
%238 = load i32*, i32** %11
%239 = load i32, i32* %238
%240 = load i32, i32* %8
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds i32, i32* %32, i64 %241
%243 = load i32, i32* %242
%244 = call i32 @_mm_xor_si128(i32 %239, i32 %243)
%245 = load i32*, i32** %11
store i32 %244, i32* %245
%246 = load i32*, i32** %12
%247 = load i32, i32* %246
%248 = load i32, i32* %8
%249 = add nsw i32 %248, 1
%250 = sext i32 %249 to i64
%251 = getelementptr inbounds i32, i32* %32, i64 %250
%252 = load i32, i32* %251
%253 = call i32 @_mm_xor_si128(i32 %247, i32 %252)
%254 = load i32*, i32** %12
store i32 %253, i32* %254
%255 = load i32*, i32** %13
%256 = load i32, i32* %255
%257 = load i32, i32* %8
%258 = add nsw i32 %257, 2
%259 = sext i32 %258 to i64
%260 = getelementptr inbounds i32, i32* %32, i64 %259
%261 = load i32, i32* %260
%262 = call i32 @_mm_xor_si128(i32 %256, i32 %261)
%263 = load i32*, i32** %13
store i32 %262, i32* %263
%264 = load i32*, i32** %14
%265 = load i32, i32* %264
%266 = load i32, i32* %8
%267 = add nsw i32 %266, 3
%268 = sext i32 %267 to i64
%269 = getelementptr inbounds i32, i32* %32, i64 %268
%270 = load i32, i32* %269
%271 = call i32 @_mm_xor_si128(i32 %265, i32 %270)
%272 = load i32*, i32** %14
store i32 %271, i32* %272
%273 = load i32*, i32** %15
%274 = load i32, i32* %273
%275 = load i32, i32* %8
%276 = add nsw i32 %275, 4
%277 = sext i32 %276 to i64
%278 = getelementptr inbounds i32, i32* %32, i64 %277
%279 = load i32, i32* %278
%280 = call i32 @_mm_xor_si128(i32 %274, i32 %279)
%281 = load i32*, i32** %15
store i32 %280, i32* %281
%282 = load i32*, i32** %16
%283 = load i32, i32* %282
%284 = load i32, i32* %8
%285 = add nsw i32 %284, 5
%286 = sext i32 %285 to i64
%287 = getelementptr inbounds i32, i32* %32, i64 %286
%288 = load i32, i32* %287
%289 = call i32 @_mm_xor_si128(i32 %283, i32 %288)
%290 = load i32*, i32** %16
store i32 %289, i32* %290
%291 = load i32*, i32** %17
%292 = load i32, i32* %291
%293 = load i32, i32* %8
%294 = add nsw i32 %293, 6
%295 = sext i32 %294 to i64
%296 = getelementptr inbounds i32, i32* %32, i64 %295
%297 = load i32, i32* %296
%298 = call i32 @_mm_xor_si128(i32 %292, i32 %297)
%299 = load i32*, i32** %17
store i32 %298, i32* %299
%300 = load i32*, i32** %18
%301 = load i32, i32* %300
%302 = load i32, i32* %8
%303 = add nsw i32 %302, 7
%304 = sext i32 %303 to i64
%305 = getelementptr inbounds i32, i32* %32, i64 %304
%306 = load i32, i32* %305
%307 = call i32 @_mm_xor_si128(i32 %301, i32 %306)
%308 = load i32*, i32** %18
store i32 %307, i32* %308
%309 = load i32*, i32** %19
%310 = load i32, i32* %309
%311 = load i32, i32* %8
%312 = add nsw i32 %311, 8
%313 = sext i32 %312 to i64
%314 = getelementptr inbounds i32, i32* %32, i64 %313
%315 = load i32, i32* %314
%316 = call i32 @_mm_xor_si128(i32 %310, i32 %315)
%317 = load i32*, i32** %19
store i32 %316, i32* %317
%318 = load i32*, i32** %20
%319 = load i32, i32* %318
%320 = load i32, i32* %8
%321 = add nsw i32 %320, 9
%322 = sext i32 %321 to i64
%323 = getelementptr inbounds i32, i32* %32, i64 %322
%324 = load i32, i32* %323
%325 = call i32 @_mm_xor_si128(i32 %319, i32 %324)
%326 = load i32*, i32** %20
store i32 %325, i32* %326
%327 = load i32*, i32** %21
%328 = load i32, i32* %327
%329 = load i32, i32* %8
%330 = add nsw i32 %329, 10
%331 = sext i32 %330 to i64
%332 = getelementptr inbounds i32, i32* %32, i64 %331
%333 = load i32, i32* %332
%334 = call i32 @_mm_xor_si128(i32 %328, i32 %333)
%335 = load i32*, i32** %21
store i32 %334, i32* %335
%336 = load i32*, i32** %22
%337 = load i32, i32* %336
%338 = load i32, i32* %8
%339 = add nsw i32 %338, 11
%340 = sext i32 %339 to i64
%341 = getelementptr inbounds i32, i32* %32, i64 %340
%342 = load i32, i32* %341
%343 = call i32 @_mm_xor_si128(i32 %337, i32 %342)
%344 = load i32*, i32** %22
store i32 %343, i32* %344
%345 = load i32*, i32** %23
%346 = load i32, i32* %345
%347 = load i32, i32* %8
%348 = add nsw i32 %347, 12
%349 = sext i32 %348 to i64
%350 = getelementptr inbounds i32, i32* %32, i64 %349
%351 = load i32, i32* %350
%352 = call i32 @_mm_xor_si128(i32 %346, i32 %351)
%353 = load i32*, i32** %23
store i32 %352, i32* %353
%354 = load i32*, i32** %24
%355 = load i32, i32* %354
%356 = load i32, i32* %8
%357 = add nsw i32 %356, 13
%358 = sext i32 %357 to i64
%359 = getelementptr inbounds i32, i32* %32, i64 %358
%360 = load i32, i32* %359
%361 = call i32 @_mm_xor_si128(i32 %355, i32 %360)
%362 = load i32*, i32** %24
store i32 %361, i32* %362
%363 = load i32*, i32** %25
%364 = load i32, i32* %363
%365 = load i32, i32* %8
%366 = add nsw i32 %365, 14
%367 = sext i32 %366 to i64
%368 = getelementptr inbounds i32, i32* %32, i64 %367
%369 = load i32, i32* %368
%370 = call i32 @_mm_xor_si128(i32 %364, i32 %369)
%371 = load i32*, i32** %25
store i32 %370, i32* %371
%372 = load i32*, i32** %26
%373 = load i32, i32* %372
%374 = load i32, i32* %8
%375 = add nsw i32 %374, 15
%376 = sext i32 %375 to i64
%377 = getelementptr inbounds i32, i32* %32, i64 %376
%378 = load i32, i32* %377
%379 = call i32 @_mm_xor_si128(i32 %373, i32 %378)
%380 = load i32*, i32** %26
store i32 %379, i32* %380
%381 = load i32*, i32** %11
%382 = load i32*, i32** %12
%383 = load i32*, i32** %13
%384 = load i32*, i32** %14
%385 = load i32*, i32** %23
%386 = load i32*, i32** %24
%387 = load i32*, i32** %25
%388 = load i32*, i32** %26
%389 = load i32, i32* %6
%390 = call i32 @xor_chacha_sidm(i32* %381, i32* %382, i32* %383, i32* %384, i32* %385, i32* %386, i32* %387, i32* %388, i32 %389)
%391 = load i32*, i32** %15
%392 = load i32*, i32** %16
%393 = load i32*, i32** %17
%394 = load i32*, i32** %18
%395 = load i32*, i32** %11
%396 = load i32*, i32** %12
%397 = load i32*, i32** %13
%398 = load i32*, i32** %14
%399 = load i32, i32* %6
%400 = call i32 @xor_chacha_sidm(i32* %391, i32* %392, i32* %393, i32* %394, i32* %395, i32* %396, i32* %397, i32* %398, i32 %399)
%401 = load i32*, i32** %19
%402 = load i32*, i32** %20
%403 = load i32*, i32** %21
%404 = load i32*, i32** %22
%405 = load i32*, i32** %15
%406 = load i32*, i32** %16
%407 = load i32*, i32** %17
%408 = load i32*, i32** %18
%409 = load i32, i32* %6
%410 = call i32 @xor_chacha_sidm_swap(i32* %401, i32* %402, i32* %403, i32* %404, i32* %405, i32* %406, i32* %407, i32* %408, i32 %409)
%411 = load i32*, i32** %23
%412 = load i32*, i32** %24
%413 = load i32*, i32** %25
%414 = load i32*, i32** %26
%415 = load i32*, i32** %15
%416 = load i32*, i32** %16
%417 = load i32*, i32** %17
%418 = load i32*, i32** %18
%419 = load i32, i32* %6
%420 = call i32 @xor_chacha_sidm(i32* %411, i32* %412, i32* %413, i32* %414, i32* %415, i32* %416, i32* %417, i32* %418, i32 %419)
br label %421
421: ; preds = %230
%422 = load i32, i32* %7
%423 = add nsw i32 %422, 1
store i32 %423, i32* %7
br label %226
424: ; preds = %226
%425 = load i8*, i8** %9
ret void
}

LLVM IR (-O2):
define void @chacha_core_r2_sidm(i32* %0, i32 %1, i32 %2) {
%4 = shl nsw i32 %1, 5
%5 = zext i32 %4 to i64
%6 = alloca i32, i64 %5
%7 = getelementptr inbounds i32, i32* %0, i64 1
%8 = getelementptr inbounds i32, i32* %0, i64 2
%9 = getelementptr inbounds i32, i32* %0, i64 3
%10 = getelementptr inbounds i32, i32* %0, i64 4
%11 = getelementptr inbounds i32, i32* %0, i64 5
%12 = getelementptr inbounds i32, i32* %0, i64 6
%13 = getelementptr inbounds i32, i32* %0, i64 7
%14 = getelementptr inbounds i32, i32* %0, i64 8
%15 = getelementptr inbounds i32, i32* %0, i64 9
%16 = getelementptr inbounds i32, i32* %0, i64 10
%17 = getelementptr inbounds i32, i32* %0, i64 11
%18 = getelementptr inbounds i32, i32* %0, i64 12
%19 = getelementptr inbounds i32, i32* %0, i64 13
%20 = getelementptr inbounds i32, i32* %0, i64 14
%21 = getelementptr inbounds i32, i32* %0, i64 15
%22 = icmp sgt i32 %1, 0
br i1 %22, label %23, label %163
23: ; preds = %3
%24 = zext i32 %1 to i64
%25 = bitcast i32* %0 to <4 x i32>*
%26 = bitcast i32* %10 to <4 x i32>*
%27 = bitcast i32* %14 to <4 x i32>*
%28 = bitcast i32* %18 to <4 x i32>*
br label %32
29: ; preds = %32
br i1 %22, label %30, label %163
30: ; preds = %29
%31 = add nsw i32 %1, -1
br label %56
32: ; preds = %23, %32
%33 = phi i64 [ 0, %23 ], [ %54, %32 ]
%34 = shl nsw i64 %33, 4
%35 = getelementptr inbounds i32, i32* %6, i64 %34
%36 = load <4 x i32>, <4 x i32>* %25
%37 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %36, <4 x i32>* %37
%38 = or i64 %34, 4
%39 = getelementptr inbounds i32, i32* %6, i64 %38
%40 = load <4 x i32>, <4 x i32>* %26
%41 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> %40, <4 x i32>* %41
%42 = or i64 %34, 8
%43 = getelementptr inbounds i32, i32* %6, i64 %42
%44 = load <4 x i32>, <4 x i32>* %27
%45 = bitcast i32* %43 to <4 x i32>*
store <4 x i32> %44, <4 x i32>* %45
%46 = or i64 %34, 12
%47 = getelementptr inbounds i32, i32* %6, i64 %46
%48 = load <4 x i32>, <4 x i32>* %28
%49 = bitcast i32* %47 to <4 x i32>*
store <4 x i32> %48, <4 x i32>* %49
%50 = tail call i32 @xor_chacha_sidm(i32* %0, i32* %7, i32* %8, i32* %9, i32* %18, i32* %19, i32* %20, i32* %21, i32 %2)
%51 = tail call i32 @xor_chacha_sidm(i32* %10, i32* %11, i32* %12, i32* %13, i32* %0, i32* %7, i32* %8, i32* %9, i32 %2)
%52 = tail call i32 @xor_chacha_sidm_swap(i32* %14, i32* %15, i32* %16, i32* %17, i32* %10, i32* %11, i32* %12, i32* %13, i32 %2)
%53 = tail call i32 @xor_chacha_sidm(i32* %18, i32* %19, i32* %20, i32* %21, i32* %10, i32* %11, i32* %12, i32* %13, i32 %2)
%54 = add nuw nsw i64 %33, 1
%55 = icmp eq i64 %54, %24
br i1 %55, label %29, label %32
56: ; preds = %30, %56
%57 = phi i32 [ 0, %30 ], [ %161, %56 ]
%58 = load i32, i32* %18
%59 = tail call i32 @_mm_extract_epi16(i32 %58, i32 0)
%60 = and i32 %59, %31
%61 = shl nsw i32 %60, 4
%62 = load i32, i32* %0
%63 = sext i32 %61 to i64
%64 = getelementptr inbounds i32, i32* %6, i64 %63
%65 = load i32, i32* %64
%66 = tail call i32 @_mm_xor_si128(i32 %62, i32 %65)
store i32 %66, i32* %0
%67 = load i32, i32* %7
%68 = or i32 %61, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %6, i64 %69
%71 = load i32, i32* %70
%72 = tail call i32 @_mm_xor_si128(i32 %67, i32 %71)
store i32 %72, i32* %7
%73 = load i32, i32* %8
%74 = or i32 %61, 2
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %6, i64 %75
%77 = load i32, i32* %76
%78 = tail call i32 @_mm_xor_si128(i32 %73, i32 %77)
store i32 %78, i32* %8
%79 = load i32, i32* %9
%80 = or i32 %61, 3
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* %6, i64 %81
%83 = load i32, i32* %82
%84 = tail call i32 @_mm_xor_si128(i32 %79, i32 %83)
store i32 %84, i32* %9
%85 = load i32, i32* %10
%86 = or i32 %61, 4
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %6, i64 %87
%89 = load i32, i32* %88
%90 = tail call i32 @_mm_xor_si128(i32 %85, i32 %89)
store i32 %90, i32* %10
%91 = load i32, i32* %11
%92 = or i32 %61, 5
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i32, i32* %6, i64 %93
%95 = load i32, i32* %94
%96 = tail call i32 @_mm_xor_si128(i32 %91, i32 %95)
store i32 %96, i32* %11
%97 = load i32, i32* %12
%98 = or i32 %61, 6
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i32, i32* %6, i64 %99
%101 = load i32, i32* %100
%102 = tail call i32 @_mm_xor_si128(i32 %97, i32 %101)
store i32 %102, i32* %12
%103 = load i32, i32* %13
%104 = or i32 %61, 7
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i32, i32* %6, i64 %105
%107 = load i32, i32* %106
%108 = tail call i32 @_mm_xor_si128(i32 %103, i32 %107)
store i32 %108, i32* %13
%109 = load i32, i32* %14
%110 = or i32 %61, 8
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i32, i32* %6, i64 %111
%113 = load i32, i32* %112
%114 = tail call i32 @_mm_xor_si128(i32 %109, i32 %113)
store i32 %114, i32* %14
%115 = load i32, i32* %15
%116 = or i32 %61, 9
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i32, i32* %6, i64 %117
%119 = load i32, i32* %118
%120 = tail call i32 @_mm_xor_si128(i32 %115, i32 %119)
store i32 %120, i32* %15
%121 = load i32, i32* %16
%122 = or i32 %61, 10
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i32, i32* %6, i64 %123
%125 = load i32, i32* %124
%126 = tail call i32 @_mm_xor_si128(i32 %121, i32 %125)
store i32 %126, i32* %16
%127 = load i32, i32* %17
%128 = or i32 %61, 11
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i32, i32* %6, i64 %129
%131 = load i32, i32* %130
%132 = tail call i32 @_mm_xor_si128(i32 %127, i32 %131)
store i32 %132, i32* %17
%133 = load i32, i32* %18
%134 = or i32 %61, 12
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds i32, i32* %6, i64 %135
%137 = load i32, i32* %136
%138 = tail call i32 @_mm_xor_si128(i32 %133, i32 %137)
store i32 %138, i32* %18
%139 = load i32, i32* %19
%140 = or i32 %61, 13
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i32, i32* %6, i64 %141
%143 = load i32, i32* %142
%144 = tail call i32 @_mm_xor_si128(i32 %139, i32 %143)
store i32 %144, i32* %19
%145 = load i32, i32* %20
%146 = or i32 %61, 14
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds i32, i32* %6, i64 %147
%149 = load i32, i32* %148
%150 = tail call i32 @_mm_xor_si128(i32 %145, i32 %149)
store i32 %150, i32* %20
%151 = load i32, i32* %21
%152 = or i32 %61, 15
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i32, i32* %6, i64 %153
%155 = load i32, i32* %154
%156 = tail call i32 @_mm_xor_si128(i32 %151, i32 %155)
store i32 %156, i32* %21
%157 = tail call i32 @xor_chacha_sidm(i32* %0, i32* %7, i32* %8, i32* %9, i32* %18, i32* %19, i32* %20, i32* %21, i32 %2)
%158 = tail call i32 @xor_chacha_sidm(i32* %10, i32* %11, i32* %12, i32* %13, i32* %0, i32* %7, i32* %8, i32* %9, i32 %2)
%159 = tail call i32 @xor_chacha_sidm_swap(i32* %14, i32* %15, i32* %16, i32* %17, i32* %10, i32* %11, i32* %12, i32* %13, i32 %2)
%160 = tail call i32 @xor_chacha_sidm(i32* %18, i32* %19, i32* %20, i32* %21, i32* %10, i32* %11, i32* %12, i32* %13, i32 %2)
%161 = add nuw nsw i32 %57, 1
%162 = icmp eq i32 %161, %1
br i1 %162, label %163, label %56
163: ; preds = %56, %3, %29
ret void
}