#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*/ exit(int);
double fabs(double);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int check_initial_values(double (*f)(double x, void *params), void *params,
                         double x_min, double x_max) {
  double y_min = f(x_min, params);
  double y_max = f(x_max, params);
  if (y_min * y_max >= 0.0) {
    printf("No zero crossing found in range [%15.14e, %15.14e].\n", x_min,
           x_max);
    printf("f(%15.14e) = %15.14e, f(%15.14e) = %15.14e\n", x_min, y_min, x_max,
           y_max);
    printf("Change initial values.\n");
    fflush(stdout);
    exit(-1);
  }
  if (fabs(y_min) < 1.e-9)
    return 1;
  if (fabs(y_max) < 1.e-9)
    return 2;
  return 0;
}


x86 assembly (clang, -O0):
<check_initial_values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rdi
call   *%rax
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rdi
call   *%rax
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e9 <check_initial_values+0xb9>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe86(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
lea    0xe99(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
movsd  -0x30(%rbp),%xmm1
movaps 0xe1b(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xdff(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1217 <check_initial_values+0xe7>
movl   $0x1,-0x4(%rbp)
jmp    124c <check_initial_values+0x11c>
movsd  -0x38(%rbp),%xmm1
movaps 0xded(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xdd1(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1245 <check_initial_values+0x115>
movl   $0x2,-0x4(%rbp)
jmp    124c <check_initial_values+0x11c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_initial_values>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%rdi
call   *%r14
movaps %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
mov    %rbx,%rdi
call   *%r14
movapd 0x10(%rsp),%xmm2
movapd %xmm0,%xmm3
movapd %xmm2,%xmm0
mulsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    11c1 <check_initial_values+0x81>
movapd 0xe6e(%rip),%xmm0
andpd  %xmm0,%xmm2
andpd  %xmm3,%xmm0
movsd  0xe6e(%rip),%xmm1
xor    %ecx,%ecx
ucomisd %xmm0,%xmm1
seta   %cl
add    %ecx,%ecx
ucomisd %xmm2,%xmm1
mov    $0x1,%eax
cmovbe %ecx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe50(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    $0x2,%al
movapd %xmm3,0x20(%rsp)
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movsd  (%rsp),%xmm2
movaps 0x20(%rsp),%xmm3
mov    $0x4,%al
call   1040 <printf@plt>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [53 x i8] c"No zero crossing found in range [%15.14e, %15.14e].\0A\00"
@.str.1 = [44 x i8] c"f(%15.14e) = %15.14e, f(%15.14e) = %15.14e\0A\00"
@.str.2 = [24 x i8] c"Change initial values.\0A\00"
@stdout = global i32 0
define i32 @check_initial_values(double (double, i8*)* %0, i8* %1, double %2, double %3) {
%5 = alloca i32
%6 = alloca double (double, i8*)*
%7 = alloca i8*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double (double, i8*)* %0, double (double, i8*)** %6
store i8* %1, i8** %7
store double %2, double* %8
store double %3, double* %9
%12 = load double (double, i8*)*, double (double, i8*)** %6
%13 = load double, double* %8
%14 = load i8*, i8** %7
%15 = call double %12(double %13, i8* %14)
store double %15, double* %10
%16 = load double (double, i8*)*, double (double, i8*)** %6
%17 = load double, double* %9
%18 = load i8*, i8** %7
%19 = call double %16(double %17, i8* %18)
store double %19, double* %11
%20 = load double, double* %10
%21 = load double, double* %11
%22 = fmul double %20, %21
%23 = fcmp oge double %22, 0.000000e+00
br i1 %23, label %24, label %37
24: ; preds = %4
%25 = load double, double* %8
%26 = load double, double* %9
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %25, double %26)
%28 = load double, double* %8
%29 = load double, double* %10
%30 = load double, double* %9
%31 = load double, double* %11
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), double %28, double %29, double %30, double %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* @stdout
%35 = call i32 @fflush(i32 %34)
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %4
%38 = load double, double* %10
%39 = call double @llvm.fabs.f64(double %38)
%40 = fcmp olt double %39, 1.000000e-09
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 1, i32* %5
br label %48
42: ; preds = %37
%43 = load double, double* %11
%44 = call double @llvm.fabs.f64(double %43)
%45 = fcmp olt double %44, 1.000000e-09
br i1 %45, label %46, label %47
46: ; preds = %42
store i32 2, i32* %5
br label %48
47: ; preds = %42
store i32 0, i32* %5
br label %48
48: ; preds = %47, %46, %41
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
@.str = [53 x i8] c"No zero crossing found in range [%15.14e, %15.14e].\0A\00"
@.str.1 = [44 x i8] c"f(%15.14e) = %15.14e, f(%15.14e) = %15.14e\0A\00"
@stdout = global i32 0
@str = [23 x i8] c"Change initial values.\00"
define i32 @check_initial_values(double (double, i8*)* nocapture %0, i8* %1, double %2, double %3) {
%5 = tail call double %0(double %2, i8* %1)
%6 = tail call double %0(double %3, i8* %1)
%7 = fmul double %5, %6
%8 = fcmp ult double %7, 0.000000e+00
br i1 %8, label %16, label %9
9: ; preds = %4
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %2, double %3)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), double %2, double %5, double %3, double %6)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %4
%17 = tail call double @llvm.fabs.f64(double %5)
%18 = fcmp olt double %17, 1.000000e-09
%19 = tail call double @llvm.fabs.f64(double %6)
%20 = fcmp olt double %19, 1.000000e-09
%21 = select i1 %20, i32 2, i32 0
%22 = select i1 %18, i32 1, i32 %21
ret i32 %22
}