#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 fabs(double);
double mchpr1();
double initialStep(double fnew, double fmin, double gtp, double smax) {
  double d, alpha;
  d = fabs(fnew - fmin);
  alpha = 1.0;
  if (d * 2.0 <= -(gtp) && d >= mchpr1())
    alpha = d * -2.0 / gtp;
  if (alpha >= smax)
    alpha = smax;
  return alpha;
}


x86 assembly (clang, -O0):
<initialStep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xee3(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeba(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xea5(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jb     11c0 <initialStep+0xb0>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1030 <mchpr1@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11c0 <initialStep+0xb0>
movsd  0xe5f(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11da <initialStep+0xca>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialStep>:
sub    $0x38,%rsp
subsd  %xmm1,%xmm0
andpd  0xee0(%rip),%xmm0
movapd %xmm0,%xmm4
addsd  %xmm0,%xmm4
movapd 0xee0(%rip),%xmm1
xorpd  %xmm2,%xmm1
movsd  0xee4(%rip),%xmm5
ucomisd %xmm4,%xmm1
jb     1184 <initialStep+0x74>
movapd %xmm2,(%rsp)
xor    %eax,%eax
movaps %xmm3,0x20(%rsp)
movapd %xmm0,0x10(%rsp)
call   1030 <mchpr1@plt>
movsd  0xebf(%rip),%xmm5
movapd 0x10(%rsp),%xmm1
movapd 0x20(%rsp),%xmm3
ucomisd %xmm0,%xmm1
jb     1184 <initialStep+0x74>
mulsd  0xead(%rip),%xmm1
divsd  (%rsp),%xmm1
movapd %xmm1,%xmm5
movapd %xmm3,%xmm0
cmplesd %xmm5,%xmm0
andpd  %xmm0,%xmm3
andnpd %xmm5,%xmm0
orpd   %xmm3,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @initialStep(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%11 = load double, double* %5
%12 = load double, double* %6
%13 = fsub double %11, %12
%14 = call double @llvm.fabs.f64(double %13)
store double %14, double* %9
store double 1.000000e+00, double* %10
%15 = load double, double* %9
%16 = fmul double %15, 2.000000e+00
%17 = load double, double* %7
%18 = fneg double %17
%19 = fcmp ole double %16, %18
br i1 %19, label %20, label %29
20: ; preds = %4
%21 = load double, double* %9
%22 = call double (...) @mchpr1()
%23 = fcmp oge double %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load double, double* %9
%26 = fmul double %25, -2.000000e+00
%27 = load double, double* %7
%28 = fdiv double %26, %27
store double %28, double* %10
br label %29
29: ; preds = %24, %20, %4
%30 = load double, double* %10
%31 = load double, double* %8
%32 = fcmp oge double %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load double, double* %8
store double %34, double* %10
br label %35
35: ; preds = %33, %29
%36 = load double, double* %10
ret double %36
}

LLVM IR (-O2):
define double @initialStep(double %0, double %1, double %2, double %3) {
%5 = fsub double %0, %1
%6 = tail call double @llvm.fabs.f64(double %5)
%7 = fmul double %6, 2.000000e+00
%8 = fneg double %2
%9 = fcmp ugt double %7, %8
br i1 %9, label %16, label %10
10: ; preds = %4
%11 = tail call double (...) @mchpr1()
%12 = fcmp ult double %6, %11
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = fmul double %6, -2.000000e+00
%15 = fdiv double %14, %2
br label %16
16: ; preds = %13, %10, %4
%17 = phi double [ %15, %13 ], [ 1.000000e+00, %10 ], [ 1.000000e+00, %4 ]
%18 = fcmp oge double %17, %3
%19 = select i1 %18, double %3, double %17
ret double %19
}