#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);
double pow(double, double);
int NonlinearDAE(int *iwork, double *rwork, int nPoints, double T, double *x,
                 double *u) {
  int i;
  double q, t, a = rwork[0], p = rwork[1];
  for (i = 0; i < nPoints; i++) {
    t = x[i * 3 + 0];
    if (p == 1.0) {
      u[i] = exp(-a * t);
    } else {
      q = 1.0 / (1.0 - p);
      u[i] = pow(((((1.0 - (1.0 - p) * a * t)) > (0.0))
                      ? ((1.0 - (1.0 - p) * a * t))
                      : (0.0)),
                 q);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<NonlinearDAE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12c8 <NonlinearDAE+0x1a8>
mov    -0x28(%rbp),%rax
imul   $0x3,-0x34(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11db <NonlinearDAE+0xbb>
jp     11db <NonlinearDAE+0xbb>
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1030 <exp@plt>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12b5 <NonlinearDAE+0x195>
movsd  0xe1d(%rip),%xmm1
subsd  -0x58(%rbp),%xmm1
movsd  0xe10(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdff(%rip),%xmm0
subsd  -0x58(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdcd(%rip),%xmm1
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    128c <NonlinearDAE+0x16c>
movsd  0xdb4(%rip),%xmm0
subsd  -0x58(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd82(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1299 <NonlinearDAE+0x179>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1299 <NonlinearDAE+0x179>
movsd  -0x60(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1040 <pow@plt>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12ba <NonlinearDAE+0x19a>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1162 <NonlinearDAE+0x42>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NonlinearDAE>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %edx,%edx
jle    11e8 <NonlinearDAE+0xc8>
mov    %r8,%r14
mov    %rcx,%r12
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm0
movsd  0xeb6(%rip),%xmm2
movapd %xmm2,%xmm3
movsd  %xmm0,0x8(%rsp)
subsd  %xmm0,%xmm3
movapd %xmm2,%xmm0
divsd  %xmm3,%xmm0
movsd  %xmm0,(%rsp)
movapd 0xea3(%rip),%xmm0
xorpd  %xmm0,%xmm3
mulsd  %xmm1,%xmm3
movapd %xmm3,0x10(%rsp)
xorpd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
mov    %edx,%r15d
xor    %ebx,%ebx
jmp    11c7 <NonlinearDAE+0xa7>
nopl   0x0(%rax)
mulsd  0x10(%rsp),%xmm0
addsd  %xmm2,%xmm0
maxsd  0xe66(%rip),%xmm0
movsd  (%rsp),%xmm1
call   1040 <pow@plt>
movsd  0xe4c(%rip),%xmm2
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
add    $0x18,%r12
cmp    %rbx,%r15
je     11e8 <NonlinearDAE+0xc8>
movsd  0x8(%rsp),%xmm0
ucomisd %xmm2,%xmm0
movsd  (%r12),%xmm0
jne    1190 <NonlinearDAE+0x70>
jp     1190 <NonlinearDAE+0x70>
mulsd  0x20(%rsp),%xmm0
call   1030 <exp@plt>
jmp    11ac <NonlinearDAE+0x8c>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @NonlinearDAE(i32* %0, double* %1, i32 %2, double %3, double* %4, double* %5) {
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store i32* %0, i32** %7
store double* %1, double** %8
store i32 %2, i32* %9
store double %3, double* %10
store double* %4, double** %11
store double* %5, double** %12
%18 = load double*, double** %8
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
store double %20, double* %16
%21 = load double*, double** %8
%22 = getelementptr inbounds double, double* %21, i64 1
%23 = load double, double* %22
store double %23, double* %17
store i32 0, i32* %13
br label %24
24: ; preds = %78, %6
%25 = load i32, i32* %13
%26 = load i32, i32* %9
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %81
28: ; preds = %24
%29 = load double*, double** %11
%30 = load i32, i32* %13
%31 = mul nsw i32 %30, 3
%32 = add nsw i32 %31, 0
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %29, i64 %33
%35 = load double, double* %34
store double %35, double* %15
%36 = load double, double* %17
%37 = fcmp oeq double %36, 1.000000e+00
br i1 %37, label %38, label %48
38: ; preds = %28
%39 = load double, double* %16
%40 = fneg double %39
%41 = load double, double* %15
%42 = fmul double %40, %41
%43 = call double @exp(double %42)
%44 = load double*, double** %12
%45 = load i32, i32* %13
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double %43, double* %47
br label %77
48: ; preds = %28
%49 = load double, double* %17
%50 = fsub double 1.000000e+00, %49
%51 = fdiv double 1.000000e+00, %50
store double %51, double* %14
%52 = load double, double* %17
%53 = fsub double 1.000000e+00, %52
%54 = load double, double* %16
%55 = fmul double %53, %54
%56 = load double, double* %15
%57 = fneg double %55
%58 = call double @llvm.fmuladd.f64(double %57, double %56, double 1.000000e+00)
%59 = fcmp ogt double %58, 0.000000e+00
br i1 %59, label %60, label %68
60: ; preds = %48
%61 = load double, double* %17
%62 = fsub double 1.000000e+00, %61
%63 = load double, double* %16
%64 = fmul double %62, %63
%65 = load double, double* %15
%66 = fneg double %64
%67 = call double @llvm.fmuladd.f64(double %66, double %65, double 1.000000e+00)
br label %69
68: ; preds = %48
br label %69
69: ; preds = %68, %60
%70 = phi double [ %67, %60 ], [ 0.000000e+00, %68 ]
%71 = load double, double* %14
%72 = call double @pow(double %70, double %71)
%73 = load double*, double** %12
%74 = load i32, i32* %13
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
store double %72, double* %76
br label %77
77: ; preds = %69, %38
br label %78
78: ; preds = %77
%79 = load i32, i32* %13
%80 = add nsw i32 %79, 1
store i32 %80, i32* %13
br label %24
81: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
define i32 @NonlinearDAE(i32* nocapture readnone %0, double* nocapture %1, i32 %2, double %3, double* nocapture %4, double* nocapture writeonly %5) {
%7 = load double, double* %1
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %37
11: ; preds = %6
%12 = fcmp oeq double %9, 1.000000e+00
%13 = fsub double 1.000000e+00, %9
%14 = fdiv double 1.000000e+00, %13
%15 = fneg double %13
%16 = fmul double %7, %15
%17 = fneg double %7
%18 = zext i32 %2 to i64
br label %19
19: ; preds = %11, %32
%20 = phi i64 [ 0, %11 ], [ %35, %32 ]
%21 = mul nuw nsw i64 %20, 3
%22 = getelementptr inbounds double, double* %4, i64 %21
%23 = load double, double* %22
br i1 %12, label %24, label %27
24: ; preds = %19
%25 = fmul double %23, %17
%26 = tail call double @exp(double %25)
br label %32
27: ; preds = %19
%28 = tail call double @llvm.fmuladd.f64(double %16, double %23, double 1.000000e+00)
%29 = fcmp ogt double %28, 0.000000e+00
%30 = select i1 %29, double %28, double 0.000000e+00
%31 = tail call double @pow(double %30, double %14)
br label %32
32: ; preds = %24, %27
%33 = phi double [ %26, %24 ], [ %31, %27 ]
%34 = getelementptr inbounds double, double* %5, i64 %20
store double %33, double* %34
%35 = add nuw nsw i64 %20, 1
%36 = icmp eq i64 %35, %18
br i1 %36, label %37, label %19
37: ; preds = %32, %6
ret i32 0
}