#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 M_PI;
double M_PI_2;
double atan2(double, double);
double fabs(double);
int G_math_findzc(double conv[], int size, double zc[], double thresh,
                  int num_orients) {
  int i, j, p;
  for (i = 1; i < size - 1; i++) {
    for (p = i * size + 1, j = 1; j < size - 1; j++, p++) {
      int nbr[4];
      int ni;
      nbr[0] = p - 1;
      nbr[1] = p + 1;
      nbr[2] = p - size;
      nbr[3] = p + size;
      zc[p] = 0;
      for (ni = 0; ni < 4; ni++) {
        if ((((conv[p] > 0) && (conv[nbr[ni]] < 0)) ||
             ((conv[p] < 0) && (conv[nbr[ni]] > 0))) &&
            (fabs(conv[p]) < fabs(conv[nbr[ni]])) &&
            (fabs(conv[p] - conv[nbr[ni]]) > thresh)) {
          double ang;
          int dir;
          if (fabs(conv[nbr[1]] - conv[nbr[0]]) < 1.0e-3) {
            ang = M_PI_2;
            if (conv[nbr[2]] - conv[nbr[3]] < 0)
              ang = -ang;
          } else
            ang =
                atan2(conv[nbr[2]] - conv[nbr[3]], conv[nbr[1]] - conv[nbr[0]]);
          dir = num_orients * ((ang + M_PI) / (M_PI * 2.0)) + 0.4999;
          dir = (3 * num_orients / 4 + dir) % num_orients;
          zc[p] = 1 + dir;
          break;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<G_math_findzc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1414 <G_math_findzc+0x304>
mov    -0x28(%rbp),%eax
imul   -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1401 <G_math_findzc+0x2f1>
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x44(%rbp)
cmpl   $0x4,-0x44(%rbp)
jge    13e5 <G_math_findzc+0x2d5>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11e2 <G_math_findzc+0xd2>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movslq -0x40(%rbp,%rcx,4),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
ja     1217 <G_math_findzc+0x107>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    13d2 <G_math_findzc+0x2c2>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movslq -0x40(%rbp,%rcx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    13d2 <G_math_findzc+0x2c2>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movaps 0xdd5(%rip),%xmm0
pand   %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movslq -0x40(%rbp,%rcx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xdb8(%rip),%xmm2
pand   %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    13d2 <G_math_findzc+0x2c2>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movslq -0x40(%rbp,%rcx,4),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xd84(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    13d2 <G_math_findzc+0x2c2>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
movaps 0xd54(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd58(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    131f <G_math_findzc+0x20f>
mov    0x2d17(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    131a <G_math_findzc+0x20a>
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    135d <G_math_findzc+0x24d>
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
mov    0x2c7a(%rip),%rax
addsd  (%rax),%xmm1
movsd  0xca6(%rip),%xmm2
mov    0x2c67(%rip),%rax
mulsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc83(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x54(%rbp)
imul   $0x3,-0x24(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
add    -0x54(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    %edx,-0x54(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    13e5 <G_math_findzc+0x2d5>
jmp    13d7 <G_math_findzc+0x2c7>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11a3 <G_math_findzc+0x93>
jmp    13ea <G_math_findzc+0x2da>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1157 <G_math_findzc+0x47>
jmp    1406 <G_math_findzc+0x2f6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1132 <G_math_findzc+0x22>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<G_math_findzc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdx,0x40(%rsp)
mov    %rsi,0x18(%rsp)
cmp    $0x3,%esi
jl     150f <G_math_findzc+0x3ff>
movapd %xmm0,%xmm4
mov    0x18(%rsp),%rdx
lea    -0x1(%rdx),%eax
mov    %eax,0x8(%rsp)
movabs $0xffffffff00000000,%r9
ff ff ff
cvtsi2sd %ecx,%xmm8
lea    (%rcx,%rcx,2),%eax
lea    (%rcx,%rcx,2),%r8d
add    $0x3,%r8d
test   %eax,%eax
cmovns %eax,%r8d
movabs $0x100000000,%rsi
sar    $0x2,%r8d
lea    0x1(%rdx),%ebx
mov    %edx,%eax
mov    %rax,%rbp
imul   %r9,%rbp
mov    %rbp,0x30(%rsp)
mov    %rax,0x38(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rdi,%rbp
sub    %rax,%rbp
mov    %rbp,0x28(%rsp)
lea    -0x2(%rdx),%r9d
mov    $0x1,%eax
xorpd  %xmm6,%xmm6
movapd 0xe50(%rip),%xmm7
movsd  0xe68(%rip),%xmm5
mov    0x2e29(%rip),%r10
movsd  0xe60(%rip),%xmm9
movsd  %xmm0,0x68(%rsp)
mov    %rdi,0x60(%rsp)
movsd  %xmm8,0x58(%rsp)
mov    %r8d,0x14(%rsp)
mov    %rcx,0x50(%rsp)
mov    %r9,0x48(%rsp)
jmp    1209 <G_math_findzc+0xf9>
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%eax
add    $0x1,%eax
mov    0x10(%rsp),%ebx
add    0x18(%rsp),%ebx
cmp    0x8(%rsp),%eax
je     150f <G_math_findzc+0x3ff>
mov    %eax,0xc(%rsp)
mov    %ebx,0x10(%rsp)
movslq %ebx,%r15
mov    0x28(%rsp),%rax
lea    (%rax,%r15,8),%r11
mov    0x38(%rsp),%rax
lea    (%rax,%r15,1),%r12
mov    0x40(%rsp),%rax
lea    (%rax,%r15,8),%rbx
lea    (%rdi,%r15,8),%rdx
shl    $0x20,%r15
mov    0x30(%rsp),%rax
lea    (%rax,%r15,1),%r13
lea    (%rdi,%r12,8),%rax
mov    %rax,0x20(%rsp)
shl    $0x20,%r12
movabs $0xffffffff00000000,%rax
ff ff ff
lea    (%r15,%rax,1),%rbp
add    %rsi,%r15
xor    %r14d,%r14d
mov    %rdx,0x80(%rsp)
mov    %r11,0x78(%rsp)
mov    %rbx,0x70(%rsp)
jmp    1339 <G_math_findzc+0x229>
movsd  (%r11,%r14,8),%xmm0
mov    0x20(%rsp),%rax
subsd  (%rax,%r14,8),%xmm0
mov    %rsi,%rbx
call   1030 <atan2@plt>
mov    0x78(%rsp),%r11
movsd  0xd89(%rip),%xmm9
mov    0x2d42(%rip),%r10
movsd  0xd72(%rip),%xmm5
movapd 0xd4a(%rip),%xmm7
xorpd  %xmm6,%xmm6
mov    0x48(%rsp),%r9
mov    %rbx,%rsi
mov    0x70(%rsp),%rbx
mov    0x14(%rsp),%r8d
movsd  0x58(%rsp),%xmm8
mov    0x60(%rsp),%rdi
movsd  0x68(%rsp),%xmm4
mov    0x50(%rsp),%rcx
movsd  (%r10),%xmm1
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
mulsd  %xmm8,%xmm0
addsd  %xmm9,%xmm0
cvttsd2si %xmm0,%eax
add    %r8d,%eax
cltd
idiv   %ecx
add    $0x1,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  %xmm0,(%rbx,%r14,8)
mov    0x80(%rsp),%rdx
add    %rsi,%r13
add    $0x1,%r14
add    %rsi,%r12
add    %rsi,%rbp
add    %rsi,%r15
cmp    %r14d,%r9d
je     11f0 <G_math_findzc+0xe0>
movq   $0x0,(%rbx,%r14,8)
movsd  (%rdx,%r14,8),%xmm0
ucomisd %xmm6,%xmm0
movapd %xmm0,%xmm1
andpd  %xmm7,%xmm1
jbe    1367 <G_math_findzc+0x257>
mov    %rbp,%rax
sar    $0x1d,%rax
movsd  (%rdi,%rax,1),%xmm2
ucomisd %xmm2,%xmm6
ja     137f <G_math_findzc+0x26f>
ucomisd %xmm0,%xmm6
jbe    13b0 <G_math_findzc+0x2a0>
mov    %rbp,%rax
sar    $0x1d,%rax
movsd  (%rdi,%rax,1),%xmm2
ucomisd %xmm6,%xmm2
jbe    13b0 <G_math_findzc+0x2a0>
movapd %xmm2,%xmm3
andpd  %xmm7,%xmm3
ucomisd %xmm1,%xmm3
jbe    13b0 <G_math_findzc+0x2a0>
movapd %xmm0,%xmm3
subsd  %xmm2,%xmm3
andpd  %xmm7,%xmm3
ucomisd %xmm4,%xmm3
ja     14bc <G_math_findzc+0x3ac>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
ucomisd %xmm6,%xmm0
jbe    13c8 <G_math_findzc+0x2b8>
mov    %r15,%rax
sar    $0x1d,%rax
movsd  (%rdi,%rax,1),%xmm2
ucomisd %xmm2,%xmm6
ja     13e0 <G_math_findzc+0x2d0>
ucomisd %xmm0,%xmm6
jbe    1410 <G_math_findzc+0x300>
mov    %r15,%rax
sar    $0x1d,%rax
movsd  (%rdi,%rax,1),%xmm2
ucomisd %xmm6,%xmm2
jbe    1410 <G_math_findzc+0x300>
movapd %xmm2,%xmm3
andpd  %xmm7,%xmm3
ucomisd %xmm1,%xmm3
jbe    1410 <G_math_findzc+0x300>
movapd %xmm0,%xmm3
subsd  %xmm2,%xmm3
andpd  %xmm7,%xmm3
ucomisd %xmm4,%xmm3
ja     14bc <G_math_findzc+0x3ac>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
ucomisd %xmm6,%xmm0
jbe    1428 <G_math_findzc+0x318>
mov    %r13,%rax
sar    $0x1d,%rax
movsd  (%rdi,%rax,1),%xmm2
ucomisd %xmm2,%xmm6
ja     1440 <G_math_findzc+0x330>
ucomisd %xmm0,%xmm6
jbe    1460 <G_math_findzc+0x350>
mov    %r13,%rax
sar    $0x1d,%rax
movsd  (%rdi,%rax,1),%xmm2
ucomisd %xmm6,%xmm2
jbe    1460 <G_math_findzc+0x350>
movapd %xmm2,%xmm3
andpd  %xmm7,%xmm3
ucomisd %xmm1,%xmm3
jbe    1460 <G_math_findzc+0x350>
movapd %xmm0,%xmm3
subsd  %xmm2,%xmm3
andpd  %xmm7,%xmm3
ucomisd %xmm4,%xmm3
ja     14bc <G_math_findzc+0x3ac>
ucomisd %xmm6,%xmm0
jbe    1478 <G_math_findzc+0x368>
mov    %r12,%rax
sar    $0x1d,%rax
movsd  (%rdi,%rax,1),%xmm2
ucomisd %xmm2,%xmm6
ja     1498 <G_math_findzc+0x388>
ucomisd %xmm0,%xmm6
jbe    1320 <G_math_findzc+0x210>
mov    %r12,%rax
sar    $0x1d,%rax
movsd  (%rdi,%rax,1),%xmm2
ucomisd %xmm6,%xmm2
jbe    1320 <G_math_findzc+0x210>
movapd %xmm2,%xmm3
andpd  %xmm7,%xmm3
ucomisd %xmm1,%xmm3
jbe    1320 <G_math_findzc+0x210>
subsd  %xmm2,%xmm0
andpd  %xmm7,%xmm0
ucomisd %xmm4,%xmm0
jbe    1320 <G_math_findzc+0x210>
movsd  0x8(%rdx,%r14,8),%xmm1
subsd  -0x8(%rdx,%r14,8),%xmm1
movapd %xmm1,%xmm0
andpd  %xmm7,%xmm0
ucomisd %xmm0,%xmm5
jbe    1278 <G_math_findzc+0x168>
mov    0x2afd(%rip),%rax
movsd  (%rax),%xmm0
movsd  (%r11,%r14,8),%xmm1
mov    0x20(%rsp),%rax
subsd  (%rax,%r14,8),%xmm1
ucomisd %xmm1,%xmm6
jbe    12e3 <G_math_findzc+0x1d3>
xorpd  0xb06(%rip),%xmm0
jmp    12e3 <G_math_findzc+0x1d3>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI_2 = global double 0.000000e+00
@M_PI = global double 0.000000e+00
define i32 @G_math_findzc(double* %0, i32 %1, double* %2, double %3, i32 %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [4 x i32]
%15 = alloca i32
%16 = alloca double
%17 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store double* %2, double** %8
store double %3, double* %9
store i32 %4, i32* %10
store i32 1, i32* %11
br label %18
18: ; preds = %224, %5
%19 = load i32, i32* %11
%20 = load i32, i32* %7
%21 = sub nsw i32 %20, 1
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %227
23: ; preds = %18
%24 = load i32, i32* %11
%25 = load i32, i32* %7
%26 = mul nsw i32 %24, %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %13
store i32 1, i32* %12
br label %28
28: ; preds = %218, %23
%29 = load i32, i32* %12
%30 = load i32, i32* %7
%31 = sub nsw i32 %30, 1
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %223
33: ; preds = %28
%34 = load i32, i32* %13
%35 = sub nsw i32 %34, 1
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 0
store i32 %35, i32* %36
%37 = load i32, i32* %13
%38 = add nsw i32 %37, 1
%39 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 1
store i32 %38, i32* %39
%40 = load i32, i32* %13
%41 = load i32, i32* %7
%42 = sub nsw i32 %40, %41
%43 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 2
store i32 %42, i32* %43
%44 = load i32, i32* %13
%45 = load i32, i32* %7
%46 = add nsw i32 %44, %45
%47 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 3
store i32 %46, i32* %47
%48 = load double*, double** %8
%49 = load i32, i32* %13
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double 0.000000e+00, double* %51
store i32 0, i32* %15
br label %52
52: ; preds = %214, %33
%53 = load i32, i32* %15
%54 = icmp slt i32 %53, 4
br i1 %54, label %55, label %217
55: ; preds = %52
%56 = load double*, double** %6
%57 = load i32, i32* %13
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double, double* %59
%61 = fcmp ogt double %60, 0.000000e+00
br i1 %61, label %62, label %72
62: ; preds = %55
%63 = load double*, double** %6
%64 = load i32, i32* %15
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 %65
%67 = load i32, i32* %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %63, i64 %68
%70 = load double, double* %69
%71 = fcmp olt double %70, 0.000000e+00
br i1 %71, label %89, label %72
72: ; preds = %62, %55
%73 = load double*, double** %6
%74 = load i32, i32* %13
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
%77 = load double, double* %76
%78 = fcmp olt double %77, 0.000000e+00
br i1 %78, label %79, label %213
79: ; preds = %72
%80 = load double*, double** %6
%81 = load i32, i32* %15
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 %82
%84 = load i32, i32* %83
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %80, i64 %85
%87 = load double, double* %86
%88 = fcmp ogt double %87, 0.000000e+00
br i1 %88, label %89, label %213
89: ; preds = %79, %62
%90 = load double*, double** %6
%91 = load i32, i32* %13
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double, double* %90, i64 %92
%94 = load double, double* %93
%95 = call double @llvm.fabs.f64(double %94)
%96 = load double*, double** %6
%97 = load i32, i32* %15
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 %98
%100 = load i32, i32* %99
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %96, i64 %101
%103 = load double, double* %102
%104 = call double @llvm.fabs.f64(double %103)
%105 = fcmp olt double %95, %104
br i1 %105, label %106, label %213
106: ; preds = %89
%107 = load double*, double** %6
%108 = load i32, i32* %13
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds double, double* %107, i64 %109
%111 = load double, double* %110
%112 = load double*, double** %6
%113 = load i32, i32* %15
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 %114
%116 = load i32, i32* %115
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %112, i64 %117
%119 = load double, double* %118
%120 = fsub double %111, %119
%121 = call double @llvm.fabs.f64(double %120)
%122 = load double, double* %9
%123 = fcmp ogt double %121, %122
br i1 %123, label %124, label %213
124: ; preds = %106
%125 = load double*, double** %6
%126 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 1
%127 = load i32, i32* %126
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %125, i64 %128
%130 = load double, double* %129
%131 = load double*, double** %6
%132 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 0
%133 = load i32, i32* %132
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds double, double* %131, i64 %134
%136 = load double, double* %135
%137 = fsub double %130, %136
%138 = call double @llvm.fabs.f64(double %137)
%139 = fcmp olt double %138, 1.000000e-03
br i1 %139, label %140, label %160
140: ; preds = %124
%141 = load double, double* @M_PI_2
store double %141, double* %16
%142 = load double*, double** %6
%143 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 2
%144 = load i32, i32* %143
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds double, double* %142, i64 %145
%147 = load double, double* %146
%148 = load double*, double** %6
%149 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 3
%150 = load i32, i32* %149
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds double, double* %148, i64 %151
%153 = load double, double* %152
%154 = fsub double %147, %153
%155 = fcmp olt double %154, 0.000000e+00
br i1 %155, label %156, label %159
156: ; preds = %140
%157 = load double, double* %16
%158 = fneg double %157
store double %158, double* %16
br label %159
159: ; preds = %156, %140
br label %188
160: ; preds = %124
%161 = load double*, double** %6
%162 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 2
%163 = load i32, i32* %162
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds double, double* %161, i64 %164
%166 = load double, double* %165
%167 = load double*, double** %6
%168 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 3
%169 = load i32, i32* %168
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds double, double* %167, i64 %170
%172 = load double, double* %171
%173 = fsub double %166, %172
%174 = load double*, double** %6
%175 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 1
%176 = load i32, i32* %175
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds double, double* %174, i64 %177
%179 = load double, double* %178
%180 = load double*, double** %6
%181 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 0
%182 = load i32, i32* %181
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %180, i64 %183
%185 = load double, double* %184
%186 = fsub double %179, %185
%187 = call double @atan2(double %173, double %186)
store double %187, double* %16
br label %188
188: ; preds = %160, %159
%189 = load i32, i32* %10
%190 = sitofp i32 %189 to double
%191 = load double, double* %16
%192 = load double, double* @M_PI
%193 = fadd double %191, %192
%194 = load double, double* @M_PI
%195 = fmul double %194, 2.000000e+00
%196 = fdiv double %193, %195
%197 = call double @llvm.fmuladd.f64(double %190, double %196, double 4.999000e-01)
%198 = fptosi double %197 to i32
store i32 %198, i32* %17
%199 = load i32, i32* %10
%200 = mul nsw i32 3, %199
%201 = sdiv i32 %200, 4
%202 = load i32, i32* %17
%203 = add nsw i32 %201, %202
%204 = load i32, i32* %10
%205 = srem i32 %203, %204
store i32 %205, i32* %17
%206 = load i32, i32* %17
%207 = add nsw i32 1, %206
%208 = sitofp i32 %207 to double
%209 = load double*, double** %8
%210 = load i32, i32* %13
%211 = sext i32 %210 to i64
%212 = getelementptr inbounds double, double* %209, i64 %211
store double %208, double* %212
br label %217
213: ; preds = %106, %89, %79, %72
br label %214
214: ; preds = %213
%215 = load i32, i32* %15
%216 = add nsw i32 %215, 1
store i32 %216, i32* %15
br label %52
217: ; preds = %188, %52
br label %218
218: ; preds = %217
%219 = load i32, i32* %12
%220 = add nsw i32 %219, 1
store i32 %220, i32* %12
%221 = load i32, i32* %13
%222 = add nsw i32 %221, 1
store i32 %222, i32* %13
br label %28
223: ; preds = %28
br label %224
224: ; preds = %223
%225 = load i32, i32* %11
%226 = add nsw i32 %225, 1
store i32 %226, i32* %11
br label %18
227: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@M_PI_2 = global double 0.000000e+00
@M_PI = global double 0.000000e+00
define i32 @G_math_findzc(double* nocapture %0, i32 %1, double* nocapture writeonly %2, double %3, i32 %4) {
%6 = add i32 %1, -1
%7 = icmp sgt i32 %1, 2
br i1 %7, label %8, label %162
8: ; preds = %5
%9 = sitofp i32 %4 to double
%10 = mul nsw i32 %4, 3
%11 = sdiv i32 %10, 4
%12 = add nuw i32 %1, 1
%13 = zext i32 %1 to i64
br label %14
14: ; preds = %158, %8
%15 = phi i32 [ %12, %8 ], [ %160, %158 ]
%16 = phi i32 [ 1, %8 ], [ %159, %158 ]
%17 = sext i32 %15 to i64
br label %18
18: ; preds = %14, %155
%19 = phi i64 [ %17, %14 ], [ %22, %155 ]
%20 = phi i32 [ 1, %14 ], [ %156, %155 ]
%21 = add nsw i64 %19, -1
%22 = add nsw i64 %19, 1
%23 = sub nsw i64 %19, %13
%24 = add nsw i64 %19, %13
%25 = getelementptr inbounds double, double* %2, i64 %19
store double 0.000000e+00, double* %25
%26 = getelementptr inbounds double, double* %0, i64 %19
%27 = load double, double* %26
%28 = fcmp ogt double %27, 0.000000e+00
%29 = fcmp olt double %27, 0.000000e+00
%30 = tail call double @llvm.fabs.f64(double %27)
br i1 %28, label %31, label %37
31: ; preds = %18
%32 = shl i64 %21, 32
%33 = ashr exact i64 %32, 32
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = load double, double* %34
%36 = fcmp olt double %35, 0.000000e+00
br i1 %36, label %44, label %37
37: ; preds = %31, %18
br i1 %29, label %38, label %89
38: ; preds = %37
%39 = shl i64 %21, 32
%40 = ashr exact i64 %39, 32
%41 = getelementptr inbounds double, double* %0, i64 %40
%42 = load double, double* %41
%43 = fcmp ogt double %42, 0.000000e+00
br i1 %43, label %44, label %89
44: ; preds = %38, %31
%45 = phi double [ %42, %38 ], [ %35, %31 ]
%46 = tail call double @llvm.fabs.f64(double %45)
%47 = fcmp olt double %30, %46
br i1 %47, label %48, label %89
48: ; preds = %44
%49 = fsub double %27, %45
%50 = tail call double @llvm.fabs.f64(double %49)
%51 = fcmp ogt double %50, %3
br i1 %51, label %52, label %89
52: ; preds = %151, %129, %107, %48
%53 = getelementptr inbounds double, double* %0, i64 %22
%54 = load double, double* %53
%55 = getelementptr inbounds double, double* %0, i64 %21
%56 = load double, double* %55
%57 = fsub double %54, %56
%58 = tail call double @llvm.fabs.f64(double %57)
%59 = fcmp olt double %58, 1.000000e-03
br i1 %59, label %60, label %70
60: ; preds = %52
%61 = load double, double* @M_PI_2
%62 = getelementptr inbounds double, double* %0, i64 %23
%63 = load double, double* %62
%64 = getelementptr inbounds double, double* %0, i64 %24
%65 = load double, double* %64
%66 = fsub double %63, %65
%67 = fcmp olt double %66, 0.000000e+00
br i1 %67, label %68, label %77
68: ; preds = %60
%69 = fneg double %61
br label %77
70: ; preds = %52
%71 = getelementptr inbounds double, double* %0, i64 %23
%72 = load double, double* %71
%73 = getelementptr inbounds double, double* %0, i64 %24
%74 = load double, double* %73
%75 = fsub double %72, %74
%76 = tail call double @atan2(double %75, double %57)
br label %77
77: ; preds = %60, %68, %70
%78 = phi double [ %69, %68 ], [ %61, %60 ], [ %76, %70 ]
%79 = load double, double* @M_PI
%80 = fadd double %78, %79
%81 = fmul double %79, 2.000000e+00
%82 = fdiv double %80, %81
%83 = tail call double @llvm.fmuladd.f64(double %9, double %82, double 4.999000e-01)
%84 = fptosi double %83 to i32
%85 = add nsw i32 %11, %84
%86 = srem i32 %85, %4
%87 = add nsw i32 %86, 1
%88 = sitofp i32 %87 to double
store double %88, double* %25
br label %155
89: ; preds = %37, %38, %44, %48
br i1 %28, label %90, label %96
90: ; preds = %89
%91 = shl i64 %22, 32
%92 = ashr exact i64 %91, 32
%93 = getelementptr inbounds double, double* %0, i64 %92
%94 = load double, double* %93
%95 = fcmp olt double %94, 0.000000e+00
br i1 %95, label %103, label %96
96: ; preds = %90, %89
br i1 %29, label %97, label %111
97: ; preds = %96
%98 = shl i64 %22, 32
%99 = ashr exact i64 %98, 32
%100 = getelementptr inbounds double, double* %0, i64 %99
%101 = load double, double* %100
%102 = fcmp ogt double %101, 0.000000e+00
br i1 %102, label %103, label %111
103: ; preds = %97, %90
%104 = phi double [ %101, %97 ], [ %94, %90 ]
%105 = tail call double @llvm.fabs.f64(double %104)
%106 = fcmp olt double %30, %105
br i1 %106, label %107, label %111
107: ; preds = %103
%108 = fsub double %27, %104
%109 = tail call double @llvm.fabs.f64(double %108)
%110 = fcmp ogt double %109, %3
br i1 %110, label %52, label %111
111: ; preds = %107, %103, %97, %96
br i1 %28, label %112, label %118
112: ; preds = %111
%113 = shl i64 %23, 32
%114 = ashr exact i64 %113, 32
%115 = getelementptr inbounds double, double* %0, i64 %114
%116 = load double, double* %115
%117 = fcmp olt double %116, 0.000000e+00
br i1 %117, label %125, label %118
118: ; preds = %112, %111
br i1 %29, label %119, label %133
119: ; preds = %118
%120 = shl i64 %23, 32
%121 = ashr exact i64 %120, 32
%122 = getelementptr inbounds double, double* %0, i64 %121
%123 = load double, double* %122
%124 = fcmp ogt double %123, 0.000000e+00
br i1 %124, label %125, label %133
125: ; preds = %119, %112
%126 = phi double [ %123, %119 ], [ %116, %112 ]
%127 = tail call double @llvm.fabs.f64(double %126)
%128 = fcmp olt double %30, %127
br i1 %128, label %129, label %133
129: ; preds = %125
%130 = fsub double %27, %126
%131 = tail call double @llvm.fabs.f64(double %130)
%132 = fcmp ogt double %131, %3
br i1 %132, label %52, label %133
133: ; preds = %129, %125, %119, %118
br i1 %28, label %134, label %140
134: ; preds = %133
%135 = shl i64 %24, 32
%136 = ashr exact i64 %135, 32
%137 = getelementptr inbounds double, double* %0, i64 %136
%138 = load double, double* %137
%139 = fcmp olt double %138, 0.000000e+00
br i1 %139, label %147, label %140
140: ; preds = %134, %133
br i1 %29, label %141, label %155
141: ; preds = %140
%142 = shl i64 %24, 32
%143 = ashr exact i64 %142, 32
%144 = getelementptr inbounds double, double* %0, i64 %143
%145 = load double, double* %144
%146 = fcmp ogt double %145, 0.000000e+00
br i1 %146, label %147, label %155
147: ; preds = %141, %134
%148 = phi double [ %145, %141 ], [ %138, %134 ]
%149 = tail call double @llvm.fabs.f64(double %148)
%150 = fcmp olt double %30, %149
br i1 %150, label %151, label %155
151: ; preds = %147
%152 = fsub double %27, %148
%153 = tail call double @llvm.fabs.f64(double %152)
%154 = fcmp ogt double %153, %3
br i1 %154, label %52, label %155
155: ; preds = %140, %141, %147, %151, %77
%156 = add nuw nsw i32 %20, 1
%157 = icmp eq i32 %156, %6
br i1 %157, label %158, label %18
158: ; preds = %155
%159 = add nuw nsw i32 %16, 1
%160 = add i32 %15, %1
%161 = icmp eq i32 %159, %6
br i1 %161, label %162, label %14
162: ; preds = %158, %5
ret i32 0
}