#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 validate_x(double x[2], double x0[2]) {
  double dv = 1.e-15;
  x[0] = fabs(x[0]);
  x[0] = (x[0] > 1.e9) ? x0[0] : x[0];
  x[1] = (x[1] < 0.) ? dv : x[1];
  x[1] = (x[1] > 1.) ? (1. - dv) : x[1];
  return;
}


x86 assembly (clang, -O0):
<validate_x>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xef4(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xef8(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xebc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1160 <validate_x+0x60>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    116d <validate_x+0x6d>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x8(%rax),%xmm0
jbe    119b <validate_x+0x9b>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11a9 <validate_x+0xa9>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  0xe48(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e9 <validate_x+0xe9>
movsd  0xe36(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11f7 <validate_x+0xf7>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_x>:
movsd  (%rdi),%xmm0
andpd  0xef4(%rip),%xmm0
movlpd %xmm0,(%rdi)
ucomisd 0xef8(%rip),%xmm0
jbe    111e <validate_x+0x1e>
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdi)
movsd  0x8(%rdi),%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm2
cmpltsd %xmm1,%xmm2
movsd  0xedc(%rip),%xmm1
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
movsd  0xed0(%rip),%xmm0
cmpltsd %xmm2,%xmm0
movsd  0xecb(%rip),%xmm1
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm0,%xmm1
movlpd %xmm1,0x8(%rdi)
ret

LLVM IR (-O0):
define void @validate_x(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
store double* %0, double** %3
store double* %1, double** %4
store double 1.000000e-15, double* %5
%6 = load double*, double** %3
%7 = getelementptr inbounds double, double* %6, i64 0
%8 = load double, double* %7
%9 = call double @llvm.fabs.f64(double %8)
%10 = load double*, double** %3
%11 = getelementptr inbounds double, double* %10, i64 0
store double %9, double* %11
%12 = load double*, double** %3
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
%15 = fcmp ogt double %14, 1.000000e+09
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
br label %24
20: ; preds = %2
%21 = load double*, double** %3
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
br label %24
24: ; preds = %20, %16
%25 = phi double [ %19, %16 ], [ %23, %20 ]
%26 = load double*, double** %3
%27 = getelementptr inbounds double, double* %26, i64 0
store double %25, double* %27
%28 = load double*, double** %3
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = fcmp olt double %30, 0.000000e+00
br i1 %31, label %32, label %34
32: ; preds = %24
%33 = load double, double* %5
br label %38
34: ; preds = %24
%35 = load double*, double** %3
%36 = getelementptr inbounds double, double* %35, i64 1
%37 = load double, double* %36
br label %38
38: ; preds = %34, %32
%39 = phi double [ %33, %32 ], [ %37, %34 ]
%40 = load double*, double** %3
%41 = getelementptr inbounds double, double* %40, i64 1
store double %39, double* %41
%42 = load double*, double** %3
%43 = getelementptr inbounds double, double* %42, i64 1
%44 = load double, double* %43
%45 = fcmp ogt double %44, 1.000000e+00
br i1 %45, label %46, label %49
46: ; preds = %38
%47 = load double, double* %5
%48 = fsub double 1.000000e+00, %47
br label %53
49: ; preds = %38
%50 = load double*, double** %3
%51 = getelementptr inbounds double, double* %50, i64 1
%52 = load double, double* %51
br label %53
53: ; preds = %49, %46
%54 = phi double [ %48, %46 ], [ %52, %49 ]
%55 = load double*, double** %3
%56 = getelementptr inbounds double, double* %55, i64 1
store double %54, double* %56
ret void
}

LLVM IR (-O2):
define void @validate_x(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = tail call double @llvm.fabs.f64(double %3)
store double %4, double* %0
%5 = fcmp ogt double %4, 1.000000e+09
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = load double, double* %1
br label %8
8: ; preds = %2, %6
%9 = phi double [ %7, %6 ], [ %4, %2 ]
store double %9, double* %0
%10 = getelementptr inbounds double, double* %0, i64 1
%11 = load double, double* %10
%12 = fcmp olt double %11, 0.000000e+00
%13 = select i1 %12, double 1.000000e-15, double %11
%14 = fcmp ogt double %13, 1.000000e+00
%15 = select i1 %14, double 0x3FEFFFFFFFFFFFF7, double %13
store double %15, double* %10
ret void
}