#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__ eca_malloc(size_t, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, int);
double *dvector(int Lo, int High) {
  double *temp;
  temp = (double *)eca_malloc((size_t)(High - Lo + 2) * sizeof(double),
                              "(size_t) (High-Lo + 2) * sizeof(double)");
  if (temp == NULL) {
    printf("\n\ndvector failed to allocate to array of length %d",
           High - Lo + 2);
    exit(1);
  }
  return (temp - Lo + 1);
}


x86 assembly (clang, -O0):
<dvector>:
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    $0x2,%eax
movslq %eax,%rdi
shl    $0x3,%rdi
lea    0xeab(%rip),%rsi
call   1040 <eca_malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1188 <dvector+0x58>
mov    -0x8(%rbp),%esi
sub    -0x4(%rbp),%esi
add    $0x2,%esi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%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    $0x8,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dvector>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
sub    %edi,%ebx
movslq %ebx,%rax
lea    0x10(,%rax,8),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <eca_malloc@plt>
test   %rax,%rax
je     116a <dvector+0x3a>
movslq %ebp,%rcx
shl    $0x3,%rcx
sub    %rcx,%rax
add    $0x8,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
add    $0x2,%ebx
lea    0xeb4(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"(size_t) (High-Lo + 2) * sizeof(double)\00"
@.str.1 = [51 x i8] c"\0A\0Advector failed to allocate to array of length %d\00"
define double* @dvector(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, 2
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 8
%12 = call i64 @eca_malloc(i64 %11, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%13 = inttoptr i64 %12 to double*
store double* %13, double** %5
%14 = load double*, double** %5
%15 = icmp eq double* %14, null
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = sub nsw i32 %17, %18
%20 = add nsw i32 %19, 2
%21 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load double*, double** %5
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = sub i64 0, %26
%28 = getelementptr inbounds double, double* %24, i64 %27
%29 = getelementptr inbounds double, double* %28, i64 1
ret double* %29
}

LLVM IR (-O2):
@.str = [40 x i8] c"(size_t) (High-Lo + 2) * sizeof(double)\00"
@.str.1 = [51 x i8] c"\0A\0Advector failed to allocate to array of length %d\00"
define double* @dvector(i32 %0, i32 %1) {
%3 = sub nsw i32 %1, %0
%4 = add nsw i32 %3, 2
%5 = sext i32 %4 to i64
%6 = shl nsw i64 %5, 3
%7 = tail call i64 @eca_malloc(i64 %6, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = inttoptr i64 %7 to double*
%14 = sext i32 %0 to i64
%15 = sub nsw i64 0, %14
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = getelementptr inbounds double, double* %16, i64 1
ret double* %17
}