#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 /*<<< orphan*/ DymosimError(char *);
int fabs(double);
int /*<<< orphan*/ sprintf(char *, char *, char const *, double, double);
double CheckContinuousIfCode(int c, const char *ys, double *v, double newValue,
                             double Time, double InitTime) {
  if (c && fabs(*v - newValue) > 1e-3 * (1 + fabs(newValue) + fabs(*v)) &&
      Time != InitTime) {
    char buf[1000];
    sprintf(buf,
            "\nModel error - differentiated if-then-else was not continuous:\n "
            "%s\n Value jumped from %g to %g.\n",
            ys, *v, newValue);
    DymosimError(buf);
  }
  return *v = newValue;
}


x86 assembly (clang, -O0):
<CheckContinuousIfCode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%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)
cmpl   $0x0,-0x4(%rbp)
je     1214 <CheckContinuousIfCode+0xe4>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x430(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <fabs@plt>
movsd  -0x430(%rbp),%xmm0
ff
mov    %eax,%ecx
mov    -0x424(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe45(%rip),%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1214 <CheckContinuousIfCode+0xe4>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jne    11e4 <CheckContinuousIfCode+0xb4>
jp     11e4 <CheckContinuousIfCode+0xb4>
jmp    1214 <CheckContinuousIfCode+0xe4>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe05(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <DymosimError@plt>
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckContinuousIfCode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
movapd %xmm0,%xmm3
mov    %rdx,%rbx
test   %edi,%edi
je     11ec <CheckContinuousIfCode+0xbc>
mov    %rsi,%r14
movsd  (%rbx),%xmm0
subsd  %xmm3,%xmm0
movsd  %xmm3,0x8(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
call   1030 <fabs@plt>
mov    %eax,%r15d
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%ebp
movsd  (%rbx),%xmm0
call   1030 <fabs@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm0
ucomisd 0x18(%rsp),%xmm0
jne    119d <CheckContinuousIfCode+0x6d>
jnp    11ec <CheckContinuousIfCode+0xbc>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
add    %ebp,%eax
add    $0x1,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe47(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ec <CheckContinuousIfCode+0xbc>
movsd  (%rbx),%xmm0
lea    0xe3e(%rip),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rdx
movapd %xmm3,%xmm1
call   1050 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <DymosimError@plt>
movsd  0x8(%rsp),%xmm3
movsd  %xmm3,(%rbx)
movapd %xmm3,%xmm0
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [97 x i8] c"\0AModel error - differentiated if-then-else was not continuous:\0A %s\0A Value jumped from %g to %g.\0A\00"
define double @CheckContinuousIfCode(i32 %0, i8* %1, double* %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca double*
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca [1000 x i8]
store i32 %0, i32* %7
store i8* %1, i8** %8
store double* %2, double** %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %46
16: ; preds = %6
%17 = load double*, double** %9
%18 = load double, double* %17
%19 = load double, double* %10
%20 = fsub double %18, %19
%21 = call i32 @fabs(double %20)
%22 = sitofp i32 %21 to double
%23 = load double, double* %10
%24 = call i32 @fabs(double %23)
%25 = add nsw i32 1, %24
%26 = load double*, double** %9
%27 = load double, double* %26
%28 = call i32 @fabs(double %27)
%29 = add nsw i32 %25, %28
%30 = sitofp i32 %29 to double
%31 = fmul double 1.000000e-03, %30
%32 = fcmp ogt double %22, %31
br i1 %32, label %33, label %46
33: ; preds = %16
%34 = load double, double* %11
%35 = load double, double* %12
%36 = fcmp une double %34, %35
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%39 = load i8*, i8** %8
%40 = load double*, double** %9
%41 = load double, double* %40
%42 = load double, double* %10
%43 = call i32 @sprintf(i8* %38, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0), i8* %39, double %41, double %42)
%44 = getelementptr inbounds [1000 x i8], [1000 x i8]* %13, i64 0, i64 0
%45 = call i32 @DymosimError(i8* %44)
br label %46
46: ; preds = %37, %33, %16, %6
%47 = load double, double* %10
%48 = load double*, double** %9
store double %47, double* %48
ret double %47
}

LLVM IR (-O2):
@.str = [97 x i8] c"\0AModel error - differentiated if-then-else was not continuous:\0A %s\0A Value jumped from %g to %g.\0A\00"
define double @CheckContinuousIfCode(i32 %0, i8* %1, double* nocapture %2, double returned %3, double %4, double %5) {
%7 = alloca [1000 x i8]
%8 = icmp eq i32 %0, 0
br i1 %8, label %29, label %9
9: ; preds = %6
%10 = load double, double* %2
%11 = fsub double %10, %3
%12 = tail call i32 @fabs(double %11)
%13 = sitofp i32 %12 to double
%14 = tail call i32 @fabs(double %3)
%15 = add nsw i32 %14, 1
%16 = load double, double* %2
%17 = tail call i32 @fabs(double %16)
%18 = add nsw i32 %15, %17
%19 = sitofp i32 %18 to double
%20 = fmul double %19, 1.000000e-03
%21 = fcmp olt double %20, %13
%22 = fcmp une double %4, %5
%23 = and i1 %22, %21
br i1 %23, label %24, label %29
24: ; preds = %9
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%26 = load double, double* %2
%27 = call i32 @sprintf(i8* %25, i8* dereferenceable(1) getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0), i8* %1, double %26, double %3)
%28 = call i32 @DymosimError(i8* %25)
br label %29
29: ; preds = %24, %9, %6
store double %3, double* %2
ret double %3
}