#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 mod2pi(double);
double my_atan2(double, int);
int sqrt(double);
double csc2_ca(double x, double y, double phi, double rs, double rc, double *t,
               double *u, double *v) {
  double a, b, u1, theta, alpha, length_rs;
  a = x - rs;
  b = y + rc;
  u1 = sqrt(a * a + b * b);
  if (u1 < (2 * (1.0)))
    return (10000);
  theta = my_atan2(b, a);
  *u = sqrt(u1 * u1 - (4 * (1.0) * (1.0))) - (2 * (1.0));
  if (*u < 0.0)
    return (10000);
  alpha = my_atan2((*u + (2 * (1.0))), (2 * (1.0)));
  *t = mod2pi(1.5707963268 + theta - alpha);
  *v = mod2pi(*t - 1.5707963268 - phi);
  length_rs = (1.0) * (*t + 1.5707963268 + *v) + *u;
  return (length_rs);
}


x86 assembly (clang, -O0):
<csc2_ca>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
mov    %rdi,-0x38(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdx,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe50(%rip),%xmm0
ucomisd -0x60(%rbp),%xmm0
jbe    11cd <csc2_ca+0x9d>
movsd  0xe55(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d2 <csc2_ca+0x1a2>
movsd  -0x58(%rbp),%xmm0
cvttsd2si -0x50(%rbp),%edi
call   1040 <my_atan2@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe11(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  0xdf4(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    123b <csc2_ca+0x10b>
movsd  0xde7(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d2 <csc2_ca+0x1a2>
mov    -0x40(%rbp),%rax
movsd  0xdb9(%rip),%xmm0
addsd  (%rax),%xmm0
mov    $0x2,%edi
call   1040 <my_atan2@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  0xdae(%rip),%xmm0
addsd  -0x68(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
call   1030 <mod2pi@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xd87(%rip),%xmm1
subsd  %xmm1,%xmm0
subsd  -0x20(%rbp),%xmm0
call   1030 <mod2pi@plt>
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  0xd65(%rip),%xmm0
addsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
addsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csc2_ca>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  %xmm2,0x10(%rsp)
subsd  %xmm3,%xmm0
addsd  %xmm4,%xmm1
movsd  %xmm1,(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm0,0x18(%rsp)
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  0xe8c(%rip),%xmm1
cmp    $0x2,%eax
jl     1239 <csc2_ca+0x109>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
cvttsd2si 0x18(%rsp),%edi
movsd  (%rsp),%xmm0
call   1040 <my_atan2@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  0xe57(%rip),%xmm0
call   1050 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xe4b(%rip),%xmm0
movsd  %xmm0,(%rbx)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
movsd  0xe27(%rip),%xmm1
ja     1239 <csc2_ca+0x109>
addsd  0xe35(%rip),%xmm0
mov    $0x2,%edi
call   1040 <my_atan2@plt>
movsd  (%rsp),%xmm1
addsd  0xe26(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <mod2pi@plt>
movsd  %xmm0,(%r14)
addsd  0xe14(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
call   1030 <mod2pi@plt>
movsd  0xdf9(%rip),%xmm1
movsd  %xmm0,(%r15)
addsd  (%r14),%xmm1
addsd  %xmm0,%xmm1
addsd  (%rbx),%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @csc2_ca(double %0, double %1, double %2, double %3, double %4, double* %5, double* %6, double* %7) {
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store double %0, double* %10
store double %1, double* %11
store double %2, double* %12
store double %3, double* %13
store double %4, double* %14
store double* %5, double** %15
store double* %6, double** %16
store double* %7, double** %17
%24 = load double, double* %10
%25 = load double, double* %13
%26 = fsub double %24, %25
store double %26, double* %18
%27 = load double, double* %11
%28 = load double, double* %14
%29 = fadd double %27, %28
store double %29, double* %19
%30 = load double, double* %18
%31 = load double, double* %18
%32 = load double, double* %19
%33 = load double, double* %19
%34 = fmul double %32, %33
%35 = call double @llvm.fmuladd.f64(double %30, double %31, double %34)
%36 = call i32 @sqrt(double %35)
%37 = sitofp i32 %36 to double
store double %37, double* %20
%38 = load double, double* %20
%39 = fcmp olt double %38, 2.000000e+00
br i1 %39, label %40, label %41
40: ; preds = %8
store double 1.000000e+04, double* %9
br label %85
41: ; preds = %8
%42 = load double, double* %19
%43 = load double, double* %18
%44 = fptosi double %43 to i32
%45 = call double @my_atan2(double %42, i32 %44)
store double %45, double* %21
%46 = load double, double* %20
%47 = load double, double* %20
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double -4.000000e+00)
%49 = call i32 @sqrt(double %48)
%50 = sitofp i32 %49 to double
%51 = fsub double %50, 2.000000e+00
%52 = load double*, double** %16
store double %51, double* %52
%53 = load double*, double** %16
%54 = load double, double* %53
%55 = fcmp olt double %54, 0.000000e+00
br i1 %55, label %56, label %57
56: ; preds = %41
store double 1.000000e+04, double* %9
br label %85
57: ; preds = %41
%58 = load double*, double** %16
%59 = load double, double* %58
%60 = fadd double %59, 2.000000e+00
%61 = call double @my_atan2(double %60, i32 2)
store double %61, double* %22
%62 = load double, double* %21
%63 = fadd double 0x3FF921FB544486E0, %62
%64 = load double, double* %22
%65 = fsub double %63, %64
%66 = call double @mod2pi(double %65)
%67 = load double*, double** %15
store double %66, double* %67
%68 = load double*, double** %15
%69 = load double, double* %68
%70 = fsub double %69, 0x3FF921FB544486E0
%71 = load double, double* %12
%72 = fsub double %70, %71
%73 = call double @mod2pi(double %72)
%74 = load double*, double** %17
store double %73, double* %74
%75 = load double*, double** %15
%76 = load double, double* %75
%77 = fadd double %76, 0x3FF921FB544486E0
%78 = load double*, double** %17
%79 = load double, double* %78
%80 = fadd double %77, %79
%81 = load double*, double** %16
%82 = load double, double* %81
%83 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %80, double %82)
store double %83, double* %23
%84 = load double, double* %23
store double %84, double* %9
br label %85
85: ; preds = %57, %56, %40
%86 = load double, double* %9
ret double %86
}

LLVM IR (-O2):
define double @csc2_ca(double %0, double %1, double %2, double %3, double %4, double* nocapture %5, double* nocapture %6, double* nocapture writeonly %7) {
%9 = fsub double %0, %3
%10 = fadd double %1, %4
%11 = fmul double %10, %10
%12 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %11)
%13 = tail call i32 @sqrt(double %12)
%14 = icmp slt i32 %13, 2
br i1 %14, label %38, label %15
15: ; preds = %8
%16 = sitofp i32 %13 to double
%17 = fptosi double %9 to i32
%18 = tail call double @my_atan2(double %10, i32 %17)
%19 = tail call double @llvm.fmuladd.f64(double %16, double %16, double -4.000000e+00)
%20 = tail call i32 @sqrt(double %19)
%21 = sitofp i32 %20 to double
%22 = fadd double %21, -2.000000e+00
store double %22, double* %6
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %38, label %24
24: ; preds = %15
%25 = fadd double %22, 2.000000e+00
%26 = tail call double @my_atan2(double %25, i32 2)
%27 = fadd double %18, 0x3FF921FB544486E0
%28 = fsub double %27, %26
%29 = tail call double @mod2pi(double %28)
store double %29, double* %5
%30 = fadd double %29, 0xBFF921FB544486E0
%31 = fsub double %30, %2
%32 = tail call double @mod2pi(double %31)
store double %32, double* %7
%33 = load double, double* %5
%34 = fadd double %33, 0x3FF921FB544486E0
%35 = fadd double %32, %34
%36 = load double, double* %6
%37 = fadd double %36, %35
br label %38
38: ; preds = %15, %8, %24
%39 = phi double [ %37, %24 ], [ 1.000000e+04, %8 ], [ 1.000000e+04, %15 ]
ret double %39
}