#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 composite_potential(double, double);
double poly_ctypes(int, double *);
double composite_poly(int N, double args[N]) {
  return composite_potential(
      -args[N - 3] * (poly_ctypes(N - 3, &args[0]) + args[N - 2]), args[N - 1]);
}


x86 assembly (clang, -O0):
<composite_poly>:
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    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x3,%edi
mov    -0x10(%rbp),%rsi
call   1040 <poly_ctypes@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1030 <composite_potential@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<composite_poly>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movslq %edi,%r14
add    $0xfffffffd,%edi
movsd  -0x18(%rsi,%r14,8),%xmm0
xorpd  0xec1(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1040 <poly_ctypes@plt>
addsd  -0x10(%rbx,%r14,8),%xmm0
mulsd  (%rsp),%xmm0
movsd  -0x8(%rbx,%r14,8),%xmm1
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1030 <composite_potential@plt>

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

LLVM IR (-O2):
define double @composite_poly(i32 %0, double* %1) {
%3 = add nsw i32 %0, -3
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds double, double* %1, i64 %4
%6 = load double, double* %5
%7 = fneg double %6
%8 = tail call double @poly_ctypes(i32 %3, double* %1)
%9 = add nsw i32 %0, -2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = load double, double* %11
%13 = fadd double %8, %12
%14 = fmul double %13, %7
%15 = add nsw i32 %0, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %1, i64 %16
%18 = load double, double* %17
%19 = tail call double @composite_potential(double %14, double %18)
ret double %19
}