#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(double);
void gradient(double *g, double *par, int x, void *fdata) {
  g[0] = 1.0 - exp(-par[2] * x);
  g[1] = exp(-par[2] * x);
  g[2] = -x * (par[1] - par[0]) * exp(-par[2] * x);
}


x86 assembly (clang, -O0):
<gradient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe9f(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
cvtsi2sd %eax,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
xor    %eax,%eax
sub    -0x14(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gradient>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  0x10(%rsi),%xmm0
xorpd  0xed3(%rip),%xmm0
cvtsi2sd %edx,%xmm1
movsd  %xmm1,(%rsp)
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xec2(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x10(%rbx),%xmm0
xorpd  0xe9c(%rip),%xmm0
mulsd  (%rsp),%xmm0
call   1030 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
neg    %ebp
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  %xmm0,0x8(%r14)
movsd  0x8(%rbx),%xmm0
subsd  (%rbx),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
xorpd  0xe5c(%rip),%xmm0
mulsd  (%rsp),%xmm0
call   1030 <exp@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @gradient(double* %0, double* %1, i32 %2, i8* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i8*
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%9 = load double*, double** %6
%10 = getelementptr inbounds double, double* %9, i64 2
%11 = load double, double* %10
%12 = fneg double %11
%13 = load i32, i32* %7
%14 = sitofp i32 %13 to double
%15 = fmul double %12, %14
%16 = call i32 @exp(double %15)
%17 = sitofp i32 %16 to double
%18 = fsub double 1.000000e+00, %17
%19 = load double*, double** %5
%20 = getelementptr inbounds double, double* %19, i64 0
store double %18, double* %20
%21 = load double*, double** %6
%22 = getelementptr inbounds double, double* %21, i64 2
%23 = load double, double* %22
%24 = fneg double %23
%25 = load i32, i32* %7
%26 = sitofp i32 %25 to double
%27 = fmul double %24, %26
%28 = call i32 @exp(double %27)
%29 = sitofp i32 %28 to double
%30 = load double*, double** %5
%31 = getelementptr inbounds double, double* %30, i64 1
store double %29, double* %31
%32 = load i32, i32* %7
%33 = sub nsw i32 0, %32
%34 = sitofp i32 %33 to double
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i64 1
%37 = load double, double* %36
%38 = load double*, double** %6
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = fsub double %37, %40
%42 = fmul double %34, %41
%43 = load double*, double** %6
%44 = getelementptr inbounds double, double* %43, i64 2
%45 = load double, double* %44
%46 = fneg double %45
%47 = load i32, i32* %7
%48 = sitofp i32 %47 to double
%49 = fmul double %46, %48
%50 = call i32 @exp(double %49)
%51 = sitofp i32 %50 to double
%52 = fmul double %42, %51
%53 = load double*, double** %5
%54 = getelementptr inbounds double, double* %53, i64 2
store double %52, double* %54
ret void
}

LLVM IR (-O2):
define void @gradient(double* nocapture writeonly %0, double* nocapture %1, i32 %2, i8* nocapture readnone %3) {
%5 = getelementptr inbounds double, double* %1, i64 2
%6 = load double, double* %5
%7 = fneg double %6
%8 = sitofp i32 %2 to double
%9 = fmul double %8, %7
%10 = tail call i32 @exp(double %9)
%11 = sitofp i32 %10 to double
%12 = fsub double 1.000000e+00, %11
store double %12, double* %0
%13 = load double, double* %5
%14 = fneg double %13
%15 = fmul double %8, %14
%16 = tail call i32 @exp(double %15)
%17 = sitofp i32 %16 to double
%18 = getelementptr inbounds double, double* %0, i64 1
store double %17, double* %18
%19 = sub nsw i32 0, %2
%20 = sitofp i32 %19 to double
%21 = getelementptr inbounds double, double* %1, i64 1
%22 = load double, double* %21
%23 = load double, double* %1
%24 = fsub double %22, %23
%25 = fmul double %24, %20
%26 = load double, double* %5
%27 = fneg double %26
%28 = fmul double %8, %27
%29 = tail call i32 @exp(double %28)
%30 = sitofp i32 %29 to double
%31 = fmul double %25, %30
%32 = getelementptr inbounds double, double* %0, i64 2
store double %31, double* %32
ret void
}