#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*/ free_or_die(double *);
double *malloc_or_die(int);
int /*<<< orphan*/ memcpy(double *, double *, int);
void cmp_ai_prepend_pos(double x, double y, double **points,
                        int *points_count) {
  int old_count = *points_count;
  int new_count = old_count + 1;
  double *new_points = malloc_or_die(new_count * 2 * sizeof(*new_points));
  new_points[0] = x;
  new_points[1] = y;
  memcpy(new_points + 2, *points, old_count * 2 * sizeof(*new_points));
  free_or_die(*points);
  *points = new_points;
  *points_count = new_count;
}


x86 assembly (clang, -O0):
<cmp_ai_prepend_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc_or_die@plt>
mov    %rax,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x30(%rbp),%rdi
add    $0x10,%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <free_or_die@plt>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp_ai_prepend_pos>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    (%rsi),%r12d
lea    0x1(%r12),%ebp
mov    %ebp,%edi
shl    $0x4,%edi
call   1050 <malloc_or_die@plt>
mov    %rax,%rbx
movsd  (%rsp),%xmm0
movsd  %xmm0,(%rax)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rax)
lea    0x10(%rax),%rdi
mov    (%r15),%rsi
shl    $0x4,%r12d
mov    %r12d,%edx
call   1030 <memcpy@plt>
mov    (%r15),%rdi
call   1040 <free_or_die@plt>
mov    %rbx,(%r15)
mov    %ebp,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @cmp_ai_prepend_pos(double %0, double %1, double** %2, i32* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double**
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
store double %0, double* %5
store double %1, double* %6
store double** %2, double*** %7
store i32* %3, i32** %8
%12 = load i32*, i32** %8
%13 = load i32, i32* %12
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = add nsw i32 %14, 1
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = mul nsw i32 %16, 2
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 8
%20 = trunc i64 %19 to i32
%21 = call double* @malloc_or_die(i32 %20)
store double* %21, double** %11
%22 = load double, double* %5
%23 = load double*, double** %11
%24 = getelementptr inbounds double, double* %23, i64 0
store double %22, double* %24
%25 = load double, double* %6
%26 = load double*, double** %11
%27 = getelementptr inbounds double, double* %26, i64 1
store double %25, double* %27
%28 = load double*, double** %11
%29 = getelementptr inbounds double, double* %28, i64 2
%30 = load double**, double*** %7
%31 = load double*, double** %30
%32 = load i32, i32* %9
%33 = mul nsw i32 %32, 2
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 8
%36 = trunc i64 %35 to i32
%37 = call i32 @memcpy(double* %29, double* %31, i32 %36)
%38 = load double**, double*** %7
%39 = load double*, double** %38
%40 = call i32 @free_or_die(double* %39)
%41 = load double*, double** %11
%42 = load double**, double*** %7
store double* %41, double** %42
%43 = load i32, i32* %10
%44 = load i32*, i32** %8
store i32 %43, i32* %44
ret void
}

LLVM IR (-O2):
define void @cmp_ai_prepend_pos(double %0, double %1, double** nocapture %2, i32* nocapture %3) {
%5 = load i32, i32* %3
%6 = add nsw i32 %5, 1
%7 = shl i32 %6, 4
%8 = tail call double* @malloc_or_die(i32 %7)
store double %0, double* %8
%9 = getelementptr inbounds double, double* %8, i64 1
store double %1, double* %9
%10 = getelementptr inbounds double, double* %8, i64 2
%11 = load double*, double** %2
%12 = shl i32 %5, 4
%13 = tail call i32 @memcpy(double* %10, double* %11, i32 %12)
%14 = load double*, double** %2
%15 = tail call i32 @free_or_die(double* %14)
store double* %8, double** %2
store i32 %6, i32* %3
ret void
}