float *vector(nl, nh)
int nl, nh;
{
  float *v;
  v = (float *)(memset(malloc((unsigned)(nh - nl + 1) * sizeof(float)), 0,
                       (unsigned)(nh - nl + 1) * sizeof(float)));
  if (!v) {
    nrerror("allocation failure in vector()");
    return (0);
  } else
    return v - nl;
}


x86 assembly (clang, -O0):
<vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    %eax,%edi
shl    $0x2,%rdi
call   1050 <malloc@plt>
mov    %rax,%rdi
mov    %rdi,-0x20(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
mov    %eax,%edx
shl    $0x2,%rdx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a1 <vector+0x71>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <nrerror@plt>
movq   $0x0,-0x8(%rbp)
jmp    11b9 <vector+0x89>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vector>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
sub    %edi,%esi
add    $0x1,%esi
shl    $0x2,%rsi
mov    $0x1,%edi
call   1040 <calloc@plt>
test   %rax,%rax
je     114c <vector+0x2c>
mov    %rax,%rbx
movslq %ebp,%rax
shl    $0x2,%rax
sub    %rax,%rbx
jmp    115c <vector+0x3c>
lea    0xead(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <nrerror@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"allocation failure in vector()\00"
define float* @vector(i32 %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca i32
%6 = alloca float*
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = sub nsw i32 %7, %8
%10 = add nsw i32 %9, 1
%11 = zext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = call i8* @malloc(i64 %12)
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = sub nsw i32 %14, %15
%17 = add nsw i32 %16, 1
%18 = zext i32 %17 to i64
%19 = mul i64 %18, 4
%20 = bitcast i8* %13 to float*
store float* %20, float** %6
%21 = load float*, float** %6
%22 = icmp ne float* %21, null
br i1 %22, label %25, label %23
23: ; preds = %2
%24 = call i32 (i8*, ...) bitcast (i32 (...)* @nrerror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store float* null, float** %3
br label %31
25: ; preds = %2
%26 = load float*, float** %6
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = sub i64 0, %28
%30 = getelementptr inbounds float, float* %26, i64 %29
store float* %30, float** %3
br label %31
31: ; preds = %25, %23
%32 = load float*, float** %3
ret float* %32
}

LLVM IR (-O2):
@.str = [31 x i8] c"allocation failure in vector()\00"
define float* @vector(i32 %0, i32 %1) {
%3 = sub i32 1, %0
%4 = add i32 %3, %1
%5 = zext i32 %4 to i64
%6 = shl nuw nsw i64 %5, 2
%7 = call i8* @calloc(i64 1, i64 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @nrerror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %16
11: ; preds = %2
%12 = bitcast i8* %7 to float*
%13 = sext i32 %0 to i64
%14 = sub nsw i64 0, %13
%15 = getelementptr inbounds float, float* %12, i64 %14
br label %16
16: ; preds = %11, %9
%17 = phi float* [ %15, %11 ], [ null, %9 ]
ret float* %17
}