#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(int);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
int x_dw(double const, double const, int);
double *interpolateX(const double xs[], int dot_i, int smooth) {
  double *xi = (double *)malloc(sizeof(double) * (smooth - 1));
  memset(xi, 0, sizeof(double) * (smooth - 1));
  int i;
  for (i = 1; i < smooth; ++i)
    xi[i - 1] = x_dw(xs[dot_i], xs[dot_i + 1], smooth) * i + xs[dot_i];
  return xi;
}


x86 assembly (clang, -O0):
<interpolateX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e1 <interpolateX+0xb1>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%edi
call   1050 <x_dw@plt>
imul   -0x1c(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1179 <interpolateX+0x49>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpolateX>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbx
lea    -0x8(,%r15,8),%ebp
ff
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <memset@plt>
cmp    $0x2,%r15d
jl     11b6 <interpolateX+0x86>
mov    %r15d,%r15d
movslq %r12d,%r13
lea    0x1(%r13),%eax
movslq %eax,%r12
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%r13,8),%xmm0
movsd  (%rbx,%r12,8),%xmm1
mov    %r15d,%edi
call   1050 <x_dw@plt>
mov    %ebp,%ecx
imul   %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
addsd  (%rbx,%r13,8),%xmm0
movsd  %xmm0,-0x8(%r14,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1180 <interpolateX+0x50>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double* @interpolateX(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = sub nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = mul i64 8, %11
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to double*
store double* %15, double** %7
%16 = load double*, double** %7
%17 = load i32, i32* %6
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = mul i64 8, %19
%21 = trunc i64 %20 to i32
%22 = call i32 @memset(double* %16, i32 0, i32 %21)
store i32 1, i32* %8
br label %23
23: ; preds = %55, %3
%24 = load i32, i32* %8
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %58
27: ; preds = %23
%28 = load double*, double** %4
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = load double*, double** %4
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %33, i64 %36
%38 = load double, double* %37
%39 = load i32, i32* %6
%40 = call i32 @x_dw(double %32, double %38, i32 %39)
%41 = load i32, i32* %8
%42 = mul nsw i32 %40, %41
%43 = sitofp i32 %42 to double
%44 = load double*, double** %4
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = fadd double %43, %48
%50 = load double*, double** %7
%51 = load i32, i32* %8
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %50, i64 %53
store double %49, double* %54
br label %55
55: ; preds = %27
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %23
58: ; preds = %23
%59 = load double*, double** %7
ret double* %59
}

LLVM IR (-O2):
define double* @interpolateX(double* nocapture %0, i32 %1, i32 %2) {
%4 = shl i32 %2, 3
%5 = add i32 %4, -8
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to double*
%8 = tail call i32 @memset(double* %7, i32 0, i32 %5)
%9 = icmp sgt i32 %2, 1
br i1 %9, label %10, label %31
10: ; preds = %3
%11 = sext i32 %1 to i64
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = add nsw i32 %1, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %0, i64 %14
%16 = zext i32 %2 to i64
br label %17
17: ; preds = %10, %17
%18 = phi i64 [ 1, %10 ], [ %29, %17 ]
%19 = load double, double* %12
%20 = load double, double* %15
%21 = tail call i32 @x_dw(double %19, double %20, i32 %2)
%22 = trunc i64 %18 to i32
%23 = mul nsw i32 %21, %22
%24 = sitofp i32 %23 to double
%25 = load double, double* %12
%26 = fadd double %25, %24
%27 = add nsw i64 %18, -1
%28 = getelementptr inbounds double, double* %7, i64 %27
store double %26, double* %28
%29 = add nuw nsw i64 %18, 1
%30 = icmp eq i64 %29, %16
br i1 %30, label %31, label %17
31: ; preds = %17, %3
ret double* %7
}