#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 exp(double);
void jacexpfunc(double *p, double *jac, int m, int n, void *data) {
  register int i, j;
  for (i = j = 0; i < n; ++i) {
    jac[j++] = exp(-p[1] * i);
    jac[j++] = -p[0] * i * exp(-p[1] * i);
    jac[j++] = 1.0;
  }
}


x86 assembly (clang, -O0):
<jacexpfunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1234 <jacexpfunc+0x124>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movsd  0xddf(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1138 <jacexpfunc+0x28>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jacexpfunc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
test   %ecx,%ecx
jle    11bd <jacexpfunc+0xad>
mov    %ecx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x10,%rbx
xorpd  %xmm1,%xmm1
movabs $0x3ff0000000000000,%r15
nopl   0x0(%rax)
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%r14),%xmm0
movapd 0xeac(%rip),%xmm2
xorpd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x10(%rbx)
movsd  (%r14),%xmm1
movsd  0x8(%r14),%xmm0
movapd 0xe87(%rip),%xmm2
xorpd  %xmm2,%xmm1
mulsd  0x8(%rsp),%xmm1
movapd %xmm1,0x10(%rsp)
xorpd  %xmm2,%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,-0x8(%rbx)
mov    %r15,(%rbx)
addsd  0xe5c(%rip),%xmm1
add    $0x18,%rbx
add    $0xffffffff,%ebp
jne    1140 <jacexpfunc+0x30>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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