#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 acos(double);
double exp(double);
double fabs(double);
double ntail(double);
double sqrt(int);
double znewt(double z, double ptail) {
  double p0, pder, h;
  double pi, zz;
  int iter;
  pi = 2.0 * acos(0.0);
  zz = z;
  for (iter = 1; iter <= 5; ++iter) {
    p0 = ntail(zz);
    pder = -exp(-0.5 * zz * zz) / sqrt(2 * pi);
    if (pder == 0.0)
      return zz;
    h = (ptail - p0) / pder;
    if (fabs(h) <= 1.0e-10)
      return zz;
    zz += h;
  }
  return zz;
}


x86 assembly (clang, -O0):
<znewt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
call   1040 <acos@plt>
movaps %xmm0,%xmm1
movsd  0xe9b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jg     127b <znewt+0x13b>
movsd  -0x40(%rbp),%xmm0
call   1030 <ntail@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe68(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
call   1050 <exp@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe2d(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1219 <znewt+0xd9>
jp     1219 <znewt+0xd9>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1285 <znewt+0x145>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movaps 0xde7(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xdcb(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     125e <znewt+0x11e>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1285 <znewt+0x145>
movsd  -0x30(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    117f <znewt+0x3f>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<znewt>:
sub    $0x48,%rsp
movaps %xmm1,0x30(%rsp)
movsd  %xmm0,(%rsp)
call   1030 <ntail@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xeaf(%rip),%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
xorpd  0xea5(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1195 <znewt+0x65>
jnp    1225 <znewt+0xf5>
movapd 0x30(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
divsd  %xmm1,%xmm0
movapd 0xe73(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xe4f(%rip),%xmm2
ucomisd %xmm1,%xmm2
jae    1225 <znewt+0xf5>
addsd  (%rsp),%xmm0
movapd %xmm0,(%rsp)
call   1030 <ntail@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xe24(%rip),%xmm0
movapd (%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
xorpd  0xe1a(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    122f <znewt+0xff>
jp     122f <znewt+0xff>
movaps (%rsp),%xmm0
add    $0x48,%rsp
ret
movsd  (%rsp),%xmm0
add    $0x48,%rsp
ret
movapd (%rsp),%xmm2
movapd 0x30(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
divsd  %xmm1,%xmm0
movapd 0xdd4(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xdb0(%rip),%xmm3
ucomisd %xmm1,%xmm3
jae    142b <znewt+0x2fb>
addsd  %xmm0,%xmm2
movapd %xmm2,(%rsp)
movapd %xmm2,%xmm0
call   1030 <ntail@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xd7e(%rip),%xmm0
movapd (%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
xorpd  0xd74(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    12c6 <znewt+0x196>
jnp    121c <znewt+0xec>
movapd (%rsp),%xmm2
movapd 0x30(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
divsd  %xmm1,%xmm0
movapd 0xd3d(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xd19(%rip),%xmm3
ucomisd %xmm1,%xmm3
jae    142b <znewt+0x2fb>
addsd  %xmm0,%xmm2
movapd %xmm2,(%rsp)
movapd %xmm2,%xmm0
call   1030 <ntail@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xce7(%rip),%xmm0
movapd (%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
xorpd  0xcdd(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    135d <znewt+0x22d>
jnp    121c <znewt+0xec>
movapd (%rsp),%xmm2
movapd 0x30(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
divsd  %xmm1,%xmm0
movapd 0xca6(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xc82(%rip),%xmm3
ucomisd %xmm1,%xmm3
jae    142b <znewt+0x2fb>
addsd  %xmm0,%xmm2
movapd %xmm2,(%rsp)
movapd %xmm2,%xmm0
call   1030 <ntail@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xc50(%rip),%xmm0
movapd (%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
xorpd  0xc46(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    13f4 <znewt+0x2c4>
jnp    121c <znewt+0xec>
movapd %xmm1,%xmm0
movapd (%rsp),%xmm2
movapd 0x30(%rsp),%xmm1
subsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd 0xc0b(%rip),%xmm0
andpd  %xmm1,%xmm0
movsd  0xbe7(%rip),%xmm3
ucomisd %xmm0,%xmm3
jae    142b <znewt+0x2fb>
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @znewt(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
store double %0, double* %4
store double %1, double* %5
%12 = call double @acos(double 0.000000e+00)
%13 = fmul double 2.000000e+00, %12
store double %13, double* %9
%14 = load double, double* %4
store double %14, double* %10
store i32 1, i32* %11
br label %15
15: ; preds = %51, %2
%16 = load i32, i32* %11
%17 = icmp sle i32 %16, 5
br i1 %17, label %18, label %54
18: ; preds = %15
%19 = load double, double* %10
%20 = call double @ntail(double %19)
store double %20, double* %6
%21 = load double, double* %10
%22 = fmul double -5.000000e-01, %21
%23 = load double, double* %10
%24 = fmul double %22, %23
%25 = call double @exp(double %24)
%26 = fneg double %25
%27 = load double, double* %9
%28 = fmul double 2.000000e+00, %27
%29 = fptosi double %28 to i32
%30 = call double @sqrt(i32 %29)
%31 = fdiv double %26, %30
store double %31, double* %7
%32 = load double, double* %7
%33 = fcmp oeq double %32, 0.000000e+00
br i1 %33, label %34, label %36
34: ; preds = %18
%35 = load double, double* %10
store double %35, double* %3
br label %56
36: ; preds = %18
%37 = load double, double* %5
%38 = load double, double* %6
%39 = fsub double %37, %38
%40 = load double, double* %7
%41 = fdiv double %39, %40
store double %41, double* %8
%42 = load double, double* %8
%43 = call double @llvm.fabs.f64(double %42)
%44 = fcmp ole double %43, 1.000000e-10
br i1 %44, label %45, label %47
45: ; preds = %36
%46 = load double, double* %10
store double %46, double* %3
br label %56
47: ; preds = %36
%48 = load double, double* %8
%49 = load double, double* %10
%50 = fadd double %49, %48
store double %50, double* %10
br label %51
51: ; preds = %47
%52 = load i32, i32* %11
%53 = add nsw i32 %52, 1
store i32 %53, i32* %11
br label %15
54: ; preds = %15
%55 = load double, double* %10
store double %55, double* %3
br label %56
56: ; preds = %54, %45, %34
%57 = load double, double* %3
ret double %57
}

LLVM IR (-O2):
define double @znewt(double %0, double %1) {
%3 = tail call double @ntail(double %0)
%4 = fmul double %0, -5.000000e-01
%5 = fmul double %4, %0
%6 = tail call double @exp(double %5)
%7 = fneg double %6
%8 = tail call double @sqrt(i32 6)
%9 = fdiv double %7, %8
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %78, label %11
11: ; preds = %2
%12 = fsub double %1, %3
%13 = fdiv double %12, %9
%14 = tail call double @llvm.fabs.f64(double %13)
%15 = fcmp ugt double %14, 1.000000e-10
br i1 %15, label %16, label %78
16: ; preds = %11
%17 = fadd double %13, %0
%18 = tail call double @ntail(double %17)
%19 = fmul double %17, -5.000000e-01
%20 = fmul double %17, %19
%21 = tail call double @exp(double %20)
%22 = fneg double %21
%23 = tail call double @sqrt(i32 6)
%24 = fdiv double %22, %23
%25 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %78, label %26
26: ; preds = %16
%27 = fsub double %1, %18
%28 = fdiv double %27, %24
%29 = tail call double @llvm.fabs.f64(double %28)
%30 = fcmp ugt double %29, 1.000000e-10
br i1 %30, label %31, label %78
31: ; preds = %26
%32 = fadd double %17, %28
%33 = tail call double @ntail(double %32)
%34 = fmul double %32, -5.000000e-01
%35 = fmul double %32, %34
%36 = tail call double @exp(double %35)
%37 = fneg double %36
%38 = tail call double @sqrt(i32 6)
%39 = fdiv double %37, %38
%40 = fcmp oeq double %39, 0.000000e+00
br i1 %40, label %78, label %41
41: ; preds = %31
%42 = fsub double %1, %33
%43 = fdiv double %42, %39
%44 = tail call double @llvm.fabs.f64(double %43)
%45 = fcmp ugt double %44, 1.000000e-10
br i1 %45, label %46, label %78
46: ; preds = %41
%47 = fadd double %32, %43
%48 = tail call double @ntail(double %47)
%49 = fmul double %47, -5.000000e-01
%50 = fmul double %47, %49
%51 = tail call double @exp(double %50)
%52 = fneg double %51
%53 = tail call double @sqrt(i32 6)
%54 = fdiv double %52, %53
%55 = fcmp oeq double %54, 0.000000e+00
br i1 %55, label %78, label %56
56: ; preds = %46
%57 = fsub double %1, %48
%58 = fdiv double %57, %54
%59 = tail call double @llvm.fabs.f64(double %58)
%60 = fcmp ugt double %59, 1.000000e-10
br i1 %60, label %61, label %78
61: ; preds = %56
%62 = fadd double %47, %58
%63 = tail call double @ntail(double %62)
%64 = fmul double %62, -5.000000e-01
%65 = fmul double %62, %64
%66 = tail call double @exp(double %65)
%67 = fneg double %66
%68 = tail call double @sqrt(i32 6)
%69 = fdiv double %67, %68
%70 = fcmp oeq double %69, 0.000000e+00
br i1 %70, label %78, label %71
71: ; preds = %61
%72 = fsub double %1, %63
%73 = fdiv double %72, %69
%74 = tail call double @llvm.fabs.f64(double %73)
%75 = fcmp ugt double %74, 1.000000e-10
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = fadd double %62, %73
br label %78
78: ; preds = %76, %71, %61, %56, %46, %41, %31, %26, %16, %11, %2
%79 = phi double [ %0, %11 ], [ %0, %2 ], [ %17, %16 ], [ %17, %26 ], [ %32, %31 ], [ %32, %41 ], [ %47, %46 ], [ %47, %56 ], [ %62, %61 ], [ %62, %71 ], [ %77, %76 ]
ret double %79
}