#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__ malloc(size_t);
int /*<<< orphan*/ nrerror(char *);
double *dvector(long nl, long nh) {
  double *v;
  long i;
  v = (double *)malloc((size_t)((nh - nl + 1 + 1) * sizeof(double)));
  if (!v)
    nrerror("allocation failure in dvector()");
  for (i = nl; i <= nh; i++)
    v[i] = 0.0;
  return v - nl + 1;
}


x86 assembly (clang, -O0):
<dvector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
sub    -0x8(%rbp),%rdi
add    $0x1,%rdi
add    $0x1,%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1164 <dvector+0x44>
lea    0xea1(%rip),%rdi
call   1030 <nrerror@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     119b <dvector+0x7b>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116c <dvector+0x4c>
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
sub    -0x8(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
add    $0x8,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dvector>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rax
sub    %rdi,%rax
lea    0x10(,%rax,8),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1182 <dvector+0x52>
sub    %r14,%r15
jl     116e <dvector+0x3e>
lea    (%rbx,%r14,8),%rdi
lea    0x8(,%r15,8),%rdx
xor    %esi,%esi
call   1040 <memset@plt>
shl    $0x3,%r14
sub    %r14,%rbx
add    $0x8,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe77(%rip),%rdi
call   1030 <nrerror@plt>
sub    %r14,%r15
jge    115b <dvector+0x2b>
jmp    116e <dvector+0x3e>

LLVM IR (-O0):
@.str = [32 x i8] c"allocation failure in dvector()\00"
define double* @dvector(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca double*
%6 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = load i64, i64* %4
%8 = load i64, i64* %3
%9 = sub nsw i64 %7, %8
%10 = add nsw i64 %9, 1
%11 = add nsw i64 %10, 1
%12 = mul i64 %11, 8
%13 = call i64 @malloc(i64 %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 %19, label %17
17: ; preds = %2
%18 = call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %2
%20 = load i64, i64* %3
store i64 %20, i64* %6
br label %21
21: ; preds = %29, %19
%22 = load i64, i64* %6
%23 = load i64, i64* %4
%24 = icmp sle i64 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load double*, double** %5
%27 = load i64, i64* %6
%28 = getelementptr inbounds double, double* %26, i64 %27
store double 0.000000e+00, double* %28
br label %29
29: ; preds = %25
%30 = load i64, i64* %6
%31 = add nsw i64 %30, 1
store i64 %31, i64* %6
br label %21
32: ; preds = %21
%33 = load double*, double** %5
%34 = load i64, i64* %3
%35 = sub i64 0, %34
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = getelementptr inbounds double, double* %36, i64 1
ret double* %37
}

LLVM IR (-O2):
@.str = [32 x i8] c"allocation failure in dvector()\00"
define double* @dvector(i64 %0, i64 %1) {
%3 = sub nsw i64 %1, %0
%4 = shl i64 %3, 3
%5 = add i64 %4, 16
%6 = tail call i64 @malloc(i64 %5)
%7 = inttoptr i64 %6 to double*
%8 = icmp eq i64 %6, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @nrerror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = icmp slt i64 %1, %0
br i1 %12, label %19, label %13
13: ; preds = %11
%14 = getelementptr double, double* %7, i64 %0
%15 = bitcast double* %14 to i8*
%16 = add i64 %1, 1
%17 = sub i64 %16, %0
%18 = shl nuw i64 %17, 3
br label %19
19: ; preds = %13, %11
%20 = sub i64 0, %0
%21 = getelementptr inbounds double, double* %7, i64 %20
%22 = getelementptr inbounds double, double* %21, i64 1
ret double* %22
}