#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 */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ stderr;
double *doublevector(int nl, int nh) {
  double *v;
  v = (double *)malloc((unsigned)(nh - nl + 1) * sizeof(double));
  if (!v) {
    fprintf(stderr, "allocation failure in doublevector()\n");
    exit(0);
  }
  return v - nl;
}


x86 assembly (clang, -O0):
<doublevector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117f <doublevector+0x4f>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doublevector>:
push   %rbx
mov    %edi,%ebx
sub    %edi,%esi
lea    0x8(,%rsi,8),%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1152 <doublevector+0x22>
movslq %ebx,%rcx
shl    $0x3,%rcx
sub    %rcx,%rax
pop    %rbx
ret
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"allocation failure in doublevector()\0A\00"
define double* @doublevector(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = load i32, i32* %3
%8 = sub nsw i32 %6, %7
%9 = add nsw i32 %8, 1
%10 = zext i32 %9 to i64
%11 = mul i64 %10, 8
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to double*
store double* %14, double** %5
%15 = load double*, double** %5
%16 = icmp ne double* %15, null
br i1 %16, label %21, label %17
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %2
%22 = load double*, double** %5
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = sub i64 0, %24
%26 = getelementptr inbounds double, double* %22, i64 %25
ret double* %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"allocation failure in doublevector()\0A\00"
define double* @doublevector(i32 %0, i32 %1) {
%3 = sub nsw i32 %1, %0
%4 = shl i32 %3, 3
%5 = add i32 %4, 8
%6 = tail call i64 @malloc(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = inttoptr i64 %6 to double*
%14 = sext i32 %0 to i64
%15 = sub nsw i64 0, %14
%16 = getelementptr inbounds double, double* %13, i64 %15
ret double* %16
}