#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(long, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double *dvector(long n) {
  double *v;
  if (n < 1) {
    fprintf(stderr, "dvector: parameter n must be > 0\n");
    return NULL;
  }
  if (!(v = (double *)calloc(n, sizeof(double))))
    fprintf(stderr, "dvector: out of memory\n");
  return v;
}


x86 assembly (clang, -O0):
<dvector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jge    1159 <dvector+0x39>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xeb9(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1192 <dvector+0x72>
mov    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    118a <dvector+0x6a>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dvector>:
push   %rbx
test   %rdi,%rdi
jle    1141 <dvector+0x21>
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1158 <dvector+0x38>
lea    0xee3(%rip),%rsi
jmp    114a <dvector+0x2a>
lea    0xeb8(%rip),%rsi
xor    %ebx,%ebx
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1040 <fprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"dvector: parameter n must be > 0\0A\00"
@.str.1 = [24 x i8] c"dvector: out of memory\0A\00"
define double* @dvector(i64 %0) {
%2 = alloca double*
%3 = alloca i64
%4 = alloca double*
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = icmp slt i64 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store double* null, double** %2
br label %20
10: ; preds = %1
%11 = load i64, i64* %3
%12 = call i64 @calloc(i64 %11, i32 8)
%13 = inttoptr i64 %12 to double*
store double* %13, double** %4
%14 = icmp ne double* %13, null
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %10
%19 = load double*, double** %4
store double* %19, double** %2
br label %20
20: ; preds = %18, %7
%21 = load double*, double** %2
ret double* %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"dvector: parameter n must be > 0\0A\00"
@.str.1 = [24 x i8] c"dvector: out of memory\0A\00"
define double* @dvector(i64 %0) {
%2 = icmp slt i64 %0, 1
br i1 %2, label %7, label %3
3: ; preds = %1
%4 = tail call i64 @calloc(i64 %0, i32 8)
%5 = inttoptr i64 %4 to double*
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %12
7: ; preds = %3, %1
%8 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), %3 ]
%9 = phi double* [ null, %1 ], [ %5, %3 ]
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* %8)
br label %12
12: ; preds = %7, %3
%13 = phi double* [ %5, %3 ], [ %9, %7 ]
ret double* %13
}