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


x86 assembly (clang, -O0):
<cvector>:
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    $0x0,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1164 <cvector+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
jge    1197 <cvector+0x77>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116c <cvector+0x4c>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
sub    -0x8(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cvector>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
sub    %r15,%rdi
add    $0x2,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    115e <cvector+0x2e>
lea    0xea7(%rip),%rdi
call   1030 <nrerror@plt>
mov    %r14,%rdx
sub    %r15,%rdx
jle    1174 <cvector+0x44>
lea    (%rbx,%r15,1),%rdi
mov    $0x20,%esi
call   1040 <memset@plt>
movb   $0x0,(%rbx,%r14,1)
sub    %r15,%rbx
add    $0x1,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"allocation failure in cvector()\00"
define i8* @cvector(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
%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, 1
%13 = call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = icmp ne i8* %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 slt i64 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i8*, i8** %5
%27 = load i64, i64* %6
%28 = getelementptr inbounds i8, i8* %26, i64 %27
store i8 32, i8* %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 i8*, i8** %5
%34 = load i64, i64* %4
%35 = getelementptr inbounds i8, i8* %33, i64 %34
store i8 0, i8* %35
%36 = load i8*, i8** %5
%37 = load i64, i64* %3
%38 = sub i64 0, %37
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = getelementptr inbounds i8, i8* %39, i64 1
ret i8* %40
}

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