#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 double int16_t;

/* Variables and functions */
void fmt_convert_s16_to_double(void *dest_v, void *src_v, int n) {
  double *dest = dest_v;
  int16_t *src = src_v;
  int i;
  for (i = 0; i < n; i++)
    dest[i] = src[i] / 32768.0;
}


x86 assembly (clang, -O0):
<fmt_convert_s16_to_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1166 <fmt_convert_s16_to_double+0x66>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xeb9(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1126 <fmt_convert_s16_to_double+0x26>
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmt_convert_s16_to_double>:
test   %edx,%edx
jle    127d <fmt_convert_s16_to_double+0x17d>
mov    %edx,%r9d
cmp    $0x4,%edx
jb     112a <fmt_convert_s16_to_double+0x2a>
lea    (%rsi,%r9,8),%rax
cmp    %rdi,%rax
jbe    11cc <fmt_convert_s16_to_double+0xcc>
lea    (%rdi,%r9,8),%rax
cmp    %rsi,%rax
jbe    11cc <fmt_convert_s16_to_double+0xcc>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
add    %r9,%rax
mov    %r9,%rdx
and    $0x3,%rdx
je     1168 <fmt_convert_s16_to_double+0x68>
movsd  0xeca(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
movsd  (%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rdx
jne    1150 <fmt_convert_s16_to_double+0x50>
cmp    $0x3,%rax
jb     127d <fmt_convert_s16_to_double+0x17d>
movsd  0xe96(%rip),%xmm0
nopw   0x0(%rax,%rax,1)
movsd  (%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rdi,%rcx,8)
movsd  0x10(%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rdi,%rcx,8)
movsd  0x18(%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rdi,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%r9
jne    1180 <fmt_convert_s16_to_double+0x80>
jmp    127d <fmt_convert_s16_to_double+0x17d>
mov    %r9d,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rax
mov    %rax,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rax,%rax
je     127e <fmt_convert_s16_to_double+0x17e>
mov    %r8,%rax
and    $0xfffffffffffffffe,%rax
xor    %edx,%edx
movapd 0xe05(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movupd (%rsi,%rdx,8),%xmm1
movupd 0x10(%rsi,%rdx,8),%xmm2
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,(%rdi,%rdx,8)
movupd %xmm2,0x10(%rdi,%rdx,8)
movupd 0x20(%rsi,%rdx,8),%xmm1
movupd 0x30(%rsi,%rdx,8),%xmm2
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,0x20(%rdi,%rdx,8)
movupd %xmm2,0x30(%rdi,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rax
jne    1200 <fmt_convert_s16_to_double+0x100>
test   $0x1,%r8b
je     1274 <fmt_convert_s16_to_double+0x174>
movupd (%rsi,%rdx,8),%xmm0
movupd 0x10(%rsi,%rdx,8),%xmm1
movapd 0xd9f(%rip),%xmm2
mulpd  %xmm2,%xmm0
mulpd  %xmm2,%xmm1
movupd %xmm0,(%rdi,%rdx,8)
movupd %xmm1,0x10(%rdi,%rdx,8)
cmp    %r9,%rcx
jne    112c <fmt_convert_s16_to_double+0x2c>
ret
xor    %edx,%edx
test   $0x1,%r8b
jne    124e <fmt_convert_s16_to_double+0x14e>
jmp    1274 <fmt_convert_s16_to_double+0x174>

LLVM IR (-O0):
define void @fmt_convert_s16_to_double(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to double*
store double* %11, double** %7
%12 = load i8*, i8** %5
%13 = bitcast i8* %12 to double*
store double* %13, double** %8
store i32 0, i32* %9
br label %14
14: ; preds = %29, %3
%15 = load i32, i32* %9
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = load double*, double** %8
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = fdiv double %23, 3.276800e+04
%25 = load double*, double** %7
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
store double %24, double* %28
br label %29
29: ; preds = %18
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %14
32: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @fmt_convert_s16_to_double(i8* nocapture writeonly %0, i8* nocapture %1, i32 %2) {
%4 = bitcast i8* %0 to double*
%5 = bitcast i8* %1 to double*
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %117
7: ; preds = %3
%8 = zext i32 %2 to i64
%9 = icmp ult i32 %2, 4
br i1 %9, label %75, label %10
10: ; preds = %7
%11 = shl nuw nsw i64 %8, 3
%12 = getelementptr i8, i8* %0, i64 %11
%13 = getelementptr i8, i8* %1, i64 %11
%14 = icmp ugt i8* %13, %0
%15 = icmp ugt i8* %12, %1
%16 = and i1 %14, %15
br i1 %16, label %75, label %17
17: ; preds = %10
%18 = and i64 %8, 4294967292
%19 = add nsw i64 %18, -4
%20 = lshr exact i64 %19, 2
%21 = add nuw nsw i64 %20, 1
%22 = and i64 %21, 1
%23 = icmp eq i64 %19, 0
br i1 %23, label %57, label %24
24: ; preds = %17
%25 = and i64 %21, 9223372036854775806
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ 0, %24 ], [ %54, %26 ]
%28 = phi i64 [ 0, %24 ], [ %55, %26 ]
%29 = getelementptr inbounds double, double* %5, i64 %27
%30 = bitcast double* %29 to <2 x double>*
%31 = load <2 x double>, <2 x double>* %30
%32 = getelementptr inbounds double, double* %29, i64 2
%33 = bitcast double* %32 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = fmul <2 x double> %31, <double 0x3F00000000000000, double 0x3F00000000000000>
%36 = fmul <2 x double> %34, <double 0x3F00000000000000, double 0x3F00000000000000>
%37 = getelementptr inbounds double, double* %4, i64 %27
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> %35, <2 x double>* %38
%39 = getelementptr inbounds double, double* %37, i64 2
%40 = bitcast double* %39 to <2 x double>*
store <2 x double> %36, <2 x double>* %40
%41 = or i64 %27, 4
%42 = getelementptr inbounds double, double* %5, i64 %41
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = getelementptr inbounds double, double* %42, i64 2
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = fmul <2 x double> %44, <double 0x3F00000000000000, double 0x3F00000000000000>
%49 = fmul <2 x double> %47, <double 0x3F00000000000000, double 0x3F00000000000000>
%50 = getelementptr inbounds double, double* %4, i64 %41
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %48, <2 x double>* %51
%52 = getelementptr inbounds double, double* %50, i64 2
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> %49, <2 x double>* %53
%54 = add nuw i64 %27, 8
%55 = add i64 %28, 2
%56 = icmp eq i64 %55, %25
br i1 %56, label %57, label %26
57: ; preds = %26, %17
%58 = phi i64 [ 0, %17 ], [ %54, %26 ]
%59 = icmp eq i64 %22, 0
br i1 %59, label %73, label %60
60: ; preds = %57
%61 = getelementptr inbounds double, double* %5, i64 %58
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = getelementptr inbounds double, double* %61, i64 2
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = fmul <2 x double> %63, <double 0x3F00000000000000, double 0x3F00000000000000>
%68 = fmul <2 x double> %66, <double 0x3F00000000000000, double 0x3F00000000000000>
%69 = getelementptr inbounds double, double* %4, i64 %58
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %67, <2 x double>* %70
%71 = getelementptr inbounds double, double* %69, i64 2
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %68, <2 x double>* %72
br label %73
73: ; preds = %57, %60
%74 = icmp eq i64 %18, %8
br i1 %74, label %117, label %75
75: ; preds = %10, %7, %73
%76 = phi i64 [ 0, %10 ], [ 0, %7 ], [ %18, %73 ]
%77 = xor i64 %76, -1
%78 = add nsw i64 %77, %8
%79 = and i64 %8, 3
%80 = icmp eq i64 %79, 0
br i1 %80, label %91, label %81
81: ; preds = %75, %81
%82 = phi i64 [ %88, %81 ], [ %76, %75 ]
%83 = phi i64 [ %89, %81 ], [ 0, %75 ]
%84 = getelementptr inbounds double, double* %5, i64 %82
%85 = load double, double* %84
%86 = fmul double %85, 0x3F00000000000000
%87 = getelementptr inbounds double, double* %4, i64 %82
store double %86, double* %87
%88 = add nuw nsw i64 %82, 1
%89 = add i64 %83, 1
%90 = icmp eq i64 %89, %79
br i1 %90, label %91, label %81
91: ; preds = %81, %75
%92 = phi i64 [ %76, %75 ], [ %88, %81 ]
%93 = icmp ult i64 %78, 3
br i1 %93, label %117, label %94
94: ; preds = %91, %94
%95 = phi i64 [ %115, %94 ], [ %92, %91 ]
%96 = getelementptr inbounds double, double* %5, i64 %95
%97 = load double, double* %96
%98 = fmul double %97, 0x3F00000000000000
%99 = getelementptr inbounds double, double* %4, i64 %95
store double %98, double* %99
%100 = add nuw nsw i64 %95, 1
%101 = getelementptr inbounds double, double* %5, i64 %100
%102 = load double, double* %101
%103 = fmul double %102, 0x3F00000000000000
%104 = getelementptr inbounds double, double* %4, i64 %100
store double %103, double* %104
%105 = add nuw nsw i64 %95, 2
%106 = getelementptr inbounds double, double* %5, i64 %105
%107 = load double, double* %106
%108 = fmul double %107, 0x3F00000000000000
%109 = getelementptr inbounds double, double* %4, i64 %105
store double %108, double* %109
%110 = add nuw nsw i64 %95, 3
%111 = getelementptr inbounds double, double* %5, i64 %110
%112 = load double, double* %111
%113 = fmul double %112, 0x3F00000000000000
%114 = getelementptr inbounds double, double* %4, i64 %110
store double %113, double* %114
%115 = add nuw nsw i64 %95, 4
%116 = icmp eq i64 %115, %8
br i1 %116, label %117, label %94
117: ; preds = %91, %94, %73, %3
ret void
}