#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*/ g2_c_raspln(int, double *, double, double *const);
int /*<<< orphan*/ g2_filled_polygon(int, int const, double *const);
int /*<<< orphan*/ g2_free(double *const);
scalar_t__ g2_malloc(int const);
void g2_filled_raspln(int dev, int n, double *points, double tn) {
  const int m = (n - 1) * 40 + 2;
  double *const sxy = (double *)g2_malloc(m * 2 * sizeof(double));
  g2_c_raspln(n, points, tn, sxy);
  sxy[m + m - 2] = points[n + n - 2];
  sxy[m + m - 1] = points[1];
  g2_filled_polygon(dev, m, sxy);
  g2_free(sxy);
}


x86 assembly (clang, -O0):
<g2_filled_raspln>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
imul   $0x28,%eax,%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <g2_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rdx
call   1060 <g2_c_raspln@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1040 <g2_filled_polygon@plt>
mov    -0x28(%rbp),%rdi
call   1050 <g2_free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g2_filled_raspln>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %rdx,%r12
mov    %esi,%ebp
mov    %edi,%r14d
lea    0x0(%rbp,%rbp,4),%eax
lea    -0x26(,%rax,8),%r15d
ff
mov    %eax,%r13d
shl    $0x3,%r13d
mov    %r15d,%edi
shl    $0x4,%edi
call   1030 <g2_malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %r12,%rsi
movsd  (%rsp),%xmm0
mov    %rax,%rdx
call   1060 <g2_c_raspln@plt>
add    %ebp,%ebp
movslq %ebp,%rax
movsd  -0x10(%r12,%rax,8),%xmm0
lea    -0x4c(%r13,%r13,1),%eax
cltq
movsd  %xmm0,-0x10(%rbx,%rax,8)
movsd  0x8(%r12),%xmm0
movsd  %xmm0,-0x8(%rbx,%rax,8)
mov    %r14d,%edi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1040 <g2_filled_polygon@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <g2_free@plt>

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

LLVM IR (-O2):
define void @g2_filled_raspln(i32 %0, i32 %1, double* %2, double %3) {
%5 = mul i32 %1, 40
%6 = add i32 %5, -38
%7 = shl i32 %6, 4
%8 = tail call i64 @g2_malloc(i32 %7)
%9 = inttoptr i64 %8 to double*
%10 = tail call i32 @g2_c_raspln(i32 %1, double* %2, double %3, double* %9)
%11 = shl nsw i32 %1, 1
%12 = add nsw i32 %11, -2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %2, i64 %13
%15 = load double, double* %14
%16 = shl nsw i32 %6, 1
%17 = add nsw i32 %16, -2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %9, i64 %18
store double %15, double* %19
%20 = getelementptr inbounds double, double* %2, i64 1
%21 = load double, double* %20
%22 = add nsw i32 %16, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %9, i64 %23
store double %21, double* %24
%25 = tail call i32 @g2_filled_polygon(i32 %0, i32 %6, double* %9)
%26 = tail call i32 @g2_free(double* %9)
ret void
}