#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 */
float expf(float);
void GCI_multiexp_lambda(float x, float param[], float *y, float dy_dparam[],
                         int nparam) {
  int i;
  float ex;
  *y = 0;
  for (i = 1; i < nparam - 1; i += 2) {
    dy_dparam[i] = ex = expf(-param[i + 1] * x);
    ex *= param[i];
    *y += ex;
    dy_dparam[i + 1] = -ex * x;
  }
}


x86 assembly (clang, -O0):
<GCI_multiexp_lambda>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e9 <GCI_multiexp_lambda+0xd9>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x4(%rbp),%xmm0
call   1030 <expf@plt>
movss  %xmm0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mulss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
addss  (%rax),%xmm0
movss  %xmm0,(%rax)
movss  -0x2c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x4(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
jmp    113e <GCI_multiexp_lambda+0x2e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GCI_multiexp_lambda>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,(%rsi)
cmp    $0x3,%ecx
jl     11a7 <GCI_multiexp_lambda+0x97>
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
movaps %xmm0,%xmm1
add    $0xffffffff,%r14d
mov    $0x1,%ebx
movss  %xmm0,0xc(%rsp)
cs nopw 0x0(%rax,%rax,1)
movss  0x4(%r12,%rbx,4),%xmm0
movaps 0xea2(%rip),%xmm2
xorps  %xmm2,%xmm0
mulss  %xmm1,%xmm0
call   1030 <expf@plt>
movss  %xmm0,(%r15,%rbx,4)
mulss  (%r12,%rbx,4),%xmm0
movss  0x0(%r13),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x0(%r13)
movss  0xc(%rsp),%xmm1
xorps  0xe6d(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x4(%r15,%rbx,4)
add    $0x2,%rbx
cmp    %r14,%rbx
jb     1150 <GCI_multiexp_lambda+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @GCI_multiexp_lambda(float %0, float* %1, float* %2, float* %3, i32 %4) {
%6 = alloca float
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
store float %0, float* %6
store float* %1, float** %7
store float* %2, float** %8
store float* %3, float** %9
store i32 %4, i32* %10
%13 = load float*, float** %8
store float 0.000000e+00, float* %13
store i32 1, i32* %11
br label %14
14: ; preds = %54, %5
%15 = load i32, i32* %11
%16 = load i32, i32* %10
%17 = sub nsw i32 %16, 1
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %57
19: ; preds = %14
%20 = load float*, float** %7
%21 = load i32, i32* %11
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %20, i64 %23
%25 = load float, float* %24
%26 = fneg float %25
%27 = load float, float* %6
%28 = fmul float %26, %27
%29 = call float @expf(float %28)
store float %29, float* %12
%30 = load float*, float** %9
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds float, float* %30, i64 %32
store float %29, float* %33
%34 = load float*, float** %7
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds float, float* %34, i64 %36
%38 = load float, float* %37
%39 = load float, float* %12
%40 = fmul float %39, %38
store float %40, float* %12
%41 = load float, float* %12
%42 = load float*, float** %8
%43 = load float, float* %42
%44 = fadd float %43, %41
store float %44, float* %42
%45 = load float, float* %12
%46 = fneg float %45
%47 = load float, float* %6
%48 = fmul float %46, %47
%49 = load float*, float** %9
%50 = load i32, i32* %11
%51 = add nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float, float* %49, i64 %52
store float %48, float* %53
br label %54
54: ; preds = %19
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 2
store i32 %56, i32* %11
br label %14
57: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @GCI_multiexp_lambda(float %0, float* nocapture %1, float* nocapture %2, float* nocapture writeonly %3, i32 %4) {
store float 0.000000e+00, float* %2
%6 = icmp sgt i32 %4, 2
br i1 %6, label %7, label %29
7: ; preds = %5
%8 = add nsw i32 %4, -1
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 1, %7 ], [ %27, %10 ]
%12 = add nuw nsw i64 %11, 1
%13 = getelementptr inbounds float, float* %1, i64 %12
%14 = load float, float* %13
%15 = fneg float %14
%16 = fmul float %15, %0
%17 = tail call float @expf(float %16)
%18 = getelementptr inbounds float, float* %3, i64 %11
store float %17, float* %18
%19 = getelementptr inbounds float, float* %1, i64 %11
%20 = load float, float* %19
%21 = fmul float %17, %20
%22 = load float, float* %2
%23 = fadd float %22, %21
store float %23, float* %2
%24 = fneg float %21
%25 = fmul float %24, %0
%26 = getelementptr inbounds float, float* %3, i64 %12
store float %25, float* %26
%27 = add nuw nsw i64 %11, 2
%28 = icmp ult i64 %27, %9
br i1 %28, label %10, label %29
29: ; preds = %10, %5
ret void
}