#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 int /*<<< orphan*/ b;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
void valarr(double a[], int n) {
  double b[2 * n];
  int m = sizeof(b) / sizeof(*b);
  printf("m = %d, n = %d\n", m, n);
  for (int i = 0; i < n; i++) {
    b[2 * i] = a[i];
    b[2 * i + 1] = a[i];
  }
}


x86 assembly (clang, -O0):
<valarr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
shl    $0x3,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
shl    $0x3,%rax
shr    $0x3,%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11be <valarr+0xae>
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x28(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rcx
movslq -0x28(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1167 <valarr+0x57>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valarr>:
mov    %esi,%edx
lea    (%rdx,%rdx,1),%esi
lea    0xee4(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"m = %d, n = %d\0A\00"
define void @valarr(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = mul nsw i32 2, %9
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %5
%13 = alloca double, i64 %11
store i64 %11, i64* %6
%14 = mul nuw i64 8, %11
%15 = udiv i64 %14, 8
%16 = trunc i64 %15 to i32
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = load i32, i32* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
store i32 0, i32* %8
br label %20
20: ; preds = %44, %2
%21 = load i32, i32* %8
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %47
24: ; preds = %20
%25 = load double*, double** %3
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = load i32, i32* %8
%31 = mul nsw i32 2, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %13, i64 %32
store double %29, double* %33
%34 = load double*, double** %3
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = load i32, i32* %8
%40 = mul nsw i32 2, %39
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %13, i64 %42
store double %38, double* %43
br label %44
44: ; preds = %24
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %20
47: ; preds = %20
%48 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"m = %d, n = %d\0A\00"
define void @valarr(double* nocapture readnone %0, i32 %1) {
%3 = shl nsw i32 %1, 1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %1)
ret void
}