#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 */
int /*<<< orphan*/ memset(double *, int, long);
scalar_t__ realloc(double *, size_t);
double *dvector_realloc(double *v, long n_alt, long n_neu) {
  double *u;
  u = (double *)realloc(v, ((size_t)(n_neu + 1)) * sizeof(double));
  if (n_neu > n_alt)
    memset(u + n_alt + 1, 0x00, (n_neu - n_alt) * sizeof(double));
  return u;
}


x86 assembly (clang, -O0):
<dvector_realloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
shl    $0x3,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jle    1181 <dvector_realloc+0x61>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
add    $0x8,%rdi
mov    -0x18(%rbp),%rdx
sub    -0x10(%rbp),%rdx
shl    $0x3,%rdx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dvector_realloc>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r15
lea    0x8(,%rdx,8),%rsi
call   1040 <realloc@plt>
mov    %rax,%r14
sub    %r15,%rbx
jle    1156 <dvector_realloc+0x36>
lea    (%r14,%r15,8),%rdi
add    $0x8,%rdi
shl    $0x3,%rbx
xor    %esi,%esi
mov    %rbx,%rdx
call   1030 <memset@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double* @dvector_realloc(double* %0, i64 %1, i64 %2) {
%4 = alloca double*
%5 = alloca i64
%6 = alloca i64
%7 = alloca double*
store double* %0, double** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load double*, double** %4
%9 = load i64, i64* %6
%10 = add nsw i64 %9, 1
%11 = mul i64 %10, 8
%12 = call i64 @realloc(double* %8, i64 %11)
%13 = inttoptr i64 %12 to double*
store double* %13, double** %7
%14 = load i64, i64* %6
%15 = load i64, i64* %5
%16 = icmp sgt i64 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %3
%18 = load double*, double** %7
%19 = load i64, i64* %5
%20 = getelementptr inbounds double, double* %18, i64 %19
%21 = getelementptr inbounds double, double* %20, i64 1
%22 = load i64, i64* %6
%23 = load i64, i64* %5
%24 = sub nsw i64 %22, %23
%25 = mul i64 %24, 8
%26 = call i32 @memset(double* %21, i32 0, i64 %25)
br label %27
27: ; preds = %17, %3
%28 = load double*, double** %7
ret double* %28
}

LLVM IR (-O2):
define double* @dvector_realloc(double* %0, i64 %1, i64 %2) {
%4 = shl i64 %2, 3
%5 = add i64 %4, 8
%6 = tail call i64 @realloc(double* %0, i64 %5)
%7 = inttoptr i64 %6 to double*
%8 = icmp sgt i64 %2, %1
br i1 %8, label %9, label %15
9: ; preds = %3
%10 = getelementptr inbounds double, double* %7, i64 %1
%11 = getelementptr inbounds double, double* %10, i64 1
%12 = sub nsw i64 %2, %1
%13 = shl i64 %12, 3
%14 = tail call i32 @memset(double* %11, i32 0, i64 %13)
br label %15
15: ; preds = %9, %3
ret double* %7
}