#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);
void check_val(double *x1, double *x2, double *xb, double *xd) {
  double temp;
  if (*x1 == *x2) {
    temp = .05 * ((fabs(*x1) > 1.0) ? fabs(*x1) : 1.0);
    *x1 = *x1 - temp;
    *x2 = *x2 + temp;
  }
  if (*x1 > *x2) {
    temp = *x2;
    *x2 = *x1;
    *x1 = temp;
  }
  *xb = .5 * (*x1 + *x2);
  *xd = 2.0 / (*x2 - *x1);
}


x86 assembly (clang, -O0):
<check_val>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
ucomisd (%rax),%xmm0
jne    11c4 <check_val+0xc4>
jp     11c4 <check_val+0xc4>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xee1(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xeb5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1172 <check_val+0x72>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xebc(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1184 <check_val+0x84>
movsd  0xe86(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1184 <check_val+0x84>
movsd  -0x30(%rbp),%xmm1
movsd  0xe77(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    1204 <check_val+0x104>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm1
movsd  0xdfc(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm1
movsd  0xdd0(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_val>:
movsd  (%rdi),%xmm0
movsd  (%rsi),%xmm1
ucomisd %xmm1,%xmm0
jne    1159 <check_val+0x59>
jp     1159 <check_val+0x59>
movapd 0xee8(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xeec(%rip),%xmm2
movsd  0xeec(%rip),%xmm3
cmpltsd %xmm1,%xmm3
mulsd  %xmm2,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm3
orpd   %xmm1,%xmm3
subsd  %xmm3,%xmm0
movsd  %xmm0,(%rdi)
movsd  (%rsi),%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm1,(%rsi)
movsd  (%rdi),%xmm0
ucomisd %xmm1,%xmm0
jbe    116d <check_val+0x6d>
movsd  %xmm0,(%rsi)
movsd  %xmm1,(%rdi)
movsd  (%rsi),%xmm2
jmp    1175 <check_val+0x75>
movapd %xmm1,%xmm2
movapd %xmm0,%xmm1
addsd  %xmm1,%xmm2
mulsd  0xe9f(%rip),%xmm2
movsd  %xmm2,(%rdx)
movsd  (%rsi),%xmm0
subsd  (%rdi),%xmm0
movsd  0xe93(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rcx)
ret

LLVM IR (-O0):
define void @check_val(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%10 = load double*, double** %5
%11 = load double, double* %10
%12 = load double*, double** %6
%13 = load double, double* %12
%14 = fcmp oeq double %11, %13
br i1 %14, label %15, label %38
15: ; preds = %4
%16 = load double*, double** %5
%17 = load double, double* %16
%18 = call double @llvm.fabs.f64(double %17)
%19 = fcmp ogt double %18, 1.000000e+00
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load double*, double** %5
%22 = load double, double* %21
%23 = call double @llvm.fabs.f64(double %22)
br label %25
24: ; preds = %15
br label %25
25: ; preds = %24, %20
%26 = phi double [ %23, %20 ], [ 1.000000e+00, %24 ]
%27 = fmul double 5.000000e-02, %26
store double %27, double* %9
%28 = load double*, double** %5
%29 = load double, double* %28
%30 = load double, double* %9
%31 = fsub double %29, %30
%32 = load double*, double** %5
store double %31, double* %32
%33 = load double*, double** %6
%34 = load double, double* %33
%35 = load double, double* %9
%36 = fadd double %34, %35
%37 = load double*, double** %6
store double %36, double* %37
br label %38
38: ; preds = %25, %4
%39 = load double*, double** %5
%40 = load double, double* %39
%41 = load double*, double** %6
%42 = load double, double* %41
%43 = fcmp ogt double %40, %42
br i1 %43, label %44, label %52
44: ; preds = %38
%45 = load double*, double** %6
%46 = load double, double* %45
store double %46, double* %9
%47 = load double*, double** %5
%48 = load double, double* %47
%49 = load double*, double** %6
store double %48, double* %49
%50 = load double, double* %9
%51 = load double*, double** %5
store double %50, double* %51
br label %52
52: ; preds = %44, %38
%53 = load double*, double** %5
%54 = load double, double* %53
%55 = load double*, double** %6
%56 = load double, double* %55
%57 = fadd double %54, %56
%58 = fmul double 5.000000e-01, %57
%59 = load double*, double** %7
store double %58, double* %59
%60 = load double*, double** %6
%61 = load double, double* %60
%62 = load double*, double** %5
%63 = load double, double* %62
%64 = fsub double %61, %63
%65 = fdiv double 2.000000e+00, %64
%66 = load double*, double** %8
store double %65, double* %66
ret void
}

LLVM IR (-O2):
define void @check_val(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = load double, double* %0
%6 = load double, double* %1
%7 = fcmp oeq double %5, %6
br i1 %7, label %8, label %17
8: ; preds = %4
%9 = tail call double @llvm.fabs.f64(double %5)
%10 = fcmp ogt double %9, 1.000000e+00
%11 = fmul double %9, 5.000000e-02
%12 = select i1 %10, double %11, double 5.000000e-02
%13 = fsub double %5, %12
store double %13, double* %0
%14 = load double, double* %1
%15 = fadd double %12, %14
store double %15, double* %1
%16 = load double, double* %0
br label %17
17: ; preds = %8, %4
%18 = phi double [ %15, %8 ], [ %6, %4 ]
%19 = phi double [ %16, %8 ], [ %5, %4 ]
%20 = fcmp ogt double %19, %18
br i1 %20, label %21, label %23
21: ; preds = %17
store double %19, double* %1
store double %18, double* %0
%22 = load double, double* %1
br label %23
23: ; preds = %21, %17
%24 = phi double [ %22, %21 ], [ %18, %17 ]
%25 = phi double [ %18, %21 ], [ %19, %17 ]
%26 = fadd double %25, %24
%27 = fmul double %26, 5.000000e-01
store double %27, double* %2
%28 = load double, double* %1
%29 = load double, double* %0
%30 = fsub double %28, %29
%31 = fdiv double 2.000000e+00, %30
store double %31, double* %3
ret void
}