#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 Bessel(double, int);
double BesselZero(int n, int m) {
  int sign1, sign2;
  double x = 0, y, ncount = 0;
  if (n <= 0)
    return (0.0);
  y = Bessel(x, m);
  if ((y < 0 ? -(y) : (y)) < 0.001) {
    if (n == 1)
      return (0.0);
    ncount++;
    x += 0.001;
    sign1 = (Bessel(x, m) < 0 ? (-1) : 1);
  } else {
    sign1 = (x < 0 ? (-1) : 1);
  }
  x += 0.001;
  for (; x < 100; x += 0.001) {
    y = (Bessel(x, m) < 0 ? (-1) : 1);
    sign2 = (y < 0 ? (-1) : 1);
    if (sign2 != sign1) {
      sign1 = sign2;
      ncount++;
      if (ncount >= n)
        return (x);
    }
  }
  return (-1.0);
}


x86 assembly (clang, -O0):
<BesselZero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     1145 <BesselZero+0x35>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1312 <BesselZero+0x202>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%edi
call   1030 <Bessel@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    118b <BesselZero+0x7b>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1195 <BesselZero+0x85>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  0xe5e(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1213 <BesselZero+0x103>
cmpl   $0x1,-0xc(%rbp)
jne    11c3 <BesselZero+0xb3>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1312 <BesselZero+0x202>
movsd  0xe3d(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe23(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%edi
call   1030 <Bessel@plt>
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    122f <BesselZero+0x11f>
movsd  -0x20(%rbp),%xmm1
xorps  %xmm0,%xmm0
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x14(%rbp)
movsd  0xdc9(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xdc7(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1305 <BesselZero+0x1f5>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%edi
call   1030 <Bessel@plt>
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
xorps  %xmm0,%xmm0
mov    $0x1,%eax
mov    $0xffffffff,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     12e9 <BesselZero+0x1d9>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
movsd  0xd51(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jb     12e4 <BesselZero+0x1d4>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1312 <BesselZero+0x202>
jmp    12e9 <BesselZero+0x1d9>
jmp    12ee <BesselZero+0x1de>
movsd  0xd0a(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1241 <BesselZero+0x131>
movsd  0xd0b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BesselZero>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %edi,%edi
jle    1237 <BesselZero+0x127>
mov    %esi,%ebx
mov    %edi,%r14d
xorpd  %xmm0,%xmm0
mov    %esi,%edi
call   1030 <Bessel@plt>
movapd 0xec8(%rip),%xmm1
xorpd  %xmm0,%xmm1
movapd %xmm0,%xmm2
cmpltsd 0xeef(%rip),%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
movsd  0xeb3(%rip),%xmm0
mov    $0x1,%ebp
ucomisd %xmm2,%xmm0
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
jbe    11b8 <BesselZero+0xa8>
xorpd  %xmm0,%xmm0
cmp    $0x1,%r14d
je     1245 <BesselZero+0x135>
movsd  0xe88(%rip),%xmm0
mov    %ebx,%edi
call   1030 <Bessel@plt>
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setbe  %al
lea    (%rax,%rax,1),%ebp
add    $0xffffffff,%ebp
movsd  0xe6e(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe68(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
movsd  %xmm1,0x18(%rsp)
jmp    11f0 <BesselZero+0xe0>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
movsd  0x10(%rsp),%xmm0
addsd  0xe30(%rip),%xmm0
movsd  0xe48(%rip),%xmm1
ucomisd %xmm0,%xmm1
mov    %eax,%ebp
jbe    123d <BesselZero+0x12d>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1030 <Bessel@plt>
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
setbe  %al
add    %eax,%eax
add    $0xffffffff,%eax
cmp    %ebp,%eax
je     11d0 <BesselZero+0xc0>
movsd  0x8(%rsp),%xmm0
addsd  0xdf7(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
ucomisd 0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm0
jb     11d8 <BesselZero+0xc8>
jmp    1245 <BesselZero+0x135>
xorpd  %xmm0,%xmm0
jmp    1245 <BesselZero+0x135>
movsd  0xde3(%rip),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @BesselZero(i32 %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %10
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
store double 0.000000e+00, double* %3
br label %85
14: ; preds = %2
%15 = load double, double* %8
%16 = load i32, i32* %5
%17 = call double @Bessel(double %15, i32 %16)
store double %17, double* %9
%18 = load double, double* %9
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load double, double* %9
%22 = fneg double %21
br label %25
23: ; preds = %14
%24 = load double, double* %9
br label %25
25: ; preds = %23, %20
%26 = phi double [ %22, %20 ], [ %24, %23 ]
%27 = fcmp olt double %26, 1.000000e-03
br i1 %27, label %28, label %43
28: ; preds = %25
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %32
31: ; preds = %28
store double 0.000000e+00, double* %3
br label %85
32: ; preds = %28
%33 = load double, double* %10
%34 = fadd double %33, 1.000000e+00
store double %34, double* %10
%35 = load double, double* %8
%36 = fadd double %35, 1.000000e-03
store double %36, double* %8
%37 = load double, double* %8
%38 = load i32, i32* %5
%39 = call double @Bessel(double %37, i32 %38)
%40 = fcmp olt double %39, 0.000000e+00
%41 = zext i1 %40 to i64
%42 = select i1 %40, i32 -1, i32 1
store i32 %42, i32* %6
br label %48
43: ; preds = %25
%44 = load double, double* %8
%45 = fcmp olt double %44, 0.000000e+00
%46 = zext i1 %45 to i64
%47 = select i1 %45, i32 -1, i32 1
store i32 %47, i32* %6
br label %48
48: ; preds = %43, %32
%49 = load double, double* %8
%50 = fadd double %49, 1.000000e-03
store double %50, double* %8
br label %51
51: ; preds = %81, %48
%52 = load double, double* %8
%53 = fcmp olt double %52, 1.000000e+02
br i1 %53, label %54, label %84
54: ; preds = %51
%55 = load double, double* %8
%56 = load i32, i32* %5
%57 = call double @Bessel(double %55, i32 %56)
%58 = fcmp olt double %57, 0.000000e+00
%59 = zext i1 %58 to i64
%60 = select i1 %58, i32 -1, i32 1
%61 = sitofp i32 %60 to double
store double %61, double* %9
%62 = load double, double* %9
%63 = fcmp olt double %62, 0.000000e+00
%64 = zext i1 %63 to i64
%65 = select i1 %63, i32 -1, i32 1
store i32 %65, i32* %7
%66 = load i32, i32* %7
%67 = load i32, i32* %6
%68 = icmp ne i32 %66, %67
br i1 %68, label %69, label %80
69: ; preds = %54
%70 = load i32, i32* %7
store i32 %70, i32* %6
%71 = load double, double* %10
%72 = fadd double %71, 1.000000e+00
store double %72, double* %10
%73 = load double, double* %10
%74 = load i32, i32* %4
%75 = sitofp i32 %74 to double
%76 = fcmp oge double %73, %75
br i1 %76, label %77, label %79
77: ; preds = %69
%78 = load double, double* %8
store double %78, double* %3
br label %85
79: ; preds = %69
br label %80
80: ; preds = %79, %54
br label %81
81: ; preds = %80
%82 = load double, double* %8
%83 = fadd double %82, 1.000000e-03
store double %83, double* %8
br label %51
84: ; preds = %51
store double -1.000000e+00, double* %3
br label %85
85: ; preds = %84, %77, %31, %13
%86 = load double, double* %3
ret double %86
}

LLVM IR (-O2):
define double @BesselZero(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %37, label %4
4: ; preds = %2
%5 = tail call double @Bessel(double 0.000000e+00, i32 %1)
%6 = fcmp olt double %5, 0.000000e+00
%7 = fneg double %5
%8 = select i1 %6, double %7, double %5
%9 = fcmp olt double %8, 1.000000e-03
br i1 %9, label %10, label %16
10: ; preds = %4
%11 = icmp eq i32 %0, 1
br i1 %11, label %37, label %12
12: ; preds = %10
%13 = tail call double @Bessel(double 1.000000e-03, i32 %1)
%14 = fcmp olt double %13, 0.000000e+00
%15 = select i1 %14, i32 -1, i32 1
br label %16
16: ; preds = %4, %12
%17 = phi i32 [ %15, %12 ], [ 1, %4 ]
%18 = phi double [ 2.000000e-03, %12 ], [ 1.000000e-03, %4 ]
%19 = phi double [ 1.000000e+00, %12 ], [ 0.000000e+00, %4 ]
%20 = sitofp i32 %0 to double
br label %21
21: ; preds = %16, %32
%22 = phi double [ %19, %16 ], [ %34, %32 ]
%23 = phi double [ %18, %16 ], [ %35, %32 ]
%24 = phi i32 [ %17, %16 ], [ %33, %32 ]
%25 = tail call double @Bessel(double %23, i32 %1)
%26 = fcmp olt double %25, 0.000000e+00
%27 = select i1 %26, i32 -1, i32 1
%28 = icmp eq i32 %27, %24
br i1 %28, label %32, label %29
29: ; preds = %21
%30 = fadd double %22, 1.000000e+00
%31 = fcmp ult double %30, %20
br i1 %31, label %32, label %37
32: ; preds = %21, %29
%33 = phi i32 [ %27, %29 ], [ %24, %21 ]
%34 = phi double [ %30, %29 ], [ %22, %21 ]
%35 = fadd double %23, 1.000000e-03
%36 = fcmp olt double %35, 1.000000e+02
br i1 %36, label %21, label %37
37: ; preds = %32, %29, %10, %2
%38 = phi double [ 0.000000e+00, %2 ], [ 0.000000e+00, %10 ], [ -1.000000e+00, %32 ], [ %23, %29 ]
ret double %38
}