#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 */
int /*<<< orphan*/ EDOM;
float atanf(float const);
int /*<<< orphan*/ errno;
scalar_t__ fabsf(float const);
float atan2f(const float x, const float y) {
  float r;
  if ((x == 0.0) && (y == 0.0)) {
    errno = EDOM;
    return 0.0;
  }
  if (fabsf(y) >= fabsf(x)) {
    r = atanf(x / y);
    if (y < 0.0)
      r += (x >= 0 ? 3.14159265358979323846 : -3.14159265358979323846);
  } else {
    r = -atanf(y / x);
    r += (x < 0.0 ? -1.57079632679489661923 : 1.57079632679489661923);
  }
  return r;
}


x86 assembly (clang, -O0):
<atan2f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1189 <atan2f+0x69>
jp     1189 <atan2f+0x69>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1189 <atan2f+0x69>
jp     1189 <atan2f+0x69>
mov    0x2e77(%rip),%rax
mov    (%rax),%ecx
mov    0x2e5e(%rip),%rax
mov    %ecx,(%rax)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a1 <atan2f+0x181>
movss  -0xc(%rbp),%xmm0
call   1030 <fabsf@plt>
mov    %rax,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabsf@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jl     1230 <atan2f+0x110>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
call   1040 <atanf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    122b <atan2f+0x10b>
movss  -0x8(%rbp),%xmm1
xorps  %xmm2,%xmm2
movsd  0xe25(%rip),%xmm0
movsd  0xe25(%rip),%xmm3
movsd  %xmm3,-0x28(%rbp)
ucomiss %xmm2,%xmm1
movsd  %xmm0,-0x20(%rbp)
jae    1210 <atan2f+0xf0>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1297 <atan2f+0x177>
movss  -0xc(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
call   1040 <atanf@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd9e(%rip),%xmm3
movsd  0xd9e(%rip),%xmm2
xorps  %xmm0,%xmm0
cmpltsd %xmm0,%xmm1
movaps %xmm1,%xmm0
andpd  %xmm3,%xmm0
andnpd %xmm2,%xmm1
orpd   %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atan2f>:
push   %rbx
sub    $0x10,%rsp
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm2
jne    1153 <atan2f+0x33>
jp     1153 <atan2f+0x33>
ucomiss %xmm0,%xmm1
jne    1153 <atan2f+0x33>
jp     1153 <atan2f+0x33>
mov    0x2ea8(%rip),%rax
mov    (%rax),%eax
mov    0x2e8f(%rip),%rcx
mov    %eax,(%rcx)
xorps  %xmm0,%xmm0
jmp    11f4 <atan2f+0xd4>
movss  %xmm1,0xc(%rsp)
movaps %xmm1,%xmm0
movss  %xmm2,0x8(%rsp)
call   1030 <fabsf@plt>
mov    %rax,%rbx
movss  0x8(%rsp),%xmm0
call   1030 <fabsf@plt>
cmp    %rax,%rbx
jge    11b7 <atan2f+0x97>
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
movss  0x8(%rsp),%xmm1
ucomiss %xmm1,%xmm0
seta   %bl
movss  0xc(%rsp),%xmm0
divss  %xmm1,%xmm0
call   1040 <atanf@plt>
lea    0xe6f(%rip),%rax
movsd  (%rax,%rbx,8),%xmm1
cvtss2sd %xmm0,%xmm0
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
jmp    11f4 <atan2f+0xd4>
movss  0x8(%rsp),%xmm0
divss  0xc(%rsp),%xmm0
call   1040 <atanf@plt>
xorps  %xmm1,%xmm1
ucomiss 0xc(%rsp),%xmm1
jbe    11f4 <atan2f+0xd4>
xor    %eax,%eax
movss  0x8(%rsp),%xmm2
ucomiss %xmm1,%xmm2
setae  %al
cvtss2sd %xmm0,%xmm0
lea    0xe15(%rip),%rcx
addsd  (%rcx,%rax,8),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@EDOM = global i32 0
@errno = global i32 0
define float @atan2f(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 = fpext float %7 to double
%9 = fcmp oeq double %8, 0.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load float, float* %5
%12 = fpext float %11 to double
%13 = fcmp oeq double %12, 0.000000e+00
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = load i32, i32* @EDOM
store i32 %15, i32* @errno
store float 0.000000e+00, float* %3
br label %57
16: ; preds = %10, %2
%17 = load float, float* %5
%18 = call i64 @fabsf(float %17)
%19 = load float, float* %4
%20 = call i64 @fabsf(float %19)
%21 = icmp sge i64 %18, %20
br i1 %21, label %22, label %40
22: ; preds = %16
%23 = load float, float* %4
%24 = load float, float* %5
%25 = fdiv float %23, %24
%26 = call float @atanf(float %25)
store float %26, float* %6
%27 = load float, float* %5
%28 = fpext float %27 to double
%29 = fcmp olt double %28, 0.000000e+00
br i1 %29, label %30, label %39
30: ; preds = %22
%31 = load float, float* %4
%32 = fcmp oge float %31, 0.000000e+00
%33 = zext i1 %32 to i64
%34 = select i1 %32, double 0x400921FB54442D18, double 0xC00921FB54442D18
%35 = load float, float* %6
%36 = fpext float %35 to double
%37 = fadd double %36, %34
%38 = fptrunc double %37 to float
store float %38, float* %6
br label %39
39: ; preds = %30, %22
br label %55
40: ; preds = %16
%41 = load float, float* %5
%42 = load float, float* %4
%43 = fdiv float %41, %42
%44 = call float @atanf(float %43)
%45 = fneg float %44
store float %45, float* %6
%46 = load float, float* %4
%47 = fpext float %46 to double
%48 = fcmp olt double %47, 0.000000e+00
%49 = zext i1 %48 to i64
%50 = select i1 %48, double 0xBFF921FB54442D18, double 0x3FF921FB54442D18
%51 = load float, float* %6
%52 = fpext float %51 to double
%53 = fadd double %52, %50
%54 = fptrunc double %53 to float
store float %54, float* %6
br label %55
55: ; preds = %40, %39
%56 = load float, float* %6
store float %56, float* %3
br label %57
57: ; preds = %55, %14
%58 = load float, float* %3
ret float %58
}

LLVM IR (-O2):
@EDOM = global i32 0
@errno = global i32 0
define float @atan2f(float %0, float %1) {
%3 = fcmp oeq float %0, 0.000000e+00
%4 = fcmp oeq float %1, 0.000000e+00
%5 = and i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = load i32, i32* @EDOM
store i32 %7, i32* @errno
br label %31
8: ; preds = %2
%9 = tail call i64 @fabsf(float %1)
%10 = tail call i64 @fabsf(float %0)
%11 = icmp slt i64 %9, %10
br i1 %11, label %22, label %12
12: ; preds = %8
%13 = fdiv float %0, %1
%14 = tail call float @atanf(float %13)
%15 = fcmp olt float %1, 0.000000e+00
br i1 %15, label %16, label %31
16: ; preds = %12
%17 = fcmp oge float %0, 0.000000e+00
%18 = select i1 %17, double 0x400921FB54442D18, double 0xC00921FB54442D18
%19 = fpext float %14 to double
%20 = fadd double %18, %19
%21 = fptrunc double %20 to float
br label %31
22: ; preds = %8
%23 = fdiv float %1, %0
%24 = tail call float @atanf(float %23)
%25 = fneg float %24
%26 = fcmp olt float %0, 0.000000e+00
%27 = select i1 %26, double 0xBFF921FB54442D18, double 0x3FF921FB54442D18
%28 = fpext float %25 to double
%29 = fadd double %27, %28
%30 = fptrunc double %29 to float
br label %31
31: ; preds = %22, %16, %12, %6
%32 = phi float [ 0.000000e+00, %6 ], [ %21, %16 ], [ %14, %12 ], [ %30, %22 ]
ret float %32
}