#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 uint8_t;

/* Variables and functions */
void convert_uint8_to_double(void *buf, double *val, int samples) {
  int i;
  for (i = 0; i < samples; i++)
    val[i] = ((uint8_t *)buf)[i];
}


x86 assembly (clang, -O0):
<convert_uint8_to_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    114a <convert_uint8_to_double+0x4a>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1116 <convert_uint8_to_double+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_uint8_to_double>:
test   %edx,%edx
jle    1276 <convert_uint8_to_double+0x176>
mov    %edx,%r9d
cmp    $0x4,%edx
jb     1126 <convert_uint8_to_double+0x26>
lea    (%rdi,%r9,8),%rax
cmp    %rsi,%rax
jbe    119c <convert_uint8_to_double+0x9c>
lea    (%rsi,%r9,8),%rax
cmp    %rdi,%rax
jbe    119c <convert_uint8_to_double+0x9c>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
add    %r9,%rax
mov    %r9,%rdx
and    $0x3,%rdx
je     1154 <convert_uint8_to_double+0x54>
nopw   0x0(%rax,%rax,1)
movsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%rsi,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rdx
jne    1140 <convert_uint8_to_double+0x40>
cmp    $0x3,%rax
jb     1276 <convert_uint8_to_double+0x176>
xchg   %ax,%ax
movsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%rsi,%rcx,8)
movsd  0x8(%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rsi,%rcx,8)
movsd  0x10(%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rsi,%rcx,8)
movsd  0x18(%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x18(%rsi,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%r9
jne    1160 <convert_uint8_to_double+0x60>
jmp    1276 <convert_uint8_to_double+0x176>
mov    %r9d,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rax
mov    %rax,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %edx,%r8d
and    $0x3,%r8d
cmp    $0xc,%rax
jae    11c2 <convert_uint8_to_double+0xc2>
xor    %eax,%eax
jmp    1228 <convert_uint8_to_double+0x128>
and    $0xfffffffffffffffc,%rdx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movups (%rdi,%rax,8),%xmm0
movups 0x10(%rdi,%rax,8),%xmm1
movups %xmm0,(%rsi,%rax,8)
movups %xmm1,0x10(%rsi,%rax,8)
movups 0x20(%rdi,%rax,8),%xmm0
movups 0x30(%rdi,%rax,8),%xmm1
movups %xmm0,0x20(%rsi,%rax,8)
movups %xmm1,0x30(%rsi,%rax,8)
movups 0x40(%rdi,%rax,8),%xmm0
movups 0x50(%rdi,%rax,8),%xmm1
movups %xmm0,0x40(%rsi,%rax,8)
movups %xmm1,0x50(%rsi,%rax,8)
movups 0x60(%rdi,%rax,8),%xmm0
movups 0x70(%rdi,%rax,8),%xmm1
movups %xmm0,0x60(%rsi,%rax,8)
movups %xmm1,0x70(%rsi,%rax,8)
add    $0x10,%rax
add    $0xfffffffffffffffc,%rdx
jne    11d0 <convert_uint8_to_double+0xd0>
test   %r8,%r8
je     126d <convert_uint8_to_double+0x16d>
lea    (%rsi,%rax,8),%r10
add    $0x10,%r10
lea    (%rdi,%rax,8),%rax
add    $0x10,%rax
shl    $0x5,%r8
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x10(%rax,%rdx,1),%xmm0
movups (%rax,%rdx,1),%xmm1
movups %xmm0,-0x10(%r10,%rdx,1)
movups %xmm1,(%r10,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%r8
jne    1250 <convert_uint8_to_double+0x150>
cmp    %r9,%rcx
jne    1128 <convert_uint8_to_double+0x28>
ret

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

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