#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;
float atan(float);
float polar_angle_rad(float x, float y) {
  float alpha;
  if (x == 0) {
    if (y <= 0)
      return 1.5 * M_PI;
    else
      return 0.5 * M_PI;
  } else {
    alpha = atan(y / x);
    if (x > 0 && y >= 0)
      return alpha;
    if (x > 0)
      return alpha + 2 * M_PI;
    return alpha + M_PI;
  }
}


x86 assembly (clang, -O0):
<polar_angle_rad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1188 <polar_angle_rad+0x78>
jp     1188 <polar_angle_rad+0x78>
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     1167 <polar_angle_rad+0x57>
movsd  0xeba(%rip),%xmm0
mov    0x2e93(%rip),%rax
mulsd  (%rax),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1225 <polar_angle_rad+0x115>
movsd  0xe91(%rip),%xmm0
mov    0x2e72(%rip),%rax
mulsd  (%rax),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1225 <polar_angle_rad+0x115>
movss  -0xc(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
call   1030 <atan@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11cd <polar_angle_rad+0xbd>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11cd <polar_angle_rad+0xbd>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1225 <polar_angle_rad+0x115>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1208 <polar_angle_rad+0xf8>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
mov    0x2dfa(%rip),%rax
movsd  (%rax),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1225 <polar_angle_rad+0x115>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    0x2dd0(%rip),%rax
addsd  (%rax),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<polar_angle_rad>:
push   %rax
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm2
jne    1138 <polar_angle_rad+0x28>
jp     1138 <polar_angle_rad+0x28>
ucomiss %xmm1,%xmm0
mov    0x2ec0(%rip),%rax
movsd  (%rax),%xmm0
jae    116d <polar_angle_rad+0x5d>
mulsd  0xed2(%rip),%xmm0
jmp    1175 <polar_angle_rad+0x65>
movss  %xmm1,(%rsp)
movaps %xmm1,%xmm0
divss  %xmm2,%xmm0
movss  %xmm2,0x4(%rsp)
call   1030 <atan@plt>
movss  0x4(%rsp),%xmm2
ucomiss 0xeb4(%rip),%xmm2
jbe    117b <polar_angle_rad+0x6b>
xorps  %xmm1,%xmm1
movss  (%rsp),%xmm3
ucomiss %xmm1,%xmm3
jb     117b <polar_angle_rad+0x6b>
pop    %rax
ret
mulsd  0xe8b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm2
cvtss2sd %xmm0,%xmm0
mov    0x2e5c(%rip),%rax
movsd  (%rax),%xmm1
jbe    1196 <polar_angle_rad+0x86>
addsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define float @polar_angle_rad(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %4
store float %1, float* %5
%7 = load float, float* %4
%8 = fcmp oeq float %7, 0.000000e+00
br i1 %8, label %9, label %20
9: ; preds = %2
%10 = load float, float* %5
%11 = fcmp ole float %10, 0.000000e+00
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load double, double* @M_PI
%14 = fmul double 1.500000e+00, %13
%15 = fptrunc double %14 to float
store float %15, float* %3
br label %47
16: ; preds = %9
%17 = load double, double* @M_PI
%18 = fmul double 5.000000e-01, %17
%19 = fptrunc double %18 to float
store float %19, float* %3
br label %47
20: ; preds = %2
%21 = load float, float* %5
%22 = load float, float* %4
%23 = fdiv float %21, %22
%24 = call float @atan(float %23)
store float %24, float* %6
%25 = load float, float* %4
%26 = fcmp ogt float %25, 0.000000e+00
br i1 %26, label %27, label %32
27: ; preds = %20
%28 = load float, float* %5
%29 = fcmp oge float %28, 0.000000e+00
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = load float, float* %6
store float %31, float* %3
br label %47
32: ; preds = %27, %20
%33 = load float, float* %4
%34 = fcmp ogt float %33, 0.000000e+00
br i1 %34, label %35, label %41
35: ; preds = %32
%36 = load float, float* %6
%37 = fpext float %36 to double
%38 = load double, double* @M_PI
%39 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %38, double %37)
%40 = fptrunc double %39 to float
store float %40, float* %3
br label %47
41: ; preds = %32
%42 = load float, float* %6
%43 = fpext float %42 to double
%44 = load double, double* @M_PI
%45 = fadd double %43, %44
%46 = fptrunc double %45 to float
store float %46, float* %3
br label %47
47: ; preds = %41, %35, %30, %16, %12
%48 = load float, float* %3
ret float %48
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define float @polar_angle_rad(float %0, float %1) {
%3 = fcmp oeq float %0, 0.000000e+00
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = fcmp ugt float %1, 0.000000e+00
%6 = load double, double* @M_PI
br i1 %5, label %10, label %7
7: ; preds = %4
%8 = fmul double %6, 1.500000e+00
%9 = fptrunc double %8 to float
br label %28
10: ; preds = %4
%11 = fmul double %6, 5.000000e-01
%12 = fptrunc double %11 to float
br label %28
13: ; preds = %2
%14 = fdiv float %1, %0
%15 = tail call float @atan(float %14)
%16 = fcmp ogt float %0, 0.000000e+00
%17 = fcmp oge float %1, 0.000000e+00
%18 = and i1 %16, %17
br i1 %18, label %28, label %19
19: ; preds = %13
%20 = fpext float %15 to double
%21 = load double, double* @M_PI
br i1 %16, label %22, label %25
22: ; preds = %19
%23 = tail call double @llvm.fmuladd.f64(double %21, double 2.000000e+00, double %20)
%24 = fptrunc double %23 to float
br label %28
25: ; preds = %19
%26 = fadd double %21, %20
%27 = fptrunc double %26 to float
br label %28
28: ; preds = %13, %25, %22, %10, %7
%29 = phi float [ %9, %7 ], [ %12, %10 ], [ %24, %22 ], [ %27, %25 ], [ %15, %13 ]
ret float %29
}