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


x86 assembly (clang, -O0):
<c_c2sc2_c>:
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
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -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 <c_c2sc2_c+0x9d>
movsd  0xe5d(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c6 <c_c2sc2_c+0x196>
cvttsd2si -0x58(%rbp),%edi
movsd  -0x50(%rbp),%xmm0
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 <c_c2sc2_c+0x10b>
movsd  0xdef(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c6 <c_c2sc2_c+0x196>
mov    -0x40(%rbp),%rax
movsd  0xdb9(%rip),%xmm0
addsd  (%rax),%xmm0
mov    $0x2,%edi
call   1040 <my_atan2@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  0xdb6(%rip),%xmm0
addsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
call   1030 <mod2pi@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1030 <mod2pi@plt>
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  0xd71(%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):
<c_c2sc2_c>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movsd  %xmm2,0x10(%rsp)
addsd  %xmm3,%xmm0
subsd  %xmm4,%xmm1
movsd  %xmm1,0x18(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm0,(%rsp)
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  0xe8c(%rip),%xmm1
cmp    $0x4,%eax
jl     122d <c_c2sc2_c+0xfd>
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  0xe43(%rip),%xmm0
movsd  %xmm0,(%rbx)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
movsd  0xe27(%rip),%xmm1
ja     122d <c_c2sc2_c+0xfd>
addsd  0xe2d(%rip),%xmm0
mov    $0x2,%edi
call   1040 <my_atan2@plt>
movsd  (%rsp),%xmm1
addsd  0xe1e(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <mod2pi@plt>
movsd  %xmm0,(%r15)
subsd  0x10(%rsp),%xmm0
call   1030 <mod2pi@plt>
movsd  %xmm0,(%r14)
movsd  (%r15),%xmm1
addsd  0xdfb(%rip),%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 @c_c2sc2_c(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 = fadd double %24, %25
store double %26, double* %18
%27 = load double, double* %11
%28 = load double, double* %14
%29 = fsub 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, 4.000000e+00
br i1 %39, label %40, label %41
40: ; preds = %8
store double 1.000000e+04, double* %9
br label %84
41: ; preds = %8
%42 = load double, double* %19
%43 = fptosi double %42 to i32
%44 = load double, double* %18
%45 = call double @my_atan2(i32 %43, double %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, 4.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 %84
57: ; preds = %41
%58 = load double*, double** %16
%59 = load double, double* %58
%60 = fadd double %59, 4.000000e+00
%61 = call double @my_atan2(i32 2, double %60)
store double %61, double* %22
%62 = load double, double* %21
%63 = fadd double 0x3FF921FB544486E0, %62
%64 = load double, double* %22
%65 = fadd 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 = load double, double* %12
%71 = fsub double %69, %70
%72 = call double @mod2pi(double %71)
%73 = load double*, double** %17
store double %72, double* %73
%74 = load double*, double** %15
%75 = load double, double* %74
%76 = fadd double %75, 0x400921FB544486E0
%77 = load double*, double** %17
%78 = load double, double* %77
%79 = fadd double %76, %78
%80 = load double*, double** %16
%81 = load double, double* %80
%82 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %79, double %81)
store double %82, double* %23
%83 = load double, double* %23
store double %83, double* %9
br label %84
84: ; preds = %57, %56, %40
%85 = load double, double* %9
ret double %85
}

LLVM IR (-O2):
define double @c_c2sc2_c(double %0, double %1, double %2, double %3, double %4, double* nocapture %5, double* nocapture %6, double* nocapture writeonly %7) {
%9 = fadd double %0, %3
%10 = fsub 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, 4
br i1 %14, label %37, label %15
15: ; preds = %8
%16 = sitofp i32 %13 to double
%17 = fptosi double %10 to i32
%18 = tail call double @my_atan2(i32 %17, double %9)
%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, -4.000000e+00
store double %22, double* %6
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %37, label %24
24: ; preds = %15
%25 = fadd double %22, 4.000000e+00
%26 = tail call double @my_atan2(i32 2, double %25)
%27 = fadd double %18, 0x3FF921FB544486E0
%28 = fadd double %27, %26
%29 = tail call double @mod2pi(double %28)
store double %29, double* %5
%30 = fsub double %29, %2
%31 = tail call double @mod2pi(double %30)
store double %31, double* %7
%32 = load double, double* %5
%33 = fadd double %32, 0x400921FB544486E0
%34 = fadd double %31, %33
%35 = load double, double* %6
%36 = fadd double %35, %34
br label %37
37: ; preds = %15, %8, %24
%38 = phi double [ %36, %24 ], [ 1.000000e+04, %8 ], [ 1.000000e+04, %15 ]
ret double %38
}