#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 M_PI;
double atan2(double, double);
double const fabs(double);
double const sin(double);
double sqrt(double);
int CalcNextVelocities(double u_max, double x, double y, double phi, double *u,
                       double *omega) {
  double c, theta;
  double alpha;
  double e;
  const double gamma = 1.0, beta = 2.9, h = 2.0;
  const double epsilon = 0.00001;
  e = sqrt(x * x + y * y);
  if (e > epsilon) {
    theta = atan2(-y, -x);
    if (theta > M_PI)
      theta -= 2.0 * M_PI;
    if (theta < -M_PI)
      theta += 2.0 * M_PI;
    alpha = theta - phi;
    if (alpha > M_PI)
      alpha -= 2.0 * M_PI;
    if (alpha < -M_PI)
      alpha += 2.0 * M_PI;
    *u = gamma * e;
    if (*u >= u_max) {
      *u = u_max;
    }
    if (fabs(alpha) > epsilon) {
      c = (sin(alpha) + (h * theta * sin(alpha) / alpha + beta * alpha)) / e;
    } else {
      c = (alpha + alpha * beta + h * theta) / e;
    }
    *omega = c * *u;
  } else {
    *u = 0.0;
    *omega = 0.0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<CalcNextVelocities>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%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  0xea9(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe7f(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe6a(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1430 <CalcNextVelocities+0x2f0>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    0x2dc2(%rip),%rax
ucomisd (%rax),%xmm0
jbe    124d <CalcNextVelocities+0x10d>
mov    0x2db1(%rip),%rax
movsd  (%rax),%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
mov    0x2d8f(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    129b <CalcNextVelocities+0x15b>
mov    0x2d63(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x40(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    0x2d32(%rip),%rax
ucomisd (%rax),%xmm0
jbe    12dd <CalcNextVelocities+0x19d>
mov    0x2d21(%rip),%rax
movsd  (%rax),%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
mov    0x2cff(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    132b <CalcNextVelocities+0x1eb>
mov    0x2cd3(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x48(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xce5(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     1360 <CalcNextVelocities+0x220>
movsd  -0x8(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
call   1040 <fabs@plt>
movsd  0xc8e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13e5 <CalcNextVelocities+0x2a5>
movsd  -0x48(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  0xc75(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x80(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm2
divsd  -0x48(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
movsd  0xc46(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1416 <CalcNextVelocities+0x2d6>
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xc19(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1446 <CalcNextVelocities+0x306>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcNextVelocities>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movapd %xmm0,%xmm4
movapd %xmm2,%xmm5
mulsd  %xmm2,%xmm5
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm5,%xmm0
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm0
movapd %xmm4,(%rsp)
movsd  %xmm3,0x20(%rsp)
jb     118b <CalcNextVelocities+0x5b>
xorps  %xmm3,%xmm3
sqrtsd %xmm0,%xmm3
ucomisd 0xe87(%rip),%xmm3
ja     11b6 <CalcNextVelocities+0x86>
movq   $0x0,(%rbx)
xorpd  %xmm5,%xmm5
jmp    1330 <CalcNextVelocities+0x200>
movapd %xmm2,0x10(%rsp)
movapd %xmm1,0x30(%rsp)
call   1050 <sqrt@plt>
movapd 0x30(%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
movapd %xmm0,%xmm3
ucomisd 0xe4c(%rip),%xmm3
jbe    117b <CalcNextVelocities+0x4b>
movapd 0xe62(%rip),%xmm0
xorpd  %xmm0,%xmm2
xorpd  %xmm0,%xmm1
movapd %xmm2,%xmm0
movapd %xmm3,0x10(%rsp)
call   1030 <atan2@plt>
mov    0x2e0c(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe20(%rip),%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm2,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm1,%xmm4
cmpltsd %xmm0,%xmm4
movapd %xmm4,%xmm5
andnpd %xmm0,%xmm5
andpd  %xmm3,%xmm4
orpd   %xmm5,%xmm4
movapd 0xe0b(%rip),%xmm0
xorpd  %xmm1,%xmm0
movapd %xmm1,%xmm6
addsd  %xmm1,%xmm6
movapd %xmm6,%xmm3
addsd  %xmm4,%xmm3
movapd %xmm4,%xmm5
cmpltsd %xmm0,%xmm5
movapd %xmm0,%xmm7
andpd  %xmm5,%xmm3
andnpd %xmm4,%xmm5
orpd   %xmm3,%xmm5
movapd %xmm5,%xmm3
subsd  0x20(%rsp),%xmm3
addsd  %xmm3,%xmm2
cmpltsd %xmm3,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm3,%xmm1
orpd   %xmm2,%xmm1
movapd 0x10(%rsp),%xmm2
addsd  %xmm1,%xmm6
movapd %xmm1,%xmm0
cmpltsd %xmm7,%xmm0
andpd  %xmm0,%xmm6
andnpd %xmm1,%xmm0
orpd   %xmm6,%xmm0
movapd (%rsp),%xmm1
movapd %xmm1,%xmm3
cmplesd %xmm2,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm3
orpd   %xmm1,%xmm3
movlpd %xmm3,(%rbx)
movapd 0xd8a(%rip),%xmm1
andpd  %xmm0,%xmm1
ucomisd 0xd4e(%rip),%xmm1
jbe    1310 <CalcNextVelocities+0x1e0>
movapd %xmm5,(%rsp)
movapd %xmm0,0x20(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x30(%rsp)
movapd (%rsp),%xmm0
addsd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
movapd 0x20(%rsp),%xmm0
call   1040 <sin@plt>
movapd 0x20(%rsp),%xmm5
movapd 0x10(%rsp),%xmm2
mulsd  (%rsp),%xmm0
divsd  %xmm5,%xmm0
mulsd  0xd10(%rip),%xmm5
addsd  %xmm0,%xmm5
addsd  0x30(%rsp),%xmm5
movsd  (%rbx),%xmm3
jmp    1328 <CalcNextVelocities+0x1f8>
movsd  0xcf8(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm5,%xmm5
addsd  %xmm1,%xmm5
divsd  %xmm2,%xmm5
mulsd  %xmm3,%xmm5
movsd  %xmm5,(%r14)
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define i32 @CalcNextVelocities(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
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = 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
store double 1.000000e+00, double* %17
store double 2.900000e+00, double* %18
store double 2.000000e+00, double* %19
store double 1.000000e-05, double* %20
%21 = load double, double* %8
%22 = load double, double* %8
%23 = load double, double* %9
%24 = load double, double* %9
%25 = fmul double %23, %24
%26 = call double @llvm.fmuladd.f64(double %21, double %22, double %25)
%27 = call double @sqrt(double %26)
store double %27, double* %16
%28 = load double, double* %16
%29 = fcmp ogt double %28, 1.000000e-05
br i1 %29, label %30, label %116
30: ; preds = %6
%31 = load double, double* %9
%32 = fneg double %31
%33 = load double, double* %8
%34 = fneg double %33
%35 = call double @atan2(double %32, double %34)
store double %35, double* %14
%36 = load double, double* %14
%37 = load double, double* @M_PI
%38 = fcmp ogt double %36, %37
br i1 %38, label %39, label %43
39: ; preds = %30
%40 = load double, double* @M_PI
%41 = load double, double* %14
%42 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %40, double %41)
store double %42, double* %14
br label %43
43: ; preds = %39, %30
%44 = load double, double* %14
%45 = load double, double* @M_PI
%46 = fneg double %45
%47 = fcmp olt double %44, %46
br i1 %47, label %48, label %52
48: ; preds = %43
%49 = load double, double* @M_PI
%50 = load double, double* %14
%51 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %49, double %50)
store double %51, double* %14
br label %52
52: ; preds = %48, %43
%53 = load double, double* %14
%54 = load double, double* %10
%55 = fsub double %53, %54
store double %55, double* %15
%56 = load double, double* %15
%57 = load double, double* @M_PI
%58 = fcmp ogt double %56, %57
br i1 %58, label %59, label %63
59: ; preds = %52
%60 = load double, double* @M_PI
%61 = load double, double* %15
%62 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %60, double %61)
store double %62, double* %15
br label %63
63: ; preds = %59, %52
%64 = load double, double* %15
%65 = load double, double* @M_PI
%66 = fneg double %65
%67 = fcmp olt double %64, %66
br i1 %67, label %68, label %72
68: ; preds = %63
%69 = load double, double* @M_PI
%70 = load double, double* %15
%71 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %69, double %70)
store double %71, double* %15
br label %72
72: ; preds = %68, %63
%73 = load double, double* %16
%74 = fmul double 1.000000e+00, %73
%75 = load double*, double** %11
store double %74, double* %75
%76 = load double*, double** %11
%77 = load double, double* %76
%78 = load double, double* %7
%79 = fcmp oge double %77, %78
br i1 %79, label %80, label %83
80: ; preds = %72
%81 = load double, double* %7
%82 = load double*, double** %11
store double %81, double* %82
br label %83
83: ; preds = %80, %72
%84 = load double, double* %15
%85 = call double @fabs(double %84)
%86 = fcmp ogt double %85, 1.000000e-05
br i1 %86, label %87, label %102
87: ; preds = %83
%88 = load double, double* %15
%89 = call double @sin(double %88)
%90 = load double, double* %14
%91 = fmul double 2.000000e+00, %90
%92 = load double, double* %15
%93 = call double @sin(double %92)
%94 = fmul double %91, %93
%95 = load double, double* %15
%96 = fdiv double %94, %95
%97 = load double, double* %15
%98 = call double @llvm.fmuladd.f64(double 2.900000e+00, double %97, double %96)
%99 = fadd double %89, %98
%100 = load double, double* %16
%101 = fdiv double %99, %100
store double %101, double* %13
br label %110
102: ; preds = %83
%103 = load double, double* %15
%104 = load double, double* %15
%105 = call double @llvm.fmuladd.f64(double %104, double 2.900000e+00, double %103)
%106 = load double, double* %14
%107 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %106, double %105)
%108 = load double, double* %16
%109 = fdiv double %107, %108
store double %109, double* %13
br label %110
110: ; preds = %102, %87
%111 = load double, double* %13
%112 = load double*, double** %11
%113 = load double, double* %112
%114 = fmul double %111, %113
%115 = load double*, double** %12
store double %114, double* %115
br label %119
116: ; preds = %6
%117 = load double*, double** %11
store double 0.000000e+00, double* %117
%118 = load double*, double** %12
store double 0.000000e+00, double* %118
br label %119
119: ; preds = %116, %110
ret i32 0
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define i32 @CalcNextVelocities(double %0, double %1, double %2, double %3, double* nocapture %4, double* nocapture writeonly %5) {
%7 = fmul double %2, %2
%8 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %7)
%9 = tail call double @sqrt(double %8)
%10 = fcmp ogt double %9, 1.000000e-05
br i1 %10, label %11, label %51
11: ; preds = %6
%12 = fneg double %2
%13 = fneg double %1
%14 = tail call double @atan2(double %12, double %13)
%15 = load double, double* @M_PI
%16 = fcmp ogt double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %15, double -2.000000e+00, double %14)
%18 = select i1 %16, double %17, double %14
%19 = fneg double %15
%20 = fcmp olt double %18, %19
%21 = tail call double @llvm.fmuladd.f64(double %15, double 2.000000e+00, double %18)
%22 = select i1 %20, double %21, double %18
%23 = fsub double %22, %3
%24 = fcmp ogt double %23, %15
%25 = tail call double @llvm.fmuladd.f64(double %15, double -2.000000e+00, double %23)
%26 = select i1 %24, double %25, double %23
%27 = fcmp olt double %26, %19
%28 = tail call double @llvm.fmuladd.f64(double %15, double 2.000000e+00, double %26)
%29 = select i1 %27, double %28, double %26
%30 = fcmp oge double %9, %0
%31 = select i1 %30, double %0, double %9
store double %31, double* %4
%32 = tail call double @llvm.fabs.f64(double %29)
%33 = fcmp ogt double %32, 1.000000e-05
br i1 %33, label %34, label %43
34: ; preds = %11
%35 = tail call double @sin(double %29)
%36 = fmul double %22, 2.000000e+00
%37 = tail call double @sin(double %29)
%38 = fmul double %36, %37
%39 = fdiv double %38, %29
%40 = tail call double @llvm.fmuladd.f64(double %29, double 2.900000e+00, double %39)
%41 = fadd double %35, %40
%42 = load double, double* %4
br label %46
43: ; preds = %11
%44 = tail call double @llvm.fmuladd.f64(double %29, double 2.900000e+00, double %29)
%45 = tail call double @llvm.fmuladd.f64(double %22, double 2.000000e+00, double %44)
br label %46
46: ; preds = %43, %34
%47 = phi double [ %42, %34 ], [ %31, %43 ]
%48 = phi double [ %41, %34 ], [ %45, %43 ]
%49 = fdiv double %48, %9
%50 = fmul double %49, %47
br label %52
51: ; preds = %6
store double 0.000000e+00, double* %4
br label %52
52: ; preds = %51, %46
%53 = phi double [ 0.000000e+00, %51 ], [ %50, %46 ]
store double %53, double* %5
ret i32 0
}