#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 */
double poly(int, int, double *, double *, double *);
double poly_ctypes(int N, double args[N]) {
  int n = (int)args[N - 1];
  int m = (int)args[N - 2];
  return poly(n, m, &args[n], &args[n + m], &args[0]);
}


x86 assembly (clang, -O0):
<poly_ctypes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cvttsd2si (%rax,%rcx,8),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
cvttsd2si (%rax,%rcx,8),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rdx
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x10(%rbp),%r8
call   1030 <poly@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poly_ctypes>:
mov    %rsi,%r8
movslq %edi,%rax
movupd -0x10(%rsi,%rax,8),%xmm0
cvttpd2dq %xmm0,%xmm0
pshufd $0x55,%xmm0,%xmm1
movd   %xmm1,%eax
movslq %eax,%rdi
lea    (%rsi,%rdi,8),%rdx
movd   %xmm0,%esi
lea    (%rsi,%rdi,1),%eax
cltq
lea    (%r8,%rax,8),%rcx
jmp    1030 <poly@plt>

LLVM IR (-O0):
define double @poly_ctypes(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %4
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
%9 = load double*, double** %4
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds double, double* %9, i64 %12
%14 = load double, double* %13
%15 = fptosi double %14 to i32
store i32 %15, i32* %5
%16 = load double*, double** %4
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %16, i64 %19
%21 = load double, double* %20
%22 = fptosi double %21 to i32
store i32 %22, i32* %6
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = load double*, double** %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double*, double** %4
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = add nsw i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %29, i64 %33
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = call double @poly(i32 %23, i32 %24, double* %28, double* %34, double* %36)
ret double %37
}

LLVM IR (-O2):
define double @poly_ctypes(i32 %0, double* %1) {
%3 = add nsw i32 %0, -2
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds double, double* %1, i64 %4
%6 = bitcast double* %5 to <2 x double>*
%7 = load <2 x double>, <2 x double>* %6
%8 = fptosi <2 x double> %7 to <2 x i32>
%9 = extractelement <2 x i32> %8, i64 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = extractelement <2 x i32> %8, i64 0
%13 = add nsw i32 %12, %9
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %1, i64 %14
%16 = tail call double @poly(i32 %9, i32 %12, double* %11, double* %15, double* %1)
ret double %16
}