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


x86 assembly (clang, -O0):
<test_interleave>:
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   1040 <printf@plt>
lea    -0xc0(%rbp),%rax
mov    %rax,-0x170(%rbp)
lea    -0x160(%rbp),%rax
mov    %rax,-0x168(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    11a5 <test_interleave+0x85>
movslq -0x14(%rbp),%rax
movw   $0x1,-0xc0(%rbp,%rax,2)
movslq -0x14(%rbp),%rax
movw   $0x2,-0x160(%rbp,%rax,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1171 <test_interleave+0x51>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa0,-0x14(%rbp)
jge    11d5 <test_interleave+0xb5>
movslq -0x14(%rbp),%rax
movw   $0x0,-0x2b0(%rbp,%rax,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ac <test_interleave+0x8c>
lea    -0x170(%rbp),%rdi
lea    -0x2b0(%rbp),%rsi
mov    $0x50,%edx
mov    $0x0,%al
call   1030 <interleave_mono_to_stereo@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa0,-0x14(%rbp)
jge    122e <test_interleave+0x10e>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
movswl -0x2b0(%rbp,%rax,2),%edx
ff
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f6 <test_interleave+0xd6>
xor    %eax,%eax
add    $0x2b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_interleave>:
push   %r14
push   %rbx
sub    $0x298,%rsp
lea    0xedf(%rip),%rdi
lea    0xee6(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xb0(%rsp),%rax
mov    %rax,(%rsp)
lea    0x10(%rsp),%rax
mov    %rax,0x8(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xe95(%rip),%xmm1
movaps %xmm1,0x10(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm1,0x20(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm1,0x30(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm1,0x40(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm1,0x50(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm1,0x60(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm1,0x70(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm1,0x80(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm1,0x90(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm1,0xa0(%rsp)
lea    0x150(%rsp),%rbx
mov    $0x140,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0x50,%edx
xor    %eax,%eax
call   1030 <interleave_mono_to_stereo@plt>
lea    0xe22(%rip),%r14
xor    %ebx,%ebx
movswl 0x150(%rsp,%rbx,2),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0xa0,%rbx
jne    1230 <test_interleave+0x100>
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_interleave = [34 x i8] c"int test_interleave(int, char **)\00"
@.str.1 = [31 x i8] c"test result in index %d is %d\0A\00"
define i32 @test_interleave(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [80 x i16]
%7 = alloca [80 x i16]
%8 = alloca [2 x i16*]
%9 = alloca [160 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 ([34 x i8], [34 x i8]* @__PRETTY_FUNCTION__.test_interleave, i64 0, i64 0))
%11 = getelementptr inbounds [80 x i16], [80 x i16]* %6, i64 0, i64 0
%12 = getelementptr inbounds [2 x i16*], [2 x i16*]* %8, i64 0, i64 0
store i16* %11, i16** %12
%13 = getelementptr inbounds [80 x i16], [80 x i16]* %7, i64 0, i64 0
%14 = getelementptr inbounds [2 x i16*], [2 x i16*]* %8, i64 0, i64 1
store i16* %13, i16** %14
store i32 0, i32* %5
br label %15
15: ; preds = %25, %2
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 80
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [80 x i16], [80 x i16]* %6, i64 0, i64 %20
store i16 1, i16* %21
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [80 x i16], [80 x i16]* %7, i64 0, i64 %23
store i16 2, i16* %24
br label %25
25: ; preds = %18
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %15
28: ; preds = %15
store i32 0, i32* %5
br label %29
29: ; preds = %36, %28
%30 = load i32, i32* %5
%31 = icmp slt i32 %30, 160
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [160 x i16], [160 x i16]* %9, i64 0, i64 %34
store i16 0, i16* %35
br label %36
36: ; preds = %32
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %29
39: ; preds = %29
%40 = getelementptr inbounds [2 x i16*], [2 x i16*]* %8, i64 0, i64 0
%41 = getelementptr inbounds [160 x i16], [160 x i16]* %9, i64 0, i64 0
%42 = call i32 (i16**, i16*, i32, ...) bitcast (i32 (...)* @interleave_mono_to_stereo to i32 (i16**, i16*, i32, ...)*)(i16** %40, i16* %41, i32 80)
store i32 0, i32* %5
br label %43
43: ; preds = %54, %39
%44 = load i32, i32* %5
%45 = icmp slt i32 %44, 160
br i1 %45, label %46, label %57
46: ; preds = %43
%47 = load i32, i32* %5
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [160 x i16], [160 x i16]* %9, i64 0, i64 %49
%51 = load i16, i16* %50
%52 = sext i16 %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %47, i32 %52)
br label %54
54: ; preds = %46
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %43
57: ; preds = %43
ret i32 0
}

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