int test_deinterleave(int argc, char *argv[]) {
  int i = 0;
  short test_input[160];
  short test_result_1[160 / 2];
  short test_result_2[160 / 2];
  short *test_result[2];
  printf("\n * Test: %s\n", __PRETTY_FUNCTION__);
  test_result[0] = test_result_1;
  test_result[1] = test_result_2;
  for (i = 0; i < 160; i++) {
    test_input[i] = 1;
    i++;
    test_input[i] = 2;
  }
  for (i = 0; i < 160 / 2; i++) {
    test_result_1[i] = 0;
    test_result_2[i] = 0;
  }
  deinterleave_stereo_to_mono((const short *)(&test_input[0]), test_result,
                              160);
  for (i = 0; i < 160 / 2; i++) {
    printf("test result 1 in idex %d is %d\n", i, test_result_1[i]);
  }
  for (i = 0; i < 160 / 2; i++) {
    printf("test result 2 in index %d is %d\n", i, test_result_2[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_deinterleave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2b0,%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>
lea    -0x200(%rbp),%rax
mov    %rax,-0x2b0(%rbp)
lea    -0x2a0(%rbp),%rax
mov    %rax,-0x2a8(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa0,-0x14(%rbp)
jge    11b1 <test_deinterleave+0x91>
movslq -0x14(%rbp),%rax
movw   $0x1,-0x160(%rbp,%rax,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
movw   $0x2,-0x160(%rbp,%rax,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1171 <test_deinterleave+0x51>
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    11ec <test_deinterleave+0xcc>
movslq -0x14(%rbp),%rax
movw   $0x0,-0x200(%rbp,%rax,2)
movslq -0x14(%rbp),%rax
movw   $0x0,-0x2a0(%rbp,%rax,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b8 <test_deinterleave+0x98>
lea    -0x160(%rbp),%rdi
lea    -0x2b0(%rbp),%rsi
mov    $0xa0,%edx
mov    $0x0,%al
call   1040 <deinterleave_stereo_to_mono@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    1242 <test_deinterleave+0x122>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
movswl -0x200(%rbp,%rax,2),%edx
ff
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    120d <test_deinterleave+0xed>
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    127e <test_deinterleave+0x15e>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
movswl -0x2a0(%rbp,%rax,2),%edx
ff
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1249 <test_deinterleave+0x129>
xor    %eax,%eax
add    $0x2b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_deinterleave>:
push   %r14
push   %rbx
sub    $0x298,%rsp
lea    0xedf(%rip),%rdi
lea    0xee6(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xb0(%rsp),%rax
mov    %rax,(%rsp)
lea    0x10(%rsp),%rax
mov    %rax,0x8(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x200(%rsp)
movaps %xmm0,0x210(%rsp)
movaps %xmm0,0x220(%rsp)
movaps %xmm0,0x230(%rsp)
movaps %xmm0,0x240(%rsp)
movaps %xmm0,0x250(%rsp)
movaps %xmm0,0x260(%rsp)
movaps %xmm0,0x270(%rsp)
movaps %xmm0,0x280(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0x150(%rsp),%rdi
mov    %rsp,%rsi
mov    $0xa0,%edx
xor    %eax,%eax
call   1040 <deinterleave_stereo_to_mono@plt>
lea    0xd9a(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movswl 0xb0(%rsp,%rbx,2),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x50,%rbx
jne    12b0 <test_deinterleave+0x190>
lea    0xd8d(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movswl 0x10(%rsp,%rbx,2),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x50,%rbx
jne    12e0 <test_deinterleave+0x1c0>
xor    %eax,%eax
add    $0x298,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"\0A * Test: %s\0A\00"
@__PRETTY_FUNCTION__.test_deinterleave = [36 x i8] c"int test_deinterleave(int, char **)\00"
@.str.1 = [32 x i8] c"test result 1 in idex %d is %d\0A\00"
@.str.2 = [33 x i8] c"test result 2 in index %d is %d\0A\00"
define i32 @test_deinterleave(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [160 x i16]
%4 = alloca [80 x i16]
%5 = bitcast [80 x i16]* %4 to i8*
%6 = alloca [80 x i16]
%7 = bitcast [80 x i16]* %6 to i8*
%8 = alloca [2 x i16*]
%9 = bitcast [160 x i16]* %3 to i8*
%10 = bitcast [2 x i16*]* %8 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @__PRETTY_FUNCTION__.test_deinterleave, i64 0, i64 0))
%12 = getelementptr inbounds [80 x i16], [80 x i16]* %4, i64 0, i64 0
%13 = getelementptr inbounds [2 x i16*], [2 x i16*]* %8, i64 0, i64 0
store i16* %12, i16** %13
%14 = getelementptr inbounds [80 x i16], [80 x i16]* %6, i64 0, i64 0
%15 = getelementptr inbounds [2 x i16*], [2 x i16*]* %8, i64 0, i64 1
store i16* %14, i16** %15
%16 = bitcast [160 x i16]* %3 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %16
%17 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 8
%18 = bitcast i16* %17 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %18
%19 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 16
%20 = bitcast i16* %19 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %20
%21 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 24
%22 = bitcast i16* %21 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %22
%23 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 32
%24 = bitcast i16* %23 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %24
%25 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 40
%26 = bitcast i16* %25 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %26
%27 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 48
%28 = bitcast i16* %27 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %28
%29 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 56
%30 = bitcast i16* %29 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %30
%31 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 64
%32 = bitcast i16* %31 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %32
%33 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 72
%34 = bitcast i16* %33 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %34
%35 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 80
%36 = bitcast i16* %35 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %36
%37 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 88
%38 = bitcast i16* %37 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %38
%39 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 96
%40 = bitcast i16* %39 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %40
%41 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 104
%42 = bitcast i16* %41 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %42
%43 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 112
%44 = bitcast i16* %43 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %44
%45 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 120
%46 = bitcast i16* %45 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %46
%47 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 128
%48 = bitcast i16* %47 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %48
%49 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 136
%50 = bitcast i16* %49 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %50
%51 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 144
%52 = bitcast i16* %51 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %52
%53 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 152
%54 = bitcast i16* %53 to <8 x i16>*
store <8 x i16> <i16 1, i16 2, i16 1, i16 2, i16 1, i16 2, i16 1, i16 2>, <8 x i16>* %54
%55 = getelementptr inbounds [160 x i16], [160 x i16]* %3, i64 0, i64 0
%56 = call i32 (i16*, i16**, i32, ...) bitcast (i32 (...)* @deinterleave_stereo_to_mono to i32 (i16*, i16**, i32, ...)*)(i16* %55, i16** %13, i32 160)
br label %57
57: ; preds = %2, %57
%58 = phi i64 [ 0, %2 ], [ %64, %57 ]
%59 = getelementptr inbounds [80 x i16], [80 x i16]* %4, i64 0, i64 %58
%60 = load i16, i16* %59
%61 = sext i16 %60 to i32
%62 = trunc i64 %58 to i32
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %62, i32 %61)
%64 = add nuw nsw i64 %58, 1
%65 = icmp eq i64 %64, 80
br i1 %65, label %66, label %57
66: ; preds = %57, %66
%67 = phi i64 [ %73, %66 ], [ 0, %57 ]
%68 = getelementptr inbounds [80 x i16], [80 x i16]* %6, i64 0, i64 %67
%69 = load i16, i16* %68
%70 = sext i16 %69 to i32
%71 = trunc i64 %67 to i32
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %71, i32 %70)
%73 = add nuw nsw i64 %67, 1
%74 = icmp eq i64 %73, 80
br i1 %74, label %75, label %66
75: ; preds = %66
ret i32 0
}