#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 *);
long *lvector(long nl, long nh) {
  long *v, i;
  v = (long *)malloc((size_t)((nh - nl + 1 + 1) * sizeof(long)));
  if (!v)
    nrerror("allocation failure in lvector()");
  for (i = nl; i <= nh; i++)
    v[i] = 0;
  return v - nl + 1;
}


x86 assembly (clang, -O0):
<lvector>:
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 <lvector+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 <lvector+0x7b>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116c <lvector+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):
<lvector>:
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 <lvector+0x52>
sub    %r14,%r15
jl     116e <lvector+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 <lvector+0x2b>
jmp    116e <lvector+0x3e>

LLVM IR (-O0):
@.str = [32 x i8] c"allocation failure in lvector()\00"
define i64* @lvector(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64*
%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 i64*
store i64* %14, i64** %5
%15 = load i64*, i64** %5
%16 = icmp ne i64* %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 i64*, i64** %5
%27 = load i64, i64* %6
%28 = getelementptr inbounds i64, i64* %26, i64 %27
store i64 0, i64* %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 i64*, i64** %5
%34 = load i64, i64* %3
%35 = sub i64 0, %34
%36 = getelementptr inbounds i64, i64* %33, i64 %35
%37 = getelementptr inbounds i64, i64* %36, i64 1
ret i64* %37
}

LLVM IR (-O2):
@.str = [32 x i8] c"allocation failure in lvector()\00"
define i64* @lvector(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 i64*
%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 i64, i64* %7, i64 %0
%15 = bitcast i64* %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 i64, i64* %7, i64 %20
%22 = getelementptr inbounds i64, i64* %21, i64 1
ret i64* %22
}