#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 sqrt(double);
void x1x2(double r, double cval, double d, double m1, double *x1, double *x2) {
  double m2;
  double sval;
  m2 = 1.0 - m1;
  if (m2 < 0.0)
    m2 = 0.0;
  if (cval < -1.0) {
    cval = -1.0;
    sval = 0.0;
  } else if (cval > 1.0) {
    cval = 1.0;
    sval = 0.0;
  } else
    sval = sqrt(1.0 - cval * cval);
  *x1 = r * cval - m2 * d;
  *x2 = r * sval;
}


x86 assembly (clang, -O0):
<x1x2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
movsd  0xec4(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    115c <x1x2+0x4c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xea4(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1189 <x1x2+0x79>
movsd  0xe91(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11fa <x1x2+0xea>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ba <x1x2+0xaa>
movsd  0xe58(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11f5 <x1x2+0xe5>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe19(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    11fa <x1x2+0xea>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x1x2>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movapd %xmm0,%xmm4
movsd  0xed7(%rip),%xmm5
movapd %xmm5,%xmm6
subsd  %xmm3,%xmm6
xorpd  %xmm3,%xmm3
movsd  0xecb(%rip),%xmm7
ucomisd %xmm1,%xmm7
xorpd  %xmm0,%xmm0
ja     11b6 <x1x2+0xa6>
ucomisd %xmm5,%xmm1
movapd %xmm5,%xmm7
xorpd  %xmm0,%xmm0
ja     11b6 <x1x2+0xa6>
movapd %xmm1,%xmm5
mulsd  %xmm1,%xmm5
movsd  0xe9b(%rip),%xmm0
subsd  %xmm5,%xmm0
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm0
jb     117d <x1x2+0x6d>
sqrtsd %xmm0,%xmm0
movapd %xmm1,%xmm7
jmp    11b6 <x1x2+0xa6>
movsd  %xmm4,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm6,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <sqrt@plt>
movsd  0x10(%rsp),%xmm6
xorpd  %xmm3,%xmm3
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm4
movsd  0x8(%rsp),%xmm7
maxsd  %xmm6,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm4,%xmm7
subsd  %xmm3,%xmm7
movsd  %xmm7,(%rbx)
mulsd  %xmm4,%xmm0
movsd  %xmm0,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @x1x2(double %0, double %1, double %2, double %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
%14 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double* %4, double** %11
store double* %5, double** %12
%15 = load double, double* %10
%16 = fsub double 1.000000e+00, %15
store double %16, double* %13
%17 = load double, double* %13
%18 = fcmp olt double %17, 0.000000e+00
br i1 %18, label %19, label %20
19: ; preds = %6
store double 0.000000e+00, double* %13
br label %20
20: ; preds = %19, %6
%21 = load double, double* %8
%22 = fcmp olt double %21, -1.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %20
store double -1.000000e+00, double* %8
store double 0.000000e+00, double* %14
br label %35
24: ; preds = %20
%25 = load double, double* %8
%26 = fcmp ogt double %25, 1.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %24
store double 1.000000e+00, double* %8
store double 0.000000e+00, double* %14
br label %34
28: ; preds = %24
%29 = load double, double* %8
%30 = load double, double* %8
%31 = fneg double %29
%32 = call double @llvm.fmuladd.f64(double %31, double %30, double 1.000000e+00)
%33 = call double @sqrt(double %32)
store double %33, double* %14
br label %34
34: ; preds = %28, %27
br label %35
35: ; preds = %34, %23
%36 = load double, double* %7
%37 = load double, double* %8
%38 = load double, double* %13
%39 = load double, double* %9
%40 = fmul double %38, %39
%41 = fneg double %40
%42 = call double @llvm.fmuladd.f64(double %36, double %37, double %41)
%43 = load double*, double** %11
store double %42, double* %43
%44 = load double, double* %7
%45 = load double, double* %14
%46 = fmul double %44, %45
%47 = load double*, double** %12
store double %46, double* %47
ret void
}

LLVM IR (-O2):
define void @x1x2(double %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = fsub double 1.000000e+00, %3
%8 = fcmp olt double %1, -1.000000e+00
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = fcmp ogt double %1, 1.000000e+00
br i1 %10, label %15, label %11
11: ; preds = %9
%12 = fneg double %1
%13 = tail call double @llvm.fmuladd.f64(double %12, double %1, double 1.000000e+00)
%14 = tail call double @sqrt(double %13)
br label %15
15: ; preds = %9, %6, %11
%16 = phi double [ %1, %11 ], [ -1.000000e+00, %6 ], [ 1.000000e+00, %9 ]
%17 = phi double [ %14, %11 ], [ 0.000000e+00, %6 ], [ 0.000000e+00, %9 ]
%18 = fcmp olt double %7, 0.000000e+00
%19 = select i1 %18, double 0.000000e+00, double %7
%20 = fneg double %19
%21 = fmul double %20, %2
%22 = tail call double @llvm.fmuladd.f64(double %0, double %16, double %21)
store double %22, double* %4
%23 = fmul double %17, %0
store double %23, double* %5
ret void
}