int test_mix(int argc, char *argv[]) {
  int i = 0;
  short test_input1[160];
  short test_input2[160];
  short test_result[160];
  printf("\n * Test: %s\n", __PRETTY_FUNCTION__);
  for (i = 0; i < 160; i++) {
    test_input1[i] = ((i % 61) - 30) * 1000;
    test_input2[i] = ((i % 31) - 15) * 2000;
  }
  for (i = 0; i < 160; i++) {
    test_result[i] = 0;
  }
  symmetric_mix(test_input1, test_input2, test_result, 160);
  for (i = 0; i < 160; i++) {
    printf("test result %d + %d = %d (sample %d)\n", test_input1[i],
           test_input2[i], test_result[i], i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_mix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3e0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec0(%rip),%rdi
lea    0xec7(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa0,-0x14(%rbp)
jge    11b6 <test_mix+0x96>
mov    -0x14(%rbp),%eax
mov    $0x3d,%ecx
cltd
idiv   %ecx
sub    $0x1e,%edx
imul   $0x3e8,%edx,%eax
mov    %ax,%cx
movslq -0x14(%rbp),%rax
mov    %cx,-0x160(%rbp,%rax,2)
ff
mov    -0x14(%rbp),%eax
mov    $0x1f,%ecx
cltd
idiv   %ecx
sub    $0xf,%edx
imul   $0x7d0,%edx,%eax
mov    %ax,%cx
movslq -0x14(%rbp),%rax
mov    %cx,-0x2a0(%rbp,%rax,2)
ff
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <test_mix+0x35>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa0,-0x14(%rbp)
jge    11e6 <test_mix+0xc6>
movslq -0x14(%rbp),%rax
movw   $0x0,-0x3e0(%rbp,%rax,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bd <test_mix+0x9d>
lea    -0x160(%rbp),%rdi
lea    -0x2a0(%rbp),%rsi
lea    -0x3e0(%rbp),%rdx
mov    $0xa0,%ecx
mov    $0x0,%al
call   1040 <symmetric_mix@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa0,-0x14(%rbp)
jge    125f <test_mix+0x13f>
movslq -0x14(%rbp),%rax
movswl -0x160(%rbp,%rax,2),%esi
ff
movslq -0x14(%rbp),%rax
movswl -0x2a0(%rbp,%rax,2),%edx
ff
movslq -0x14(%rbp),%rax
movswl -0x3e0(%rbp,%rax,2),%ecx
ff
mov    -0x14(%rbp),%r8d
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    120e <test_mix+0xee>
xor    %eax,%eax
add    $0x3e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mix>:
push   %r14
push   %rbx
sub    $0x3c8,%rsp
lea    0xf8f(%rip),%rdi
lea    0xf96(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
movdqa 0xea6(%rip),%xmm9
movdqa 0xeae(%rip),%xmm1
pxor   %xmm2,%xmm2
movdqa 0xeb2(%rip),%xmm3
movdqa 0xed9(%rip),%xmm10
movdqa 0xee0(%rip),%xmm11
movdqa 0xee8(%rip),%xmm4
movdqa 0xef0(%rip),%xmm5
movdqa 0xef7(%rip),%xmm12
movdqa 0xefe(%rip),%xmm13
movdqa 0xf05(%rip),%xmm14
movdqa 0xf0c(%rip),%xmm15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqa %xmm9,%xmm7
punpckhbw %xmm2,%xmm7
movdqa %xmm7,%xmm6
pmullw %xmm1,%xmm6
psrlw  $0x8,%xmm6
movdqa %xmm9,%xmm8
punpcklbw %xmm2,%xmm8
movdqa %xmm8,%xmm0
pmullw %xmm1,%xmm0
psrlw  $0x8,%xmm0
packuswb %xmm6,%xmm0
movdqa %xmm9,%xmm6
psubb  %xmm0,%xmm6
psrlw  $0x1,%xmm6
pand   %xmm3,%xmm6
paddb  %xmm0,%xmm6
psrlw  $0x5,%xmm6
pand   0xe1b(%rip),%xmm6
punpcklbw %xmm6,%xmm6
pmullw 0xe1f(%rip),%xmm6
pand   %xmm10,%xmm6
packuswb %xmm6,%xmm6
movdqa %xmm9,%xmm0
psubb  %xmm6,%xmm0
punpcklbw %xmm2,%xmm0
pmullw %xmm11,%xmm0
paddw  %xmm4,%xmm0
movdqa %xmm0,0x140(%rsp,%rbx,2)
pmullw %xmm5,%xmm7
psrlw  $0x8,%xmm7
pmullw %xmm5,%xmm8
psrlw  $0x8,%xmm8
packuswb %xmm7,%xmm8
movdqa %xmm9,%xmm0
psubb  %xmm8,%xmm0
psrlw  $0x1,%xmm0
pand   %xmm3,%xmm0
paddb  %xmm8,%xmm0
psrlw  $0x4,%xmm0
pand   %xmm12,%xmm0
movdqa %xmm0,%xmm6
psllw  $0x5,%xmm6
pand   %xmm13,%xmm6
psubb  %xmm6,%xmm0
paddb  %xmm9,%xmm0
punpcklbw %xmm2,%xmm0
pmullw %xmm14,%xmm0
paddw  %xmm4,%xmm0
movdqa %xmm0,(%rsp,%rbx,2)
add    $0x8,%rbx
paddb  %xmm15,%xmm9
cmp    $0xa0,%rbx
jne    11c0 <test_mix+0x90>
lea    0x280(%rsp),%rbx
mov    $0x140,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0x140(%rsp),%rdi
mov    %rsp,%rsi
mov    %rbx,%rdx
mov    $0xa0,%ecx
xor    %eax,%eax
call   1050 <symmetric_mix@plt>
lea    0xdfe(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
movswl 0x140(%rsp,%rbx,2),%esi
movswl (%rsp,%rbx,2),%edx
movswl 0x280(%rsp,%rbx,2),%ecx
mov    %r14,%rdi
mov    %ebx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0xa0,%rbx
jne    1300 <test_mix+0x1d0>
xor    %eax,%eax
add    $0x3c8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\0A * Test: %s\0A\00"
@__PRETTY_FUNCTION__.test_mix = [27 x i8] c"int test_mix(int, char **)\00"
@.str.1 = [38 x i8] c"test result %d + %d = %d (sample %d)\0A\00"
define i32 @test_mix(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [160 x i16]
%7 = alloca [160 x i16]
%8 = alloca [160 x i16]
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @__PRETTY_FUNCTION__.test_mix, i64 0, i64 0))
store i32 0, i32* %5
br label %10
10: ; preds = %30, %2
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 160
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = load i32, i32* %5
%15 = srem i32 %14, 61
%16 = sub nsw i32 %15, 30
%17 = mul nsw i32 %16, 1000
%18 = trunc i32 %17 to i16
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [160 x i16], [160 x i16]* %6, i64 0, i64 %20
store i16 %18, i16* %21
%22 = load i32, i32* %5
%23 = srem i32 %22, 31
%24 = sub nsw i32 %23, 15
%25 = mul nsw i32 %24, 2000
%26 = trunc i32 %25 to i16
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [160 x i16], [160 x i16]* %7, i64 0, i64 %28
store i16 %26, i16* %29
br label %30
30: ; preds = %13
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %10
33: ; preds = %10
store i32 0, i32* %5
br label %34
34: ; preds = %41, %33
%35 = load i32, i32* %5
%36 = icmp slt i32 %35, 160
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [160 x i16], [160 x i16]* %8, i64 0, i64 %39
store i16 0, i16* %40
br label %41
41: ; preds = %37
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %34
44: ; preds = %34
%45 = getelementptr inbounds [160 x i16], [160 x i16]* %6, i64 0, i64 0
%46 = getelementptr inbounds [160 x i16], [160 x i16]* %7, i64 0, i64 0
%47 = getelementptr inbounds [160 x i16], [160 x i16]* %8, i64 0, i64 0
%48 = call i32 (i16*, i16*, i16*, i32, ...) bitcast (i32 (...)* @symmetric_mix to i32 (i16*, i16*, i16*, i32, ...)*)(i16* %45, i16* %46, i16* %47, i32 160)
store i32 0, i32* %5
br label %49
49: ; preds = %70, %44
%50 = load i32, i32* %5
%51 = icmp slt i32 %50, 160
br i1 %51, label %52, label %73
52: ; preds = %49
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [160 x i16], [160 x i16]* %6, i64 0, i64 %54
%56 = load i16, i16* %55
%57 = sext i16 %56 to i32
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [160 x i16], [160 x i16]* %7, i64 0, i64 %59
%61 = load i16, i16* %60
%62 = sext i16 %61 to i32
%63 = load i32, i32* %5
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [160 x i16], [160 x i16]* %8, i64 0, i64 %64
%66 = load i16, i16* %65
%67 = sext i16 %66 to i32
%68 = load i32, i32* %5
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %57, i32 %62, i32 %67, i32 %68)
br label %70
70: ; preds = %52
%71 = load i32, i32* %5
%72 = add nsw i32 %71, 1
store i32 %72, i32* %5
br label %49
73: ; preds = %49
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"\0A * Test: %s\0A\00"
@__PRETTY_FUNCTION__.test_mix = [27 x i8] c"int test_mix(int, char **)\00"
@.str.1 = [38 x i8] c"test result %d + %d = %d (sample %d)\0A\00"
define i32 @test_mix(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [160 x i16]
%4 = alloca [160 x i16]
%5 = alloca [160 x i16]
%6 = bitcast [160 x i16]* %5 to i8*
%7 = bitcast [160 x i16]* %3 to i8*
%8 = bitcast [160 x i16]* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @__PRETTY_FUNCTION__.test_mix, i64 0, i64 0))
br label %10
10: ; preds = %10, %2
%11 = phi i64 [ 0, %2 ], [ %25, %10 ]
%12 = phi <8 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7>, %2 ], [ %26, %10 ]
%13 = urem <8 x i8> %12, <i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61, i8 61>
%14 = zext <8 x i8> %13 to <8 x i16>
%15 = mul nuw <8 x i16> %14, <i16 1000, i16 1000, i16 1000, i16 1000, i16 1000, i16 1000, i16 1000, i16 1000>
%16 = add <8 x i16> %15, <i16 -30000, i16 -30000, i16 -30000, i16 -30000, i16 -30000, i16 -30000, i16 -30000, i16 -30000>
%17 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 %11
%18 = bitcast i16* %17 to <8 x i16>*
store <8 x i16> %16, <8 x i16>* %18
%19 = urem <8 x i8> %12, <i8 31, i8 31, i8 31, i8 31, i8 31, i8 31, i8 31, i8 31>
%20 = zext <8 x i8> %19 to <8 x i16>
%21 = mul nuw <8 x i16> %20, <i16 2000, i16 2000, i16 2000, i16 2000, i16 2000, i16 2000, i16 2000, i16 2000>
%22 = add <8 x i16> %21, <i16 -30000, i16 -30000, i16 -30000, i16 -30000, i16 -30000, i16 -30000, i16 -30000, i16 -30000>
%23 = getelementptr inbounds [160 x i16], [160 x i16]* %4, i64 0, i64 %11
%24 = bitcast i16* %23 to <8 x i16>*
store <8 x i16> %22, <8 x i16>* %24
%25 = add nuw i64 %11, 8
%26 = add <8 x i8> %12, <i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8>
%27 = icmp eq i64 %25, 160
br i1 %27, label %28, label %10
28: ; preds = %10
%29 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 0
%30 = getelementptr inbounds [160 x i16], [160 x i16]* %4, i64 0, i64 0
%31 = getelementptr inbounds [160 x i16], [160 x i16]* %5, i64 0, i64 0
%32 = call i32 (i16*, i16*, i16*, i32, ...) bitcast (i32 (...)* @symmetric_mix to i32 (i16*, i16*, i16*, i32, ...)*)(i16* %29, i16* %30, i16* %31, i32 160)
br label %33
33: ; preds = %28, %33
%34 = phi i64 [ 0, %28 ], [ %46, %33 ]
%35 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 %34
%36 = load i16, i16* %35
%37 = sext i16 %36 to i32
%38 = getelementptr inbounds [160 x i16], [160 x i16]* %4, i64 0, i64 %34
%39 = load i16, i16* %38
%40 = sext i16 %39 to i32
%41 = getelementptr inbounds [160 x i16], [160 x i16]* %5, i64 0, i64 %34
%42 = load i16, i16* %41
%43 = sext i16 %42 to i32
%44 = trunc i64 %34 to i32
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %40, i32 %43, i32 %44)
%46 = add nuw nsw i64 %34, 1
%47 = icmp eq i64 %46, 160
br i1 %47, label %48, label %33
48: ; preds = %33
ret i32 0
}