#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);
double pow(int, int);
double *buildNvals(int n) {
  int i;
  double *vals = malloc(sizeof(*vals) * n);
  for (i = 0; i < n; i++) {
    vals[i] = (0.1 + (double)(i % 10)) * pow(10, (i / 10));
  }
  return vals;
}


x86 assembly (clang, -O0):
<buildNvals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11af <buildNvals+0x8f>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm1
movsd  0xe98(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0xa,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1145 <buildNvals+0x25>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildNvals>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1196 <buildNvals+0x76>
mov    %r14d,%r14d
xor    %ebx,%ebx
mov    $0xcccccccd,%r12d
nopl   0x0(%rax,%rax,1)
mov    %ebx,%esi
imul   %r12,%rsi
shr    $0x23,%rsi
lea    (%rsi,%rsi,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
addsd  0xe8d(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
call   1040 <pow@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1150 <buildNvals+0x30>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double* @buildNvals(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca double*
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = mul i64 8, %6
%8 = trunc i64 %7 to i32
%9 = call double* @malloc(i32 %8)
store double* %9, double** %4
store i32 0, i32* %3
br label %10
10: ; preds = %27, %1
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i32, i32* %3
%16 = srem i32 %15, 10
%17 = sitofp i32 %16 to double
%18 = fadd double 1.000000e-01, %17
%19 = load i32, i32* %3
%20 = sdiv i32 %19, 10
%21 = call double @pow(i32 10, i32 %20)
%22 = fmul double %18, %21
%23 = load double*, double** %4
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
store double %22, double* %26
br label %27
27: ; preds = %14
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %10
30: ; preds = %10
%31 = load double*, double** %4
ret double* %31
}

LLVM IR (-O2):
define noalias double* @buildNvals(i32 %0) {
%2 = shl i32 %0, 3
%3 = tail call double* @malloc(i32 %2)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %19
5: ; preds = %1
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %17, %7 ]
%9 = trunc i64 %8 to i32
%10 = urem i32 %9, 10
%11 = sitofp i32 %10 to double
%12 = fadd double %11, 1.000000e-01
%13 = udiv i32 %9, 10
%14 = tail call double @pow(i32 10, i32 %13)
%15 = fmul double %12, %14
%16 = getelementptr inbounds double, double* %3, i64 %8
store double %15, double* %16
%17 = add nuw nsw i64 %8, 1
%18 = icmp eq i64 %17, %6
br i1 %18, label %19, label %7
19: ; preds = %7, %1
ret double* %3
}