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

/* Variables and functions */
double *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  double *a;
  int n = 10;
  int i;
  a = malloc(sizeof(double) * n);
  for (i = 0; i < n; i++) {
    printf("%lf ", a[i]);
  }
  printf("caculate sizeof(a)/sizeof(double) = %lu\n",
         sizeof(a) / sizeof(double));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1183 <main+0x63>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%esi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1150 <main+0x30>
lea    0xe7b(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x50,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
cvttsd2si (%rax),%esi
lea    0xec4(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
cvttsd2si 0x8(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
cvttsd2si 0x10(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
cvttsd2si 0x18(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
cvttsd2si 0x20(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
cvttsd2si 0x28(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
cvttsd2si 0x30(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
cvttsd2si 0x38(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
cvttsd2si 0x40(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
cvttsd2si 0x48(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
lea    0xe45(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lf \00"
@.str.1 = [41 x i8] c"caculate sizeof(a)/sizeof(double) = %lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %3
%5 = load i32, i32* %3
%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** %2
store i32 0, i32* %4
br label %10
10: ; preds = %22, %0
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load double*, double** %2
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = fptosi double %19 to i32
%21 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %14
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %10
25: ; preds = %10
%26 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 1)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lf \00"
@.str.1 = [41 x i8] c"caculate sizeof(a)/sizeof(double) = %lu\0A\00"
define i32 @main() {
%1 = tail call double* @malloc(i32 80)
%2 = load double, double* %1
%3 = fptosi double %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = getelementptr inbounds double, double* %1, i64 1
%6 = load double, double* %5
%7 = fptosi double %6 to i32
%8 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds double, double* %1, i64 2
%10 = load double, double* %9
%11 = fptosi double %10 to i32
%12 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds double, double* %1, i64 3
%14 = load double, double* %13
%15 = fptosi double %14 to i32
%16 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds double, double* %1, i64 4
%18 = load double, double* %17
%19 = fptosi double %18 to i32
%20 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds double, double* %1, i64 5
%22 = load double, double* %21
%23 = fptosi double %22 to i32
%24 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds double, double* %1, i64 6
%26 = load double, double* %25
%27 = fptosi double %26 to i32
%28 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds double, double* %1, i64 7
%30 = load double, double* %29
%31 = fptosi double %30 to i32
%32 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds double, double* %1, i64 8
%34 = load double, double* %33
%35 = fptosi double %34 to i32
%36 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds double, double* %1, i64 9
%38 = load double, double* %37
%39 = fptosi double %38 to i32
%40 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 1)
ret i32 0
}