#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 */

/* Variables and functions */
double *malloc(int);
void init_array(double **x) {
  double *y = malloc(sizeof(double) * 10);
  int i;
  for (i = 0; i < 10; ++i) {
    y[i] = i;
  }
  *x = y;
}


x86 assembly (clang, -O0):
<init_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x50,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    115b <init_array+0x4b>
cvtsi2sdl -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <init_array+0x21>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_array>:
push   %rbx
mov    %rdi,%rbx
mov    $0x50,%edi
call   1030 <malloc@plt>
xorps  %xmm0,%xmm0
movhps 0xed8(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xede(%rip),%xmm0
movups %xmm0,0x10(%rax)
movaps 0xee3(%rip),%xmm0
movups %xmm0,0x20(%rax)
movaps 0xee8(%rip),%xmm0
movups %xmm0,0x30(%rax)
movaps 0xeed(%rip),%xmm0
movups %xmm0,0x40(%rax)
mov    %rax,(%rbx)
pop    %rbx
ret

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

LLVM IR (-O2):
define void @init_array(double** nocapture writeonly %0) {
%2 = tail call double* @malloc(i32 80)
%3 = bitcast double* %2 to <2 x double>*
store <2 x double> <double 0.000000e+00, double 1.000000e+00>, <2 x double>* %3
%4 = getelementptr inbounds double, double* %2, i64 2
%5 = bitcast double* %4 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 3.000000e+00>, <2 x double>* %5
%6 = getelementptr inbounds double, double* %2, i64 4
%7 = bitcast double* %6 to <2 x double>*
store <2 x double> <double 4.000000e+00, double 5.000000e+00>, <2 x double>* %7
%8 = getelementptr inbounds double, double* %2, i64 6
%9 = bitcast double* %8 to <2 x double>*
store <2 x double> <double 6.000000e+00, double 7.000000e+00>, <2 x double>* %9
%10 = getelementptr inbounds double, double* %2, i64 8
%11 = bitcast double* %10 to <2 x double>*
store <2 x double> <double 8.000000e+00, double 9.000000e+00>, <2 x double>* %11
store double* %2, double** %0
ret void
}