#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(int);
int /*<<< orphan*/ fisError(char *);
int pow(double, double);
double fisGaussian2Mf(double x, double *params) {
  double sigma1 = params[0], c1 = params[1];
  double sigma2 = params[2], c2 = params[3];
  double tmp1, tmp2;
  if ((sigma1 == 0) || (sigma2 == 0))
    fisError(
        "Illegal parameters in fisGaussian2MF() --> sigma1 or sigma2 is zero");
  tmp1 = x >= c1 ? 1 : exp(-pow((x - c1) / sigma1, 2.0) / 2);
  tmp2 = x <= c2 ? 1 : exp(-pow((x - c2) / sigma2, 2.0) / 2);
  return (tmp1 * tmp2);
}


x86 assembly (clang, -O0):
<fisGaussian2Mf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1195 <fisGaussian2Mf+0x65>
jp     1195 <fisGaussian2Mf+0x65>
jmp    11ad <fisGaussian2Mf+0x7d>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b9 <fisGaussian2Mf+0x89>
jp     11b9 <fisGaussian2Mf+0x89>
lea    0xe54(%rip),%rdi
call   1030 <fisError@plt>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11d6 <fisGaussian2Mf+0xa6>
mov    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    120a <fisGaussian2Mf+0xda>
movsd  -0x8(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  0xe13(%rip),%xmm1
call   1050 <pow@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <exp@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1237 <fisGaussian2Mf+0x107>
mov    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    126b <fisGaussian2Mf+0x13b>
movsd  -0x8(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  0xdb2(%rip),%xmm1
call   1050 <pow@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <exp@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fisGaussian2Mf>:
sub    $0x28,%rsp
movapd %xmm0,%xmm2
movsd  (%rdi),%xmm5
movsd  0x8(%rdi),%xmm6
movsd  0x10(%rdi),%xmm1
movsd  0x18(%rdi),%xmm0
movsd  %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm5
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x8(%rsp)
jne    1168 <fisGaussian2Mf+0x38>
jnp    1170 <fisGaussian2Mf+0x40>
ucomisd %xmm0,%xmm1
jne    119f <fisGaussian2Mf+0x6f>
jp     119f <fisGaussian2Mf+0x6f>
lea    0xe99(%rip),%rdi
movsd  %xmm5,0x18(%rsp)
movsd  %xmm6,0x10(%rsp)
call   1030 <fisError@plt>
movsd  0x10(%rsp),%xmm6
movsd  0x18(%rsp),%xmm5
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
movsd  0xe59(%rip),%xmm3
ucomisd %xmm6,%xmm2
movapd %xmm3,%xmm4
jae    11f4 <fisGaussian2Mf+0xc4>
movapd %xmm2,%xmm0
subsd  %xmm6,%xmm0
divsd  %xmm5,%xmm0
movsd  0xe43(%rip),%xmm1
call   1050 <pow@plt>
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
neg    %edi
call   1040 <exp@plt>
movsd  0xe1e(%rip),%xmm3
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
movsd  0x20(%rsp),%xmm0
ucomisd %xmm2,%xmm0
jae    123a <fisGaussian2Mf+0x10a>
subsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
movsd  0xdf8(%rip),%xmm1
movapd %xmm2,%xmm0
movsd  %xmm4,(%rsp)
call   1050 <pow@plt>
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
neg    %edi
call   1040 <exp@plt>
movsd  (%rsp),%xmm4
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm4
movapd %xmm4,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"Illegal parameters in fisGaussian2MF() --> sigma1 or sigma2 is zero\00"
define double @fisGaussian2Mf(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %3
store double* %1, double** %4
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
store double %13, double* %5
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
store double %16, double* %6
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 2
%19 = load double, double* %18
store double %19, double* %7
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 3
%22 = load double, double* %21
store double %22, double* %8
%23 = load double, double* %5
%24 = fcmp oeq double %23, 0.000000e+00
br i1 %24, label %28, label %25
25: ; preds = %2
%26 = load double, double* %7
%27 = fcmp oeq double %26, 0.000000e+00
br i1 %27, label %28, label %30
28: ; preds = %25, %2
%29 = call i32 @fisError(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
%31 = load double, double* %3
%32 = load double, double* %6
%33 = fcmp oge double %31, %32
br i1 %33, label %34, label %35
34: ; preds = %30
br label %45
35: ; preds = %30
%36 = load double, double* %3
%37 = load double, double* %6
%38 = fsub double %36, %37
%39 = load double, double* %5
%40 = fdiv double %38, %39
%41 = call i32 @pow(double %40, double 2.000000e+00)
%42 = sub nsw i32 0, %41
%43 = sdiv i32 %42, 2
%44 = call i32 @exp(i32 %43)
br label %45
45: ; preds = %35, %34
%46 = phi i32 [ 1, %34 ], [ %44, %35 ]
%47 = sitofp i32 %46 to double
store double %47, double* %9
%48 = load double, double* %3
%49 = load double, double* %8
%50 = fcmp ole double %48, %49
br i1 %50, label %51, label %52
51: ; preds = %45
br label %62
52: ; preds = %45
%53 = load double, double* %3
%54 = load double, double* %8
%55 = fsub double %53, %54
%56 = load double, double* %7
%57 = fdiv double %55, %56
%58 = call i32 @pow(double %57, double 2.000000e+00)
%59 = sub nsw i32 0, %58
%60 = sdiv i32 %59, 2
%61 = call i32 @exp(i32 %60)
br label %62
62: ; preds = %52, %51
%63 = phi i32 [ 1, %51 ], [ %61, %52 ]
%64 = sitofp i32 %63 to double
store double %64, double* %10
%65 = load double, double* %9
%66 = load double, double* %10
%67 = fmul double %65, %66
ret double %67
}

LLVM IR (-O2):
@.str = [68 x i8] c"Illegal parameters in fisGaussian2MF() --> sigma1 or sigma2 is zero\00"
define double @fisGaussian2Mf(double %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = getelementptr inbounds double, double* %1, i64 1
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %1, i64 2
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %1, i64 3
%9 = load double, double* %8
%10 = fcmp oeq double %3, 0.000000e+00
%11 = fcmp oeq double %7, 0.000000e+00
%12 = select i1 %10, i1 true, i1 %11
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 @fisError(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %2, %13
%16 = fcmp ugt double %5, %0
br i1 %16, label %17, label %24
17: ; preds = %15
%18 = fsub double %0, %5
%19 = fdiv double %18, %3
%20 = tail call i32 @pow(double %19, double 2.000000e+00)
%21 = sdiv i32 %20, -2
%22 = tail call i32 @exp(i32 %21)
%23 = sitofp i32 %22 to double
br label %24
24: ; preds = %15, %17
%25 = phi double [ %23, %17 ], [ 1.000000e+00, %15 ]
%26 = fcmp ult double %9, %0
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = fsub double %0, %9
%29 = fdiv double %28, %7
%30 = tail call i32 @pow(double %29, double 2.000000e+00)
%31 = sdiv i32 %30, -2
%32 = tail call i32 @exp(i32 %31)
%33 = sitofp i32 %32 to double
br label %34
34: ; preds = %24, %27
%35 = phi double [ %33, %27 ], [ 1.000000e+00, %24 ]
%36 = fmul double %25, %35
ret double %36
}