#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
int main() {
  double *d;
  int a;
  d = (double *)calloc(4, sizeof(double));
  if (d == NULL) {
    fprintf(stderr, "Unable to allocate memory\n");
    return (0);
  }
  for (a = 0; a < 4; a++)
    printf("%f\n", *(d + a));
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117e <main+0x4e>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bd <main+0x8d>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11b6 <main+0x86>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1185 <main+0x55>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1187 <main+0x57>
mov    %rax,%rbx
movsd  (%rax),%xmm0
lea    0xec5(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
movsd  0x8(%rbx),%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
movsd  0x10(%rbx),%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
movsd  0x18(%rbx),%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
jmp    119c <main+0x6c>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Unable to allocate memory\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i64 @calloc(i32 4, i32 8)
%5 = inttoptr i64 %4 to double*
store double* %5, double** %2
%6 = load double*, double** %2
%7 = icmp eq double* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %26
11: ; preds = %0
store i32 0, i32* %3
br label %12
12: ; preds = %22, %11
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load double*, double** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %12
25: ; preds = %12
store i32 0, i32* %1
br label %26
26: ; preds = %25, %8
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Unable to allocate memory\0A\00"
@.str.1 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = tail call i64 @calloc(i32 4, i32 8)
%2 = inttoptr i64 %1 to double*
%3 = icmp eq i64 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %0
%5 = load double, double* %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %5)
%7 = getelementptr inbounds double, double* %2, i64 1
%8 = load double, double* %7
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %8)
%10 = getelementptr inbounds double, double* %2, i64 2
%11 = load double, double* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %11)
%13 = getelementptr inbounds double, double* %2, i64 3
%14 = load double, double* %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %14)
br label %19
16: ; preds = %0
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %4, %16
ret i32 0
}