double findRootsInterval(double *a, double *b, int origin,
                         double (*fp)(double)) {
  double i;
  for (i = 1;; i += 0.5) {
    if ((*fp)(origin + i) * (*fp)(origin - i) < 0) {
      *a = origin - i;
      *b = origin + i;
      return 0;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<findRootsInterval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  0xee1(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cvtsi2sdl -0x14(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
cvtsi2sdl -0x14(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   *%rax
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    118c <findRootsInterval+0x8c>
cvtsi2sdl -0x14(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
cvtsi2sdl -0x14(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
add    $0x30,%rsp
pop    %rbp
ret
jmp    1191 <findRootsInterval+0x91>
movsd  0xe6f(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1124 <findRootsInterval+0x24>

x86 assembly (clang, -O2):
<findRootsInterval>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rcx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
cvtsi2sd %edx,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xedc(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
call   *%rcx
movsd  %xmm0,0x8(%rsp)
movsd  0xeca(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   *%rbx
mulsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11bc <findRootsInterval+0xbc>
movsd  0xe9c(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
addsd  0xe92(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
call   *%rbx
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   *%rbx
xorpd  %xmm1,%xmm1
mulsd  0x28(%rsp),%xmm0
ucomisd %xmm0,%xmm1
jbe    1170 <findRootsInterval+0x70>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r15)
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r14)
xorps  %xmm0,%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @findRootsInterval(double* %0, double* %1, i32 %2, double (double)* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double (double)*
%9 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store double (double)* %3, double (double)** %8
store double 1.000000e+00, double* %9
br label %10
10: ; preds = %37, %4
%11 = load double (double)*, double (double)** %8
%12 = load i32, i32* %7
%13 = sitofp i32 %12 to double
%14 = load double, double* %9
%15 = fadd double %13, %14
%16 = call double %11(double %15)
%17 = load double (double)*, double (double)** %8
%18 = load i32, i32* %7
%19 = sitofp i32 %18 to double
%20 = load double, double* %9
%21 = fsub double %19, %20
%22 = call double %17(double %21)
%23 = fmul double %16, %22
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %25, label %36
25: ; preds = %10
%26 = load i32, i32* %7
%27 = sitofp i32 %26 to double
%28 = load double, double* %9
%29 = fsub double %27, %28
%30 = load double*, double** %5
store double %29, double* %30
%31 = load i32, i32* %7
%32 = sitofp i32 %31 to double
%33 = load double, double* %9
%34 = fadd double %32, %33
%35 = load double*, double** %6
store double %34, double* %35
ret double 0.000000e+00
36: ; preds = %10
br label %37
37: ; preds = %36
%38 = load double, double* %9
%39 = fadd double %38, 5.000000e-01
store double %39, double* %9
br label %10
}

LLVM IR (-O2):
define double @findRootsInterval(double* nocapture writeonly %0, double* nocapture writeonly %1, i32 %2, double (double)* nocapture %3) {
%5 = sitofp i32 %2 to double
%6 = fadd double %5, 1.000000e+00
%7 = tail call double %3(double %6)
%8 = fadd double %5, -1.000000e+00
%9 = tail call double %3(double %8)
%10 = fmul double %7, %9
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %15, %4
%13 = phi double [ %6, %4 ], [ %18, %15 ]
%14 = phi double [ %8, %4 ], [ %20, %15 ]
store double %14, double* %0
store double %13, double* %1
ret double 0.000000e+00
15: ; preds = %4, %15
%16 = phi double [ %17, %15 ], [ 1.000000e+00, %4 ]
%17 = fadd double %16, 5.000000e-01
%18 = fadd double %17, %5
%19 = tail call double %3(double %18)
%20 = fsub double %5, %17
%21 = tail call double %3(double %20)
%22 = fmul double %19, %21
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %12, label %15
}