#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 cos(double);
double sin(double);
double tanh(double);
void softened_transit_(int N, double *t, double *mag, double P, double T0,
                       double eta, double cval, double delta, double mconst,
                       int Nlin_coeffs, double *lin_coeffs,
                       double **Design_Matrix) {
  int i, j;
  double tanhval1, tanhval2, cosval, sinval, tp, val1;
  for (i = 0; i < N; i++) {
    val1 = 3.1415926535897932384626433832795 * (t[i] - T0) / P;
    sinval = sin(val1);
    cosval = cos(val1);
    tp = P * sinval / 3.1415926535897932384626433832795 / eta;
    tanhval1 = tanh(cval * (tp + 0.5));
    tanhval2 = tanh(cval * (tp - 0.5));
    mag[i] = 0.5 * delta * (tanhval1 - tanhval2) + mconst;
    for (j = 2; j < Nlin_coeffs; j++)
      mag[i] += Design_Matrix[i][j] * lin_coeffs[j];
  }
}


x86 assembly (clang, -O0):
<softened_transit_>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
movsd  %xmm3,-0x38(%rbp)
movsd  %xmm4,-0x40(%rbp)
movsd  %xmm5,-0x48(%rbp)
mov    %ecx,-0x4c(%rbp)
mov    %r8,-0x58(%rbp)
mov    %r9,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12e5 <softened_transit_+0x1b5>
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
subsd  -0x28(%rbp),%xmm1
movsd  0xe6c(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
call   1040 <sin@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
call   1050 <cos@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movsd  0xe1f(%rip),%xmm1
divsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  0xdf9(%rip),%xmm1
addsd  -0x90(%rbp),%xmm1
ff
mulsd  %xmm1,%xmm0
call   1030 <tanh@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x90(%rbp),%xmm1
ff
movsd  0xdce(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <tanh@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  0xdb4(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
subsd  -0x78(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x2,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    12d2 <softened_transit_+0x1a2>
mov    -0x60(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    127c <softened_transit_+0x14c>
jmp    12d7 <softened_transit_+0x1a7>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1176 <softened_transit_+0x46>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<softened_transit_>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,0x30(%rsp)
mov    %ecx,0xc(%rsp)
movsd  %xmm5,0x48(%rsp)
movsd  %xmm4,0x10(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x40(%rsp)
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x18(%rsp)
test   %edi,%edi
jle    131b <softened_transit_+0x1eb>
mov    %r8,%rbx
mov    %rdx,%rbp
mov    %rsi,%r12
movsd  0x10(%rsp),%xmm0
mulsd  0xe76(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %edi,%r13d
mov    0xc(%rsp),%eax
mov    %rax,0x28(%rsp)
lea    -0x2(%rax),%r14
and    $0xfffffffffffffffe,%r14
neg    %r14
xor    %r15d,%r15d
jmp    11bd <softened_transit_+0x8d>
nopl   0x0(%rax)
add    $0x1,%r15
cmp    %r13,%r15
je     131b <softened_transit_+0x1eb>
movsd  (%r12,%r15,8),%xmm0
subsd  0x38(%rsp),%xmm0
mulsd  0xe37(%rip),%xmm0
divsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rsp)
call   1040 <sin@plt>
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm1
ucomisd 0xe1e(%rip),%xmm2
jae    1303 <softened_transit_+0x1d3>
movsd  0xe18(%rip),%xmm0
ucomisd %xmm2,%xmm0
jae    1303 <softened_transit_+0x1d3>
mulsd  0x18(%rsp),%xmm1
divsd  0xdf0(%rip),%xmm1
divsd  0x40(%rsp),%xmm1
movsd  %xmm1,(%rsp)
addsd  0xdd5(%rip),%xmm1
mulsd  0x20(%rsp),%xmm1
movapd %xmm1,%xmm0
call   1030 <tanh@plt>
movsd  %xmm0,0x50(%rsp)
movsd  (%rsp),%xmm0
addsd  0xdd3(%rip),%xmm0
mulsd  0x20(%rsp),%xmm0
call   1030 <tanh@plt>
movsd  0x50(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  0x48(%rsp),%xmm1
movsd  %xmm1,0x0(%rbp,%r15,8)
cmpl   $0x3,0xc(%rsp)
jl     11b0 <softened_transit_+0x80>
mov    0x30(%rsp),%rax
mov    (%rax,%r15,8),%rax
mov    $0x2,%ecx
je     12de <softened_transit_+0x1ae>
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rax,%rcx,8),%xmm0
mulsd  (%rbx,%rcx,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%rbp,%r15,8)
movsd  0x8(%rax,%rcx,8),%xmm1
mulsd  0x8(%rbx,%rcx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%rbp,%r15,8)
lea    (%r14,%rcx,1),%rdx
add    $0x2,%rdx
add    $0x2,%rcx
cmp    $0x2,%rdx
jne    12a0 <softened_transit_+0x170>
testb  $0x1,0x28(%rsp)
je     11b0 <softened_transit_+0x80>
movsd  (%rax,%rcx,8),%xmm0
mulsd  (%rbx,%rcx,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%rbp,%r15,8)
jmp    11b0 <softened_transit_+0x80>
movapd %xmm2,%xmm0
movsd  %xmm1,(%rsp)
call   1050 <cos@plt>
movsd  (%rsp),%xmm1
jmp    120a <softened_transit_+0xda>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @softened_transit_(i32 %0, double* %1, double* %2, double %3, double %4, double %5, double %6, double %7, double %8, i32 %9, double* %10, double** %11) {
%13 = alloca i32
%14 = alloca double*
%15 = alloca double*
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca i32
%23 = alloca double*
%24 = alloca double**
%25 = alloca i32
%26 = alloca i32
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
store i32 %0, i32* %13
store double* %1, double** %14
store double* %2, double** %15
store double %3, double* %16
store double %4, double* %17
store double %5, double* %18
store double %6, double* %19
store double %7, double* %20
store double %8, double* %21
store i32 %9, i32* %22
store double* %10, double** %23
store double** %11, double*** %24
store i32 0, i32* %25
br label %33
33: ; preds = %108, %12
%34 = load i32, i32* %25
%35 = load i32, i32* %13
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %111
37: ; preds = %33
%38 = load double*, double** %14
%39 = load i32, i32* %25
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double, double* %17
%44 = fsub double %42, %43
%45 = fmul double 0x400921FB54442D18, %44
%46 = load double, double* %16
%47 = fdiv double %45, %46
store double %47, double* %32
%48 = load double, double* %32
%49 = call double @sin(double %48)
store double %49, double* %30
%50 = load double, double* %32
%51 = call double @cos(double %50)
store double %51, double* %29
%52 = load double, double* %16
%53 = load double, double* %30
%54 = fmul double %52, %53
%55 = fdiv double %54, 0x400921FB54442D18
%56 = load double, double* %18
%57 = fdiv double %55, %56
store double %57, double* %31
%58 = load double, double* %19
%59 = load double, double* %31
%60 = fadd double %59, 5.000000e-01
%61 = fmul double %58, %60
%62 = call double @tanh(double %61)
store double %62, double* %27
%63 = load double, double* %19
%64 = load double, double* %31
%65 = fsub double %64, 5.000000e-01
%66 = fmul double %63, %65
%67 = call double @tanh(double %66)
store double %67, double* %28
%68 = load double, double* %20
%69 = fmul double 5.000000e-01, %68
%70 = load double, double* %27
%71 = load double, double* %28
%72 = fsub double %70, %71
%73 = load double, double* %21
%74 = call double @llvm.fmuladd.f64(double %69, double %72, double %73)
%75 = load double*, double** %15
%76 = load i32, i32* %25
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %75, i64 %77
store double %74, double* %78
store i32 2, i32* %26
br label %79
79: ; preds = %104, %37
%80 = load i32, i32* %26
%81 = load i32, i32* %22
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %107
83: ; preds = %79
%84 = load double**, double*** %24
%85 = load i32, i32* %25
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double*, double** %84, i64 %86
%88 = load double*, double** %87
%89 = load i32, i32* %26
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %88, i64 %90
%92 = load double, double* %91
%93 = load double*, double** %23
%94 = load i32, i32* %26
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double, double* %96
%98 = load double*, double** %15
%99 = load i32, i32* %25
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %98, i64 %100
%102 = load double, double* %101
%103 = call double @llvm.fmuladd.f64(double %92, double %97, double %102)
store double %103, double* %101
br label %104
104: ; preds = %83
%105 = load i32, i32* %26
%106 = add nsw i32 %105, 1
store i32 %106, i32* %26
br label %79
107: ; preds = %79
br label %108
108: ; preds = %107
%109 = load i32, i32* %25
%110 = add nsw i32 %109, 1
store i32 %110, i32* %25
br label %33
111: ; preds = %33
ret void
}

LLVM IR (-O2):
define void @softened_transit_(i32 %0, double* nocapture %1, double* nocapture %2, double %3, double %4, double %5, double %6, double %7, double %8, i32 %9, double* nocapture %10, double** nocapture %11) {
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %83
14: ; preds = %12
%15 = fmul double %7, 5.000000e-01
%16 = icmp sgt i32 %9, 2
%17 = zext i32 %0 to i64
%18 = zext i32 %9 to i64
%19 = add nsw i64 %18, -2
%20 = and i64 %18, 1
%21 = icmp eq i32 %9, 3
%22 = and i64 %19, -2
%23 = icmp eq i64 %20, 0
br label %24
24: ; preds = %14, %80
%25 = phi i64 [ 0, %14 ], [ %81, %80 ]
%26 = getelementptr inbounds double, double* %1, i64 %25
%27 = load double, double* %26
%28 = fsub double %27, %4
%29 = fmul double %28, 0x400921FB54442D18
%30 = fdiv double %29, %3
%31 = tail call double @sin(double %30)
%32 = fcmp oeq double %30, 0xFFF0000000000000
%33 = fcmp oeq double %30, 0x7FF0000000000000
%34 = or i1 %33, %32
br i1 %34, label %35, label %37
35: ; preds = %24
%36 = tail call double @cos(double %30)
br label %37
37: ; preds = %24, %35
%38 = fmul double %31, %3
%39 = fdiv double %38, 0x400921FB54442D18
%40 = fdiv double %39, %5
%41 = fadd double %40, 5.000000e-01
%42 = fmul double %41, %6
%43 = tail call double @tanh(double %42)
%44 = fadd double %40, -5.000000e-01
%45 = fmul double %44, %6
%46 = tail call double @tanh(double %45)
%47 = fsub double %43, %46
%48 = tail call double @llvm.fmuladd.f64(double %15, double %47, double %8)
%49 = getelementptr inbounds double, double* %2, i64 %25
store double %48, double* %49
br i1 %16, label %50, label %80
50: ; preds = %37
%51 = getelementptr inbounds double*, double** %11, i64 %25
%52 = load double*, double** %51
br i1 %21, label %71, label %53
53: ; preds = %50, %53
%54 = phi double [ %67, %53 ], [ %48, %50 ]
%55 = phi i64 [ %68, %53 ], [ 2, %50 ]
%56 = phi i64 [ %69, %53 ], [ 0, %50 ]
%57 = getelementptr inbounds double, double* %52, i64 %55
%58 = load double, double* %57
%59 = getelementptr inbounds double, double* %10, i64 %55
%60 = load double, double* %59
%61 = tail call double @llvm.fmuladd.f64(double %58, double %60, double %54)
store double %61, double* %49
%62 = or i64 %55, 1
%63 = getelementptr inbounds double, double* %52, i64 %62
%64 = load double, double* %63
%65 = getelementptr inbounds double, double* %10, i64 %62
%66 = load double, double* %65
%67 = tail call double @llvm.fmuladd.f64(double %64, double %66, double %61)
store double %67, double* %49
%68 = add nuw nsw i64 %55, 2
%69 = add i64 %56, 2
%70 = icmp eq i64 %69, %22
br i1 %70, label %71, label %53
71: ; preds = %53, %50
%72 = phi double [ %48, %50 ], [ %67, %53 ]
%73 = phi i64 [ 2, %50 ], [ %68, %53 ]
br i1 %23, label %80, label %74
74: ; preds = %71
%75 = getelementptr inbounds double, double* %52, i64 %73
%76 = load double, double* %75
%77 = getelementptr inbounds double, double* %10, i64 %73
%78 = load double, double* %77
%79 = tail call double @llvm.fmuladd.f64(double %76, double %78, double %72)
store double %79, double* %49
br label %80
80: ; preds = %74, %71, %37
%81 = add nuw nsw i64 %25, 1
%82 = icmp eq i64 %81, %17
br i1 %82, label %83, label %24
83: ; preds = %80, %12
ret void
}