#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 dg_dy(double, double);
double fabs(double);
double g(double, double);
double compute_boundary_y(double x0, double y) {
  for (size_t k = 0; k < 10; ++k) {
    double dy = -g(x0, y) / dg_dy(x0, y);
    if (fabs(dy) < 1.0e-15)
      break;
    y += dy;
  }
  return y;
}


x86 assembly (clang, -O0):
<compute_boundary_y>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0xa,-0x18(%rbp)
jae    11d7 <compute_boundary_y+0xb7>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <g@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <dg_dy@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movaps 0xe74(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe58(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b7 <compute_boundary_y+0x97>
jmp    11d7 <compute_boundary_y+0xb7>
movsd  -0x20(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113a <compute_boundary_y+0x1a>
movsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_boundary_y>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%ebx
movsd  0x8(%rsp),%xmm0
movsd  %xmm1,(%rsp)
call   1030 <g@plt>
xorps  0xeb9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1040 <dg_dy@plt>
movapd 0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
andpd  0xe9e(%rip),%xmm0
movsd  0xea6(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1191 <compute_boundary_y+0x71>
movsd  (%rsp),%xmm1
addsd  %xmm2,%xmm1
add    $0xffffffffffffffff,%rbx
jne    1130 <compute_boundary_y+0x10>
jmp    1196 <compute_boundary_y+0x76>
movsd  (%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @compute_boundary_y(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i64
%6 = alloca double
store double %0, double* %3
store double %1, double* %4
store i64 0, i64* %5
br label %7
7: ; preds = %27, %2
%8 = load i64, i64* %5
%9 = icmp ult i64 %8, 10
br i1 %9, label %10, label %30
10: ; preds = %7
%11 = load double, double* %3
%12 = load double, double* %4
%13 = call double @g(double %11, double %12)
%14 = fneg double %13
%15 = load double, double* %3
%16 = load double, double* %4
%17 = call double @dg_dy(double %15, double %16)
%18 = fdiv double %14, %17
store double %18, double* %6
%19 = load double, double* %6
%20 = call double @llvm.fabs.f64(double %19)
%21 = fcmp olt double %20, 1.000000e-15
br i1 %21, label %22, label %23
22: ; preds = %10
br label %30
23: ; preds = %10
%24 = load double, double* %6
%25 = load double, double* %4
%26 = fadd double %25, %24
store double %26, double* %4
br label %27
27: ; preds = %23
%28 = load i64, i64* %5
%29 = add i64 %28, 1
store i64 %29, i64* %5
br label %7
30: ; preds = %22, %7
%31 = load double, double* %4
ret double %31
}

LLVM IR (-O2):
define double @compute_boundary_y(double %0, double %1) {
br label %3
3: ; preds = %2, %12
%4 = phi double [ %1, %2 ], [ %13, %12 ]
%5 = phi i64 [ 0, %2 ], [ %14, %12 ]
%6 = tail call double @g(double %0, double %4)
%7 = fneg double %6
%8 = tail call double @dg_dy(double %0, double %4)
%9 = fdiv double %7, %8
%10 = tail call double @llvm.fabs.f64(double %9)
%11 = fcmp olt double %10, 1.000000e-15
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = fadd double %4, %9
%14 = add nuw nsw i64 %5, 1
%15 = icmp eq i64 %14, 10
br i1 %15, label %16, label %3
16: ; preds = %12, %3
%17 = phi double [ %13, %12 ], [ %4, %3 ]
ret double %17
}