#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 exp(int);
void fk10(double *x, int M, int N, double *f, void *params) {
  int i;
  for (i = 1; i <= M; ++i) {
    f[i - 1] = 2 + 2 * i - exp(i * x[0]) - exp(i * x[1]);
  }
}


x86 assembly (clang, -O0):
<fk10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11ab <fk10+0x9b>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x28(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1131 <fk10+0x21>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fk10>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    1198 <fk10+0x88>
mov    %rcx,%r14
mov    %esi,%r15d
mov    %rdi,%r12
add    $0x1,%r15d
mov    $0x1,%ebx
mov    $0x4,%ebp
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%r12),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
mov    %eax,%r13d
movsd  (%rsp),%xmm0
mulsd  0x8(%r12),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
add    %r13d,%eax
mov    %ebp,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,-0x8(%r14,%rbx,8)
add    $0x1,%rbx
add    $0x2,%ebp
cmp    %rbx,%r15
jne    1140 <fk10+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fk10(double* %0, i32 %1, i32 %2, double* %3, i8* %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca i8*
%11 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double* %3, double** %9
store i8* %4, i8** %10
store i32 1, i32* %11
br label %12
12: ; preds = %44, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %7
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %47
16: ; preds = %12
%17 = load i32, i32* %11
%18 = mul nsw i32 2, %17
%19 = add nsw i32 2, %18
%20 = load i32, i32* %11
%21 = sitofp i32 %20 to double
%22 = load double*, double** %6
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load double, double* %23
%25 = fmul double %21, %24
%26 = fptosi double %25 to i32
%27 = call i32 @exp(i32 %26)
%28 = sub nsw i32 %19, %27
%29 = load i32, i32* %11
%30 = sitofp i32 %29 to double
%31 = load double*, double** %6
%32 = getelementptr inbounds double, double* %31, i64 1
%33 = load double, double* %32
%34 = fmul double %30, %33
%35 = fptosi double %34 to i32
%36 = call i32 @exp(i32 %35)
%37 = sub nsw i32 %28, %36
%38 = sitofp i32 %37 to double
%39 = load double*, double** %9
%40 = load i32, i32* %11
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %39, i64 %42
store double %38, double* %43
br label %44
44: ; preds = %16
%45 = load i32, i32* %11
%46 = add nsw i32 %45, 1
store i32 %46, i32* %11
br label %12
47: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @fk10(double* nocapture %0, i32 %1, i32 %2, double* nocapture writeonly %3, i8* nocapture readnone %4) {
%6 = icmp slt i32 %1, 1
br i1 %6, label %33, label %7
7: ; preds = %5
%8 = getelementptr inbounds double, double* %0, i64 1
%9 = add nuw i32 %1, 1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 1, %7 ], [ %31, %11 ]
%13 = trunc i64 %12 to i32
%14 = sitofp i32 %13 to double
%15 = load double, double* %0
%16 = fmul double %15, %14
%17 = fptosi double %16 to i32
%18 = tail call i32 @exp(i32 %17)
%19 = load double, double* %8
%20 = fmul double %19, %14
%21 = fptosi double %20 to i32
%22 = tail call i32 @exp(i32 %21)
%23 = add i32 %18, %22
%24 = trunc i64 %12 to i32
%25 = shl i32 %24, 1
%26 = add i32 %25, 2
%27 = sub i32 %26, %23
%28 = sitofp i32 %27 to double
%29 = add nsw i64 %12, -1
%30 = getelementptr inbounds double, double* %3, i64 %29
store double %28, double* %30
%31 = add nuw nsw i64 %12, 1
%32 = icmp eq i64 %31, %10
br i1 %32, label %33, label %11
33: ; preds = %11, %5
ret void
}