int test_dup(int argc, char *argv[]) {
  int i = 0;
  short test_input[160 / 2];
  short test_result[160];
  printf("\n * Test: %s\n", __PRETTY_FUNCTION__);
  for (i = 0; i < 160 / 2; i++) {
    test_input[i] = 1;
    i++;
    test_input[i] = 2;
  }
  for (i = 0; i < 160; i++) {
    test_result[i] = 0;
  }
  dup_mono_to_interleaved_stereo(test_input, test_result, 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_dup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%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   $0x50,-0x14(%rbp)
jge    1192 <test_dup+0x72>
movslq -0x14(%rbp),%rax
movw   $0x1,-0xc0(%rbp,%rax,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
movw   $0x2,-0xc0(%rbp,%rax,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <test_dup+0x35>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa0,-0x14(%rbp)
jge    11c2 <test_dup+0xa2>
movslq -0x14(%rbp),%rax
movw   $0x0,-0x200(%rbp,%rax,2)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1199 <test_dup+0x79>
lea    -0xc0(%rbp),%rdi
lea    -0x200(%rbp),%rsi
mov    $0x50,%edx
mov    $0x0,%al
call   1040 <dup_mono_to_interleaved_stereo@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa0,-0x14(%rbp)
jge    121b <test_dup+0xfb>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
movswl -0x200(%rbp,%rax,2),%edx
ff
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e3 <test_dup+0xc3>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_dup>:
push   %r14
push   %rbx
sub    $0x1e8,%rsp
lea    0xecf(%rip),%rdi
lea    0xed6(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
lea    0xa0(%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   1040 <dup_mono_to_interleaved_stereo@plt>
lea    0xe7c(%rip),%r14
xor    %ebx,%ebx
nop
movswl 0xa0(%rsp,%rbx,2),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0xa0,%rbx
jne    11c0 <test_dup+0x90>
xor    %eax,%eax
add    $0x1e8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"\0A * Test: %s\0A\00"
@__PRETTY_FUNCTION__.test_dup = [27 x i8] c"int test_dup(int, char **)\00"
@.str.1 = [31 x i8] c"test result in index %d is %d\0A\00"
define i32 @test_dup(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [80 x i16]
%4 = alloca [160 x i16]
%5 = bitcast [160 x i16]* %4 to i8*
%6 = bitcast [80 x i16]* %3 to i8*
%7 = 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_dup, i64 0, i64 0))
%8 = bitcast [80 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>* %8
%9 = getelementptr inbounds [80 x i16], [80 x i16]* %3, i64 0, i64 8
%10 = bitcast i16* %9 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>* %10
%11 = getelementptr inbounds [80 x i16], [80 x i16]* %3, i64 0, i64 16
%12 = bitcast i16* %11 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>* %12
%13 = getelementptr inbounds [80 x i16], [80 x i16]* %3, i64 0, i64 24
%14 = bitcast i16* %13 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>* %14
%15 = getelementptr inbounds [80 x i16], [80 x i16]* %3, i64 0, i64 32
%16 = bitcast i16* %15 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 [80 x i16], [80 x i16]* %3, i64 0, i64 40
%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 [80 x i16], [80 x i16]* %3, i64 0, i64 48
%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 [80 x i16], [80 x i16]* %3, i64 0, i64 56
%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 [80 x i16], [80 x i16]* %3, i64 0, i64 64
%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 [80 x i16], [80 x i16]* %3, i64 0, i64 72
%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 [80 x i16], [80 x i16]* %3, i64 0, i64 0
%28 = getelementptr inbounds [160 x i16], [160 x i16]* %4, i64 0, i64 0
%29 = call i32 (i16*, i16*, i32, ...) bitcast (i32 (...)* @dup_mono_to_interleaved_stereo to i32 (i16*, i16*, i32, ...)*)(i16* %27, i16* %28, i32 80)
br label %30
30: ; preds = %2, %30
%31 = phi i64 [ 0, %2 ], [ %37, %30 ]
%32 = getelementptr inbounds [160 x i16], [160 x i16]* %4, i64 0, i64 %31
%33 = load i16, i16* %32
%34 = sext i16 %33 to i32
%35 = trunc i64 %31 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %34)
%37 = add nuw nsw i64 %31, 1
%38 = icmp eq i64 %37, 160
br i1 %38, label %39, label %30
39: ; preds = %30
ret i32 0
}