#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 mglsadff(double, double *, int const, double const, double *);
double mglsadf(double x, double *b, const int m, const double a, const int n,
               double *d) {
  int i;
  for (i = 0; i < n; i++)
    x = mglsadff(x, b, m, a, &d[i * (m + 1)]);
  return (x);
}


x86 assembly (clang, -O0):
<mglsadf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %rcx,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1185 <mglsadf+0x75>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
movsd  -0x20(%rbp),%xmm1
mov    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
call   1030 <mglsadff@plt>
movsd  %xmm0,-0x8(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1137 <mglsadf+0x27>
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mglsadf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edx,%edx
jle    115d <mglsadf+0x4d>
mov    %rcx,%rbx
mov    %esi,%r15d
mov    %rdi,%r14
movslq %esi,%rax
mov    %edx,%ebp
lea    0x8(,%rax,8),%r12
movsd  %xmm1,0x8(%rsp)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15d,%esi
movsd  0x8(%rsp),%xmm1
mov    %rbx,%rdx
call   1030 <mglsadff@plt>
add    %r12,%rbx
add    $0xffffffffffffffff,%rbp
jne    1140 <mglsadf+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @mglsadf(double %0, double* %1, i32 %2, double %3, i32 %4, double* %5) {
%7 = alloca double
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca double*
%13 = alloca i32
store double %0, double* %7
store double* %1, double** %8
store i32 %2, i32* %9
store double %3, double* %10
store i32 %4, i32* %11
store double* %5, double** %12
store i32 0, i32* %13
br label %14
14: ; preds = %31, %6
%15 = load i32, i32* %13
%16 = load i32, i32* %11
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %34
18: ; preds = %14
%19 = load double, double* %7
%20 = load double*, double** %8
%21 = load i32, i32* %9
%22 = load double, double* %10
%23 = load double*, double** %12
%24 = load i32, i32* %13
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
%27 = mul nsw i32 %24, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %23, i64 %28
%30 = call double @mglsadff(double %19, double* %20, i32 %21, double %22, double* %29)
store double %30, double* %7
br label %31
31: ; preds = %18
%32 = load i32, i32* %13
%33 = add nsw i32 %32, 1
store i32 %33, i32* %13
br label %14
34: ; preds = %14
%35 = load double, double* %7
ret double %35
}

LLVM IR (-O2):
define double @mglsadf(double %0, double* %1, i32 %2, double %3, i32 %4, double* %5) {
%7 = icmp sgt i32 %4, 0
br i1 %7, label %8, label %20
8: ; preds = %6
%9 = add nsw i32 %2, 1
%10 = sext i32 %9 to i64
%11 = zext i32 %4 to i64
br label %12
12: ; preds = %8, %12
%13 = phi i64 [ 0, %8 ], [ %18, %12 ]
%14 = phi double [ %0, %8 ], [ %17, %12 ]
%15 = mul nsw i64 %13, %10
%16 = getelementptr inbounds double, double* %5, i64 %15
%17 = tail call double @mglsadff(double %14, double* %1, i32 %2, double %3, double* %16)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %11
br i1 %19, label %20, label %12
20: ; preds = %12, %6
%21 = phi double [ %0, %6 ], [ %17, %12 ]
ret double %21
}